I have a ReportsController
, nested in ProjectsController
, with a #show
method:
def show
# Some stuff
do_something(@report)
end
Routes:
resources :projects do
resources :reports
end
I need to test that the do_something
method is called:
it 'calls do_something' do
expect(controller).to receive(:do_something)
project = create :project
report = create :report, project: project
get :show, params: {project_id: project.id, id: report.id}
end
I placed binding.pry
within the #show
action, but this doesn't get called. So what's wrong with my spec?
The problem was that I wasn't logged in:
before do
@user = create :user, :admin
sign_in_as @user
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With