syntax error, unexpected '\n', expecting => (SyntaxError)
12,483
Your error seem to be in the next line:
post :create, :booking_id => 1, params
You need to change it to:
post :create, params.merge(booking_id: 1)
Or include booking_id: 1
in params at once.
Ruby cannot parse options hash in the end of method call, it expects smth like
post :create, :booking_id => 1, params => 'something'
Author by
Will Taylor
Updated on August 04, 2022Comments
-
Will Taylor almost 2 years
Using RSpec to run some tests, I get the following error:
/spec/requests/booking_applications_spec.rb:13: syntax error, unexpected '\n', expecting => (SyntaxError)
Here's the file:
spec/requests/booking_applications_spec.rb:
require 'spec_helper' require "rails_helper" RSpec.describe "Booking applications", :type => :request do describe "POST new booking application" do it "creates a new booking application" do BookingApplication.destroy_all BookingApplication.count.should == 0 params = { format: :json, booking_application: { driver_id: 1 } } #Error post :create, :booking_id => 1, params BookingApplication.count.should == 1 response.status.should eq(200) end end end