|
|
|
#1 |
|
Messages: n/a
Hébergeur: |
I'm just trying out RSpec with some really simple code. I have this
line: @subject.num(0).fizz?.should == false And I want it to pass if it's false OR nil. I tried using =~ but it made no difference. Is there no way to do this in Ruby? -- Posted via http://www.ruby-forum.com/. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Jan 7, 2008 7:25 PM, Oliver Saunders <oliver.saunders@gmail.com> wrote:
> I'm just trying out RSpec with some really simple code. I have this > line: > > @subject.num(0).fizz?.should == false > > And I want it to pass if it's false OR nil. I tried using =~ but it made > no difference. Is there no way to do this in Ruby? @subject.num(0).fizz?.should be -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
On Jan 7, 7:25 pm, Oliver Saunders <oliver.saund...@gmail.com> wrote:
> I'm just trying out RSpec with some really simple code. I have this > line: > > @subject.num(0).fizz?.should == false > > And I want it to pass if it's false OR nil. I tried using =~ but it made > no difference. Is there no way to do this in Ruby? > -- > Posted viahttp://www.ruby-forum.com/. This doesn't exactly answer your question, but isn't it unusual to have a method suffixed with a ? that doesn't return a boolean value? Anyway, here's a solution: @subject.num(0).fizz?.should_not be Regards, Jason |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Jan 7, 11:01 pm, "jwmerr...@gmail.com" <jwmerr...@gmail.com> wrote:
> This doesn't exactly answer your question, but isn't it unusual to > have a method suffixed with a ? that doesn't return a boolean value? Oh yeah, the reason I ask is because, if fizz? acted like other ? methods, you could do @subject.num(0).should_not be_fizz JM |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
On Jan 7, 2008 11:05 PM, jwmerrill@gmail.com <jwmerrill@gmail.com> wrote:
> Anyway, here's a solution: > > @subject.num(0).fizz?.should_not be Time for me to get new reading glasses, I got the sense of the test reversed. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/ |
|
![]() |
| Outils de la discussion | |
|
|