我有一段代码,我试图运行rspec。Rails 4 - 语法错误,意外tidENTIFIER,预计输入结束
require 'spec_helper'
describe "User" do
before { @user = User.new(name: "Example User", email: "[email protected]", password: "foobar", password_confirmation: "foobar") }
subject { @user }
it { should respond_to(:name)}
end
我收到以下错误
c:\Sites\sample_app>rspec spec/models/user_spec.rb
C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/rspec-core-2.13.1/lib/rspec
/core/configuration.rb:819:in `load': c:/Sites/sample_app/spec/models/user_spec.
rb:1: syntax error, unexpected tIDENTIFIER, expecting end-of-input (SyntaxError)
before { @user...er'
现在我重新输入一个新的文件,测试和运行,并没有错误。我想有一些编码问题,或者我没有了解到我没有得到的东西。有没有人能够解释这个问题?
错误来自第1行,您要求spec_helper,那么您可以共享spec_helper代码吗? –
是的,因为错误说“user_spec.rb:1”...我写错了这个问题吗?奇怪它已经有-1。只是寻找一些帮助:/ –
请重新阅读来自@SachinSingh的评论:-)你被要求发布你的'spec_helper.rb'文件,因为这可能是问题的源头(没有双关语意)。 –