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

Ruby

What is wrong with my syntax for the password and password confirmation in the code? The errors are shown first. Thanks

There are two errors that show up in the terminal and in my editor's compiler -

/odot$ bin/rspec spec/models/user_spec.rb /var/lib/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in load': /home/bob/Source/projects/odot/spec/models/user_spec.rb:10: syntax error, unexpected tIDENTIFIER, expecting '}' (SyntaxError) password: "treehouse1234" ^ /home/bob/Source/projects/odot/spec/models/user_spec.rb:13: syntax error, unexpected '}', expecting keyword_end from /var/lib/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:inblock in load_spec_files' from /var/lib/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:in each' from /var/lib/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/configuration.rb:1065:inload_spec_files' from /var/lib/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/command_line.rb:18:in run' from /var/lib/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:103:inrun' from /var/lib/gems/1.9.1/gems/rspec-core-2.99.2/lib/rspec/core/runner.rb:17:in `block in autorun

The code for user_spec.rb is:

require 'spec_helper'

describe User do

let(:valid_attributes) { 
    {
        first_name: "Jason",
        last_name: "Seifer",
        email: "jason@teamtreehouse.com"
        password: "treehouse1234"
        password_confirmation "treehouse1234"
    }
}
context "validations" do
    let(:user) { User.new(valid_attributes) }

    before do
        User.create(valid_attributes)
    end

    it "requires an email" do
        expect(user).to validate_presence_of(:email)
    end

    it "requires a unique email" do
        expect(user).to validate_uniqueness_of(:email)
    end

    it "requires a unique email (case insensitive)" do
        user.email = "JASON@TEAMTREEHOUSE.COM"
        expect(user).to validate_uniqueness_of(:email)
    end

end

describe "#downcase_email" do
    it "makes the email attribute lower case" do
        user = User.new(valid_attributes.merge(email: "JASON@TEAMTREEHOUSE.COM"))
        expect{ user.downcase_email }.to change{ user.email }.
            from("JASON@TEAMTREEHOUSE.COM").
            to("jason@teamtreehouse.com")
    end

    it "downcases an email before saving" do
        user = User.new(valid_attributes)
        user.email = "MIKE@TEAMTREEHOUSE.COM"
        expect(user.save).to be_true
        expect(user.email).to eq("mike@teamtreehouse.com")
    end
end

end

Thank you for your help! Bob

Javier Perez
Javier Perez
3,337 Points

in your let(:valid_attributes) you are missing commas after email and password

1 Answer

Javier,

That worked! Thank you for your help. I spent a lot of time overlooking that little bit of code yesterday. It is funny how something like that can put a dent in your whole day.

Thanks again!

Bob