开发者

Michael Hartl guide chapter 6 syntax error user_spec.rb

开发者 https://www.devze.com 2023-03-13 12:49 出处:网络
I am getting the following error me开发者_StackOverflow社区ssage: rails_projects/sample_app/spec/models/user_spec.rb:6: syntax error, unexpected \',\', expecting \')\'

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!)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号