The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Sprinkle Some Integration Tests into a Mock Heavy Test Suite

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Jake Scruggs

Posts: 336
Nickname: aurorae314
Registered: Feb, 2008

Jake Scruggs is a developer at ThoughtWorks
Sprinkle Some Integration Tests into a Mock Heavy Test Suite Posted: Dec 2, 2008 8:03 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Jake Scruggs.
Original Post: Sprinkle Some Integration Tests into a Mock Heavy Test Suite
Feed Title: Jake Scruggs
Feed URL: http://jakescruggs.blogspot.com/feeds/posts/default
Feed Description: Ruby, Rails, Metrics, Testing, and pursuit of clean code.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Jake Scruggs
Latest Posts From Jake Scruggs

Advertisement
I like mocks and stubs and I use them liberally in my tests. This practice, however, is not without danger: If my models, views, and controllers are all tested in isolation then how will I know if a model change busts a controller or a view? Here's something I like to drop in at the end of every controller spec:




1
2
3
4
5
6
7
8
9
10
11
12
describe JerkStoreController, "with views integrated and real objects" do
integrate_views

it "should render the page without blowing up" do
store = JerkStore.create!(:name => "Costanza's house of bargins")
store.products << Jerk.create!(:name => "Puddy") <<
Jerk.create!(:name => "Newman") <<
Jerk.create!(:name => "Steinbrenner")

post :show, :id => store.id
end
end
Not a mock or a stub as far as the eye can see and I'm even integrating views. Normally RSpec doesn't render the view in a controller spec, but if you include "integrate_views" it will. So now if I make some changes that bust MVC integration my spec will let me know. I don't try to exercise all the possible paths with these tests -- rather they are a safety net for problems isolated specs won't detect.

Read: Sprinkle Some Integration Tests into a Mock Heavy Test Suite

Topic: self.facts.randomly_select(7) Previous Topic   Next Topic Topic: Testing private class methods in Ruby

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use