我收到以下错误消息:
rails_projects/sample_app/spec/models/user_spec.rb:6: syntax error, unexpected ',', expecting ')'
@attr = ( :name => "Example User", :email => "user@example.com")在我设置并仅设置user_spec.rb文件后,需要'spec_helper‘
describe User do
before(:each) do
@attr = ( :name => "Example User", :email => "user@example.com")
# pending "add seme examples to (or delete) #{__FILE__}"
end
it "should create a new instance given valid attributes" do
User.create!(@attr)
end
it "should require a name"
end我知道我仍然会在代码中得到一条挂起的消息,但是不会出现语法错误
发布于 2011-06-16 10:17:20
您需要在此处使用{...} for Hash语法:
@attr = { :name => "Example User", :email => "user@example.com" }Ps。只需检查教程和it shows the same -你犯了一个拼写错误,不用担心(教程中的代码使用的字体应该更好!)
https://stackoverflow.com/questions/6366423
复制相似问题