rspec/rspec-mocks — Issue #114: Mock works `before :each` but not `before :all`?
Author: nathanl
Created: 2012-03-02 21:48:01+00:00
State: open

I'm mocking `Time.new` in a few tests to ensure that a method returns a predictable result. I've just found that, if I do this:

```ruby
before :all do
t = Time.new(2000, 1, 31)
Time.stub!(:now).and_return(t)
end
```

... I get `undefined method `stub!' for Time:Class`. However, if I change `before :all` to `before :each`, it works.

Is this a bug, or is there a good reason for it?