From cc94b08e588c7cabdecd9aabff6be0d6200f9265 Mon Sep 17 00:00:00 2001 From: nilsding Date: Sun, 7 Dec 2014 11:33:26 +0100 Subject: [PATCH] more specs! --- spec/models/user_spec.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 2ce876dd..af300d69 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -1,4 +1,28 @@ require 'rails_helper' RSpec.describe User, :type => :model do + before :each do + @user = User.new( + screen_name: 'FunnyMeme2004', + password: 'y_u_no_secure_password?', + email: 'nice.meme@nsa.gov' + ) + end + + subject { @user } + + it { should respond_to(:email) } + + it '#email returns a string' do + expect(@user.email).to match 'nice.meme@nsa.gov' + end + + it '#motivation_header has a default value' do + expect(@user.motivation_header).to match '' + end + + it 'does not save an invalid screen name' do + @user.screen_name = '$Funny-Meme-%&2004' + expect{@user.save!}.to raise_error(ActiveRecord::RecordInvalid) + end end