Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added user name and email presence validation and model rspec test

  • Loading branch information...
commit 53c974c058b94e4df527d4e1410656bf59ab91b1 1 parent 389e2ed
@safalmj authored
View
34 Gemfile.lock
@@ -28,7 +28,7 @@ GEM
activesupport (3.2.6)
i18n (~> 0.6)
multi_json (~> 1.0)
- addressable (2.2.8)
+ addressable (2.3.2)
annotate (2.5.0)
rake
arel (3.0.2)
@@ -41,8 +41,8 @@ GEM
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 0.1.4)
- childprocess (0.3.3)
- ffi (~> 1.0.6)
+ childprocess (0.3.5)
+ ffi (~> 1.0, >= 1.0.6)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
@@ -54,7 +54,7 @@ GEM
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
- ffi (1.0.11)
+ ffi (1.1.5)
guard (1.3.2)
listen (>= 0.4.2)
thor (>= 0.14.6)
@@ -64,19 +64,16 @@ GEM
guard (>= 0.8.4)
spork (>= 0.8.4)
hike (1.2.1)
- i18n (0.6.0)
+ i18n (0.6.1)
journey (1.0.4)
- jquery-rails (2.0.2)
- railties (>= 3.2.0, < 5.0)
+ jquery-rails (2.1.1)
+ railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
- json (1.7.4)
+ json (1.7.5)
libnotify (0.5.9)
- libwebsocket (0.1.4)
+ libwebsocket (0.1.5)
addressable
- listen (0.4.7)
- rb-fchange (~> 0.0.5)
- rb-fsevent (~> 0.9.1)
- rb-inotify (~> 0.8.8)
+ listen (0.5.0)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
@@ -109,9 +106,6 @@ GEM
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (0.9.2.2)
- rb-fchange (0.0.5)
- ffi
- rb-fsevent (0.9.1)
rb-inotify (0.8.8)
ffi (>= 0.5.0)
rdoc (3.12)
@@ -130,7 +124,7 @@ GEM
railties (>= 3.0)
rspec (~> 2.10.0)
rubyzip (0.9.9)
- sass (3.1.20)
+ sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
@@ -146,15 +140,15 @@ GEM
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.5)
- thor (0.15.4)
+ thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.33)
- uglifier (1.2.7)
+ uglifier (1.3.0)
execjs (>= 0.3.0)
- multi_json (~> 1.3)
+ multi_json (~> 1.0, >= 1.0.2)
xpath (0.1.4)
nokogiri (~> 1.3)
View
3  app/models/user.rb
@@ -11,4 +11,7 @@
class User < ActiveRecord::Base
attr_accessible :email, :name
+
+ validates :name, :presence => true
+ validates :email, :presence => true
end
View
1  db/schema.rb
@@ -1,3 +1,4 @@
+# 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
18 spec/models/user_spec.rb
@@ -12,5 +12,21 @@
require 'spec_helper'
describe User do
- pending "add some examples to (or delete) #{__FILE__}"
+ before { @user = User.new(:name => "Safal", :email => "safal@gmail.com") }
+
+ subject { @user }
+ it { should respond_to(:name)}
+ it { should respond_to(:email)}
+
+ it { should be_valid}
+
+ describe "when user 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 }
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.