My code:
puts questionframe.radio(:id, "rlbYesNo_0").checked?
questionframe.radio(:id, "rlbYesNo_0").checked? should equal true
It outputs "true" for the first line, but for the second line, it
gives this error:
expected #<TrueClass:2> => true
got #<String:103356170> => "Yesno"
It does return true when I print it to the screen, but when using
"should" to check it, it somehow thinks it returns the text "Yesno".
Can anyone explain what's going on and what I can do to fix this?
Thanks,
James
--
You received this message because you are subscribed to the Google Groups "Watir General" group.
To post to this group, send email to watir-...@googlegroups.com
Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to watir-genera...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/watir-general
I have:
questionframe.radio(:id, "rlbYesNo_0").checked? should(be_true)
(I also tried it without parentheses and got the same error, plus a
warning that I should have parentheses.)
This is the output:
1)
ArgumentError in 'Yesno should answer Yes on first question'
wrong number of arguments (1 for 0)
yesno_spec.rb:45:in `checked?'
yesno_spec.rb:45:
yesno_spec.rb:9:
If I check for "false", I get a similar error as before:
I have:
questionframe.radio(:id, "rlbYesNo_0").checked? should(be_false)
My output:
2)
'Yesno should change answer from Yes to no' FAILED
expected false, got "Yesno"
yesno_spec.rb:54:
yesno_spec.rb:9:
Any ideas?
On Feb 9, 11:23 am, Charley Baker <charley.ba...@gmail.com> wrote:
> Wrong matcher, use be_true instead:
>
> questionframe.radio(:id, "rlbYesNo_0").checked? should be_true
>
> -Charley
> Lead Developer, Watir,http://watir.com
>
> On Tue, Feb 9, 2010 at 8:58AM, James <jgcpal...@gmail.com> wrote:
> > I'm trying to check if a radio button is checked or not, using the
> > Rspec "should" command, but it's not acting as I would expect.
>
> > My code:
>
> > puts questionframe.radio(:id, "rlbYesNo_0").checked?
> > questionframe.radio(:id, "rlbYesNo_0").checked? should equal true
>
> > It outputs "true" for the first line, but for the second line, it
> > gives this error:
>
> > expected #<TrueClass:2> => true
> > got #<String:103356170> => "Yesno"
>
> > It does return true when I print it to the screen, but when using
> > "should" to check it, it somehow thinks it returns the text "Yesno".
>
> > Can anyone explain what's going on and what I can do to fix this?
>
> > Thanks,
> > James
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Watir General" group.
> > To post to this group, send email to watir-...@googlegroups.com
> > Before posting, please read the following guidelines:
> >http://wiki.openqa.org/display/WTR/Support
> > To unsubscribe from this group, send email to
> > watir-genera...@googlegroups.com<watir-general%2Bunsu...@googlegroups.com>
James
On Feb 9, 12:13 pm, Charley Baker <charley.ba...@gmail.com> wrote:
> Oopsy daisy. I left out a dot. Note the dot before should.
>
> questionframe.radio(:id, "rlbYesNo_0").checked?.should be_true
>
> that.should work :)
>
> -c
>
> On Tue, Feb 9, 2010 at 9:48AM, James <jgcpal...@gmail.com> wrote:
> > Hmm, that's not working for me.
>
> > I have:
> > questionframe.radio(:id, "rlbYesNo_0").checked? should(be_true)
>
> > (I also tried it without parentheses and got the same error, plus a
> > warning that I should have parentheses.)
>
> > This is the output:
> > 1)
> > ArgumentError in 'Yesno should answer Yes on first question'
> > wrong number of arguments (1 for 0)
> > yesno_spec.rb:45:in `checked?'
> > yesno_spec.rb:45:
> > yesno_spec.rb:9:
>
> > If I check for "false", I get a similar error as before:
> > I have:
> > questionframe.radio(:id, "rlbYesNo_0").checked? should(be_false)
>
> > My output:
> > 2)
> > 'Yesno should change answer from Yes to no' FAILED
> > expected false, got "Yesno"
> > yesno_spec.rb:54:
> > yesno_spec.rb:9:
>
> > Any ideas?
>
> > <watir-general%2Bunsu...@googlegroups.com<watir-general%252Buns...@googlegroups.com>
I vote for:
questionframe.radio(:id, "rlbYesNo_0").should be_checked
(or radio.should be_set)
to negate
questionframe.radio(:id, "rlbYesNo_0").should_not be_checked
more BDD flavor in this one.
the matcher will call .checked? method automatically part of a be_ pattern
I think any predicate in watir can be used in rspec, so exists? can e
queried with element.should exist (Bret has fixed that)
and include? will be should include('some value')
more about predicates in rspec here
http://rspec.rubyforge.org/rspec/1.3.0/classes/Spec/Matchers.html
marekj
Watirloo: Semantic Page Objects in UseCases
http://github.com/marekj/watirloo/
Support Watir Project http://pledgie.com/campaigns/2982
--
You received this message because you are subscribed to the Google Groups "Watir General" group.
To post to this group, send email to watir-...@googlegroups.com
Before posting, please read the following guidelines: http://wiki.openqa.org/display/WTR/Support
To unsubscribe from this group, send email to watir-genera...@googlegroups.com
I'm having similar issues trying to match the value of a text field.
textfield.value should equal "test"
gives similar problems I was having before. What should I be using?
And is there a list somewhere that I can find all these matchers? I'm
having trouble finding a comprehensive resource on this.
Thanks,
James
On Feb 9, 1:22 pm, Charley Baker <charley.ba...@gmail.com> wrote:
> Actually that's a good point, I definitely agree it's cleaner syntax. We use
> that same syntax all over, rarely check for checked, but certainly use it
> for exists, include, displayed, etc.
>
> Follow Marek's advice. :)
>
> -c
>
> On Tue, Feb 9, 2010 at 10:39AM, marekj <marekj....@gmail.com> wrote:
> > On Tue, Feb 9, 2010 at 11:21AM, James <jgcpal...@gmail.com> wrote:
> > > That worked perfectly, thanks!
>
> > > James
>
> > > On Feb 9, 12:13pm, Charley Baker <charley.ba...@gmail.com> wrote:
> > >> Oopsy daisy. I left out a dot. Note the dot before should.
>
> > >> questionframe.radio(:id, "rlbYesNo_0").checked?.should be_true
>
> > I vote for:
> > questionframe.radio(:id, "rlbYesNo_0").should be_checked
> > (or radio.should be_set)
> > to negate
> > questionframe.radio(:id, "rlbYesNo_0").should_not be_checked
>
> > more BDD flavor in this one.
> > the matcher will call .checked? method automatically part of a be_ pattern
> > I think any predicate in watir can be used in rspec, so exists? can e
> > queried with element.should exist (Bret has fixed that)
> > and include? will be should include('some value')
>
> > more about predicates in rspec here
> >http://rspec.rubyforge.org/rspec/1.3.0/classes/Spec/Matchers.html
>
> > marekj
>
> > Watirloo: Semantic Page Objects in UseCases
> >http://github.com/marekj/watirloo/
> > Support Watir Projecthttp://pledgie.com/campaigns/2982
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Watir General" group.
> > To post to this group, send email to watir-...@googlegroups.com
> > Before posting, please read the following guidelines:
> >http://wiki.openqa.org/display/WTR/Support
> > To unsubscribe from this group, send email to
> > watir-genera...@googlegroups.com<watir-general%2Bunsu...@googlegroups.com>
textfield.value.should == "test"
is what I needed to do.
So charley, does that mean that the rspec predicate matcher for exists? would be ...
obj.should be_exists ?
On Feb 9, 2010 2:46 PM, "James" <jgcp...@gmail.com> wrote:
Ok, solved it myself:
textfield.value.should == "test"
is what I needed to do.
On Feb 9, 3:21 pm, James <jgcpal...@gmail.com> wrote:
> Thanks guys!
>
> I'm having similar issues ...
obj.should exist
On Feb 9, 4:26 pm, Alan Baird <aba...@bairdsnet.net> wrote:
> So charley, does that mean that the rspec predicate matcher for exists?
> would be ...
> obj.should be_exists ?
>
> On Feb 9, 2010 2:46PM, "James" <jgcpal...@gmail.com> wrote:
>
> Ok, solved it myself:
>
> textfield.value.should == "test"
>
> is what I needed to do.
>
James - I agree that it should be this way, but the way I'm reading this line leads me to believe otherwise:
" All you need to do is write +should be_+ followed by the predicate without the question mark, and RSpec will figure it out from there. For example:
[].should be_empty => [].empty? #passes
[].should_not be_empty => [].empty? #fails"
Am I missing something?
Alan
This email message and any attachments are for the sole use of the intended recipients and may contain proprietary and/or confidential information which may be privileged or otherwise protected from disclosure. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not an intended recipient, please contact the sender by reply email and destroy the original message and any copies of the message as well as any attachments to the original message.
Alan, the matchers are malleable and usually written in a way a person
would talk.
empty? => should be_empty (because some thing is empty)
exists? => should exist (becuase there is no need to force be_ here)
Rspec gives you a mechanism to define your matchers:
so if you have a method like object.blinks? that returns true or false
you can make a matcher
object.should blink
or
object.should_not blink
I did mention in my earlier post that element.should exist was a fix
to rspec contributed by Bret a while back (too lazy to find the
relevant code)
Marek-thanks...I got it to work as you suggested...exists and even include work for me without using '_be'
Alan
On Feb 9, 2010 6:33 PM, "marekj" <marekj.com@gmail.com> wrote:
On Tue, Feb 9, 2010 at 4:54 PM, Alan Baird <alan....@riskmetrics.com> wrote:
>>According to >http:...
Alan, the matchers are malleable and usually written in a way a person
would talk.
empty? => should be_empty (because some thing is empty)
exists? => should exist (becuase there is no need to force be_ here)
Rspec gives you a mechanism to define your matchers:
so if you have a method like object.blinks? that returns true or false
you can make a matcher
object.should blink
or
object.should_not blink
I did mention in my earlier post that element.should exist was a fix
to rspec contributed by Bret a while back (too lazy to find the
relevant code)
marekj
Watirloo: Semantic Page Objects in UseCases
http://github.com/marekj/watirloo/
Support Watir Project http://pledgie.com/campaigns/2982
--
You received this message because you are subscribed to the Google Groups "Watir General" group.
To ...
class Person
def has_brain?
true
end
end
person = Person.new
person.should have_brain
Neat, eh?
That's the beauty of RSpec (and other similar DSL-s) and that's why i
have been using RSpec instead of Test::Unit for a long time already.
Jarmo
On Feb 10, 8:38 pm, Alan Baird <aba...@bairdsnet.net> wrote:
> Marek-thanks...I got it to work as you suggested...exists and even include
> work for me without using '_be'
>
> Alan
>
> On Feb 9, 2010 6:33 PM, "marekj" <marekj....@gmail.com> wrote:
>
> On Tue, Feb 9, 2010 at 4:54 PM, Alan Baird <alan.ba...@riskmetrics.com>
> wrote:>>According to >http:...
>
> Alan, the matchers are malleable and usually written in a way a person
> would talk.
> empty? => should be_empty (because some thing is empty)
> exists? => should exist (becuase there is no need to force be_ here)
>
> Rspec gives you a mechanism to define your matchers:
> so if you have a method like object.blinks? that returns true or false
> you can make a matcher
>
> object.should blink
> or
> object.should_not blink
>
> I did mention in my earlier post that element.should exist was a fix
> to rspec contributed by Bret a while back (too lazy to find the
> relevant code)
>
> marekj
>
> Watirloo: Semantic Page Objects in UseCaseshttp://github.com/marekj/watirloo/
>
> Support Watir Projecthttp://pledgie.com/campaigns/2982