Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
chris salvi
7,584 Pointshelp reading errors on ODOT user_sessions_controller_spec
The terminal is saying I have a bunch of syntax errors on these lines, but Im not sure what I did wrong. I have fixed many syntax errors in my specs, but these ones have been befuddling.
here are the errors for reference
/Users/salvi/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load': /Users/salvi/rprojects/odot/spec/controllers/user_sessions_controller_spec.rb:82: syntax error, unexpected '{', expecting ')' (SyntaxError)
let(:email {user.email})
^
/Users/salvi/rprojects/odot/spec/controllers/user_sessions_controller_spec.rb:82: syntax error, unexpected '}', expecting keyword_end
let(:email {user.email})
^
/Users/salvi/rprojects/odot/spec/controllers/user_sessions_controller_spec.rb:88: syntax error, unexpected '{', expecting ')'
let(:email{"none@found.com"}
^
CODE
context "with an incorrect password" do
let!(:user) {User.create(first_name: "Chris", last_name:"Salvi", email:"csalvi42@gmail.com", password: "treehouse1", password_confirmation: "treehouse1" )}
let(:email) user.email
let(:password) {"incorrect"}
it_behaves_like "denied login"
end
context "with no email in existence" do
let(:email) "none@found.com"
let(:password){"incorrect"}
it_behaves_like "denied login"
end
1 Answer
J Scott Erickson
11,883 PointsBest guess based on the error and your code
let(:email) {user.email}
....
let(:email) {"none@found.com"}
J Scott Erickson
11,883 PointsJ Scott Erickson
11,883 PointsI can expound a bit on this now that I took a quick second the think about it, let() as a function takes two arguments. the first (:email) and the second {user.email} both need to be wrapped because how the syntax is parsed for rpsec