Skip to content

Instantly share code, notes, and snippets.

@thoughtbot
Created August 4, 2009 22:29
Show Gist options
  • Save thoughtbot/162345 to your computer and use it in GitHub Desktop.
Save thoughtbot/162345 to your computer and use it in GitHub Desktop.
class HouseSearchesTest < ActionController::TestCase
should_route :get, '/house_searches',
:controller => :house_searches,
:action => :index
context "GET to index with houses" do
setup do
@houses = [Factory.stub(:house), Factory.stub(:house)]
@search = HouseSearch.new
HouseSearch.stubs(:new).returns(@search)
@search.stubs(:results).returns(@houses)
@params = 'the params'
get :index, :house_search => @params
end
should_render_template :index
should "assign the houses to @houses" do
assert_received(@search, :results) {|expects| expects.with()}
assert_equal @houses, assigns(:houses)
end
should "assign the house search to @house_search" do
assert_received(HouseSearch, :new) {|expects| expects.with(@params)}
assert_equal @search, assigns(:house_search)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment