I am getting the following error me开发者_StackOverflow社区ssage:
rails_projects/sample_app/spec/models/user_spec.rb:6: syntax error, unexpected ',', expecting ')'
@attr = ( :name => "Example User", :email => "user@example.com")
After I setup and only setup the user_spec.rb file require '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
I know I will still get a pending message at the code however not a syntax error
You need to use the {...}
for Hash syntax here:
@attr = { :name => "Example User", :email => "user@example.com" }
Ps. Just checked the tutorial and it shows the same - you made a typo, no worries (The font used for code in the tutorial could have been better!)
精彩评论