I have this example:
context "on get to new" do
it "should assign cardset" do
@profile.cardsets.expects(:build).once.returns(Factory.stub(:cardset))
get :new
assigns[:cardset].should_not be_nil
end
end
To test this method:
def new
@cardset = current_user.cardsets.build
end
I am trying to ensure that the association is built out current_userto ensure that the user creates only what belongs to them. I use expectation very much like they are calling findfrom an object current_userand it works, but when I run the above example, I get:
6)
Mocha::ExpectationError in 'CardsetsController for a logged in user on get to new should assign cardset'
not all expectations were satisfied
unsatisfied expectations:
- expected exactly once, not yet invoked: [
satisfied expectations:
- allowed any number of times, not yet invoked: ApplicationController.require_user(any_parameters)
- allowed any number of times, already invoked twice:
/Applications/MAMP/htdocs/my_app/spec/controllers/cardsets_controller_spec.rb:32:
source
share