Reputation: 85
why this test does not pass? i use devise for authentication.
user.rb
validates :username, presence: true, :length => { :minimum => 2 }
user_spec.rb
require 'spec_helper'
describe User do
before do
@user = User.new(username: "Example User", email: "[email protected]",
password: "foobar", password_confirmation: "foobar")
end
describe "name" do
before { @user.username="test" }
it { should be_valid }
end
end
Upvotes: 0
Views: 294
Reputation: 3937
You have to specify a subject to call 'it' in RSpec. For example, you can add
subject { @user }
after your 'before do' block.
In the future, be sure to copy the error message as well so that everyone knows where to look!
Upvotes: 1