Permalink
Browse files

rspec for User model validation

  • Loading branch information...
safalmj committed Sep 27, 2012
1 parent 317f1e5 commit 97abf17f38926e5136518d2650d275bfda74235f
Showing with 21 additions and 16 deletions.
  1. +0 −1 db/schema.rb
  2. +21 −15 spec/models/user_spec.rb
View
@@ -1,4 +1,3 @@
-# encoding: UTF-8
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
View
@@ -12,26 +12,32 @@
require 'spec_helper'
describe User do
- before { @user = User.new(:name => "Safal", :email => "safal@gmail.com") }
+
+ before { @user = User.new(:name => 'Safal M Joshi', :email => "safalmj@gmail.com") }
- subject { @user }
- it { should respond_to(:name)}
- it { should respond_to(:email)}
+ subject { @user}
- it { should be_valid}
+ it { should respond_to(:name) }
+ it { should respond_to(:email) }
- describe "when user is not present" do
- before { @user.name = " "}
- it { should_not be_valid }
- end
+ it {should be_valid}
+
+ describe "When user name is not present" do
+ before { @user.name = " "}
+ it { should_not be_valid }
+ end
- describe "when email is not present" do
- before { @user.email = " "}
- it { should_not be_valid }
+ describe "When user email is not present" do
+ before { @user.email = " " }
+ it { should_not be_valid }
end
- describe "when name is too long" do
- before { @user.name = "a"*51}
- it { should_not be_valid }
+ describe "When the name is too long" do
+ before { @user.name = "a" * 51}
+ it { should_not be_valid }
end
+
end
+
+
+

0 comments on commit 97abf17

Please sign in to comment.