Hi for the life of me I cannot locate a syntax error in my rspec file. I've gone over it dozens of times and just can't find it. I could use an extra set of eyes to help me on this. Heres my spec file:
require 'rails_helper'
RSpec.describe User, type: :model do
let(:user) { User.create!(name: "Bloccit User", email: "[email protected]",
password: "password") }
#name tests
it { is_expected.to validate_presence_of(:name) }
it { is_expected.to validate_length_of(:name).is_at_least(1) }
#email tests
it { is_expected.to validate_presence_of(:email) }
it { is_expected.to validate_uniqueness_of(:email) }
it { is_expected.to validate_length_of(:email).is_at_least(3) }
it { is_expected.to allow_value("[email protected]").for(:email) }
#password tests
it { is_expected.to validate_presence_of(:password) }
it { is_expected.to have_secure_password }
it { is_expected.to validate_length_of(:password).is_at_least(6)}
describe "attributes" do
it "should have a name and an email address" do
expect(user).to have_attributes(name: "Bloccit User", email:
"[email protected]")
end
it "should capitalize the user name" do
user.name = 'bloc user'
user.save
expect(user.name).to eq "Bloc User"
end
end
describe "invalid user" do
let(:user_with_invalid_name) {User.new(name: "",
email:"[email protected]")}
let(:user_with_invalid_email) {User.new(name: "Bloccit User", email:"")}
it "should have an invalid user due to blank name" do
expect(user_with_invalid_name).to_not be_valid
end
it "should be an invalid user due to blank email" do
expect(user_with_invalid_email).to_not be_valid
end
end
end
I get the following error every time I run the code.
SyntaxError:
/mnt/c/Users/bjm84/Bloccit/app/models/user.rb:26: syntax error, unexpected
end-of-input, expecting keyword_end
# ./spec/models/user_spec.rb:3:in `<top (required)>'
If someone could help me pinpoint this I would appreciate it. This has miffed me pretty good. Thanks.
The error is telling you that the syntax error is in line 26 of your User model file.
It's not in the spec file.