search for: stub_association

Displaying 2 results from an estimated 2 matches for "stub_association".

2007 Oct 05
7
Easy AR association stubbing
...p code for the controller and model specs that use associations. #before @person = mock_model(Person) posts = mock(''post_proxy'') posts.stub!(:build).and_return(mock_model(Post, :save => true)) @person.stub!(:posts).and_return(posts) # now @person = mock_model(Person) @person.stub_association!(:posts, :find_by_title => mock_model(Post)) Just add this to the spec helper module Spec module Mocks module Methods def stub_association!(association_name, methods_to_be_stubbed = {}) mock_association = Spec::Mocks::Mock.new(association_name.to_s) methods_to_be_s...
2007 Oct 08
6
spec''in controllers request for nested routes
describe PlayersController, "handling GET /saltmines/games/1/players" do before do @game = mock_model(Game, :to_param => "1") @game.stub_association!(:players, :find => mock_model(Player)) end def do_get get :index, :game_id => @game end it "should be successful" do do_get response.should be_success end it "should render index template" do do_get response.should render_template('&...