[rspec-users] Suggestions on how to use stub_model with webrat?

Danny Sofer d at sofer.com
Tue Jun 24 11:39:44 EDT 2008


Hi all,

I am using story runner with webrat, but I am not sure how to  
incorporate stub_model into my tests.

The webrat steps only care about the user interface and have nothing  
to say about interaction with the database.

Following Ben Mabey, I have a line in my story like:

"When clicks the Create button"

And a step like:

When "clicks the $button button" do |button|
   clicks_button button
end

Would it be sensible to extend it as follows:

"And clicks the Create button to create a new thing"

With step:

When "clicks the $button button to create a new $resource" do |button,  
resource|
   klass      = resource.classify.constantize
   stub_model(klass)
   clicks_button button
end

Or is there a better way of making sure that all required models are  
stubbed?

many thanks,

danny



More information about the rspec-users mailing list