0
私の人生では、私のrspecファイルに構文エラーが見つかりません。私は数十回それを見て、それを見つけることができませんでした。私はこれを手伝うために余分な目を使うことができました。構文エラーruby rspec testing
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
私はコードを実行するたびに次のエラーが発生します。
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)>'
誰かが私にこの点を教えていただければ幸いです。これは私をかなり苦しめました。ありがとう。