ruby on rails 3 - Best way to modify factory attributes for multiple tests? -
trying test routing rspec , factories. best way modify existing factory multiple times inside spec test?
require "spec_helper" describe gamecontroller describe "routing" game = factorygirl.create(:game) "routes #show" get("/game/1").should route_to("game#show", :id => "1") end "routes #show" # need modify 1 param of factory.. how best this? get("/game/1").should route_to("game#show", :id => "1") end end end
you have 2 options. if you're modifying single param between test, might easiest like:
before(:each) game = factorygirl.create(:game) end "does something" get("/game/1").should route_to("game#show", :id => "1") end "does else" game.update_attributes(:param => "value") get("/game/1").should route_to("game#show", :id => "1") end otherwise, set factory girl sequence , fresh factorygirl.create in each spec.
Comments
Post a Comment