More loosely typed expression

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?

On Jan 7, 2008 7:25 PM, Oliver S. [email protected]
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/

On Jan 7, 7:25 pm, Oliver S. [email protected] 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

On Jan 7, 2008 11:05 PM, [email protected] [email protected]
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/

On Jan 7, 11:01 pm, “[email protected][email protected] 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