Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

syntax error, unexpected '\n', expecting => (SyntaxError)

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
like image 909
Will Taylor Avatar asked Mar 26 '26 20:03

Will Taylor


1 Answers

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'
like image 199
faron Avatar answered Mar 28 '26 10:03

faron