I’m working on some code that uses association proxies. I’m trying to
get away from using fixtures, and move more to mocking and stubbing.
So far, so good, but the methods I cant figure out, even with
extensive googling, are how to simulate the association_proxy.build
method in rails.
I’m on edge rails and edge rspec.
Datawise, a bar has_many suggested_beers, and a suggested_beer belongs
to a bar
@bar = Bar.find(params[:bar_id])
This is generated with rspec_scaffold, and i’ve added in the beer_id,
bar_id, and ip_address attributes for stubbing.
@mock_suggested_beer ||= mock_model(SuggestedBeer, stubs) get :new, :bar_id => "1" response.should render_template('new') end it "should create a new suggested_beer" do
get :new, :bar_id => “1”
“should create a new suggested_beer” fails with this message
Spec::Mocks::MockExpectationError in ‘SuggestedBeersController
responding to GET /bars/1/suggested_beers/new should create a new
Mock ‘SuggestedBeer_1016’ received unexpected message := with
I don’t know how to fix this.
I’ve looked at several articles, specifically
but I’m still confused.
Any help is much appreciated!
Sam Granieri, Jr
irc (freenode): samgranieri
Recommend me at WWR!