简体   繁体   English

语法错误,意外的'\\ n',期望=>(SyntaxError)

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

Using RSpec to run some tests, I get the following error: 使用RSpec运行一些测试,我得到以下错误:

/spec/requests/booking_applications_spec.rb:13: syntax error, unexpected '\n', expecting => (SyntaxError)

Here's the file: 这是文件:

spec/requests/booking_applications_spec.rb: 规格/要求/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

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. 或在参数中同时包含booking_id: 1

Ruby cannot parse options hash in the end of method call, it expects smth like Ruby无法在方法调用结束时解析选项哈希,它期望像

  post :create, :booking_id => 1, params => 'something'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 语法错误,意外的'\\ n',期望=> - syntax error, unexpected '\n', expecting => 语法错误,意外的'\\ n',期望::或'['或'。 - syntax error, unexpected '\n', expecting :: or '[' or '.' Figaro语法错误,意外的tSYMBEG,预期为“}”(SyntaxError) - Figaro syntax error, unexpected tSYMBEG, expecting '}' (SyntaxError) 语法错误,意外tLABEL,期待')'(SyntaxError) - Syntax error, unexpected tLABEL, expecting ')' (SyntaxError) 语法错误,意外的tIDENTIFIER,期待';' 或'\\ n' - syntax error, unexpected tIDENTIFIER, expecting ';' or '\n' Mailer生成语法错误:意外的'\\ n',期望::或'['或'。 - Mailer Generating Syntax Error: unexpected '\n', expecting :: or '[' or '.' Ruby on Rails语法错误,意外的'\\ n',期望&。 或::或'['或'。 - Ruby on Rails syntax error, unexpected '\n', expecting &. or :: or '[' or '.' 语法错误,意外'\\ n',期待tCOLON2或'['或'。' - Syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.' rails SyntaxError 意外,期望然后或';' 或 '\\n' - rails SyntaxError unexpected in, expecting then or ';' or '\n' 语法错误,意外的'}',期望::或'['或'。' - Syntax error, unexpected '}', expecting :: or '[' or '.'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM