[rspec-users] Stubbing Time.now in trunk

Jay Levitt lists-rspec at shopwatch.org
Thu Nov 9 20:48:29 EST 2006

I'm a big fan of stubbing Time.now so it returns a known value.  I used 
to be able to use stubba and say:

@time_now = Time.parse("Jan 1 2001")

However, something in trunk broke that.  Fine, rspec's got its own 
stubbing lib now, so I tried switching to that:

@time_now = Time.parse("Jan 1 2001")

This gives me some VERY odd errors.  For instance, if this is in a 
controller spec, and the next line is
  get 'index'

I get:

wrong number of arguments (1 for 0)
./spec/controllers/one_spec.rb:9:in `should render the index page'

Line 9 is the get 'index' line. If I delete that, so there is no next 
line, I get:

NoMethodError in 'the test app should render the index page'
undefined method `to_i' for 
#<Proc:0x04a0374c at ./spec/controllers/one_spec.rb:8>

Am I doing something wrong, or is this a bug in trunk?


More information about the rspec-users mailing list