Reputation: 1066
This is a piece of code which throws an error "Wrong number of args (1 for 0) on the 5-th line:
describe 'PATCH #update' do
context 'title is empty' do
it 'should not update page' do
page = create(:page)
patch :update, { id: page.id, page: FactoryGirl.attributes_for(:page, title: nil) }, format: :json
expect(response).to have_http_status(:unprocessable_entity)
end
end
end
Rails controller:
def update
if @page.update(page_params)
render json: @page
else
status :unprocessable_entity
end
end
Other tests work just fine, but this for #update's else
- doesn't .
Cant' get it, what's the problem and how can I fix this? (feature works just fine, but test fails)
Upvotes: 0
Views: 201
Reputation: 33542
You need to change your update
method to below
def update
if @page.update(page_params)
render json: @page
else
render json: @page.errors, status: :unprocessable_entity
end
end
Upvotes: 1