[rspec-users] Cucumber - stub! or mock?

Luke Melia luke at lukemelia.com
Tue Sep 30 15:56:04 EDT 2008


On Sep 30, 2008, at 10:55 AM, Luke Melia wrote:

> We need to stub time in some of our scenarios, which exist to to  
> verify behavior over time. We're looking into a before/after to  
> support mocking/stubbing for this scenario.

Thanks for everyone's thoughts. I understand that mocks are generally  
an anathema to story tests. We've decided to use them to solve this  
particular problem, though, and rely on our own self-discipline to not  
abuse their presence. Here's what we're going with for now in our  
env.rb:

require 'spec/mocks'
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..",  
"vendor", "plugins", "rspec", "plugins", "mock_frameworks", "rspec"))
include Spec::Plugins::MockFramework

Before do
   setup_mocks_for_rspec
end

After do
   begin
     verify_mocks_for_rspec
   ensure
     teardown_mocks_for_rspec
   end
end

Luke
--
Luke Melia
luke at lukemelia.com
http://www.lukemelia.com/



More information about the rspec-users mailing list