public
Description: The open source social networking platform in Ruby on Rails from the author of RailsSpace
Homepage: http://insoshi.com
Clone URL: git://github.com/insoshi/insoshi.git
Search Repo:
Mocked out what I could
Michael Hartl (author)
Tue Feb 19 13:03:57 -0800 2008
commit  2c7fb61c036291840807941c9607666e7379d6d7
tree    3d53fe040fca76debf9d505930a1dfa1ed15815a
parent  e37ccea6f6fb123eb8baac464d375465b638f9d9
...
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
 
 
 
 
 
22
23
24
25
26
27
28
 
 
29
30
31
32
33
34
35
 
 
36
37
38
39
40
41
42
 
 
43
44
45
46
47
 
 
 
48
49
50
51
52
 
 
53
54
55
56
 
 
 
 
 
57
58
59
60
61
62
 
 
 
63
64
65
66
67
68
69
 
 
 
 
70
71
72
73
74
 
75
76
77
78
 
 
 
79
80
81
82
83
84
85
86
 
 
 
 
87
88
89
90
91
 
92
93
94
95
 
 
 
96
97
98
99
100
101
 
 
 
 
102
103
104
...
5
6
7
 
8
 
 
 
 
 
 
 
 
 
 
 
 
9
10
11
12
13
14
15
16
17
 
 
 
 
18
19
20
21
22
 
 
 
 
23
24
25
26
27
 
 
 
 
28
29
30
31
32
 
 
33
34
35
36
37
38
 
 
39
40
41
42
43
 
44
45
46
47
48
49
50
51
 
 
 
52
53
54
55
56
57
 
 
 
 
58
59
60
61
62
63
64
65
 
66
67
 
 
 
68
69
70
71
72
73
74
 
 
 
 
75
76
77
78
79
80
81
82
 
83
84
 
 
 
85
86
87
88
89
90
91
 
 
92
93
94
95
96
97
98
0
@@ -5,100 +5,94 @@ require File.dirname(__FILE__) + '/../spec_helper'
0
 include AuthenticatedTestHelper
0
 
0
 describe Person do
0
- fixtures :people
0
 
0
- describe 'being created' do
0
- before do
0
- @person = nil
0
- @creating_person = lambda do
0
- @person = create_person
0
- violated "#{@person.errors.full_messages.to_sentence}" if @person.new_record?
0
- end
0
- end
0
-
0
- it 'increments User#count' do
0
- @creating_person.should change(Person, :count).by(1)
0
- end
0
+ before(:each) do
0
+ @person = people(:quentin)
0
+ end
0
+
0
+ it "should be valid" do
0
+ create_person.should be_valid
0
   end
0
   
0
   it 'requires password' do
0
- lambda do
0
- u = create_person(:password => nil)
0
- u.errors.on(:password).should_not be_nil
0
- end.should_not change(Person, :count)
0
+ u = create_person(:password => nil)
0
+ u.errors.on(:password).should_not be_nil
0
   end
0
 
0
   it 'requires password confirmation' do
0
- lambda do
0
- u = create_person(:password_confirmation => nil)
0
- u.errors.on(:password_confirmation).should_not be_nil
0
- end.should_not change(Person, :count)
0
+ u = create_person(:password_confirmation => nil)
0
+ u.errors.on(:password_confirmation).should_not be_nil
0
   end
0
 
0
   it 'requires email' do
0
- lambda do
0
- u = create_person(:email => nil)
0
- u.errors.on(:email).should_not be_nil
0
- end.should_not change(Person, :count)
0
+ u = create_person(:email => nil)
0
+ u.errors.on(:email).should_not be_nil
0
   end
0
 
0
   it 'resets password' do
0
- people(:quentin).update_attributes(:password => 'new password', :password_confirmation => 'new password')
0
- Person.authenticate('quentin@example.com', 'new password').should == people(:quentin)
0
+ @person.update_attributes(:password => 'newp',
0
+ :password_confirmation => 'newp')
0
+ Person.authenticate('quentin@example.com', 'newp').should == @person
0
   end
0
 
0
   it 'does not rehash password' do
0
- people(:quentin).update_attributes(:email => 'quentin2@example.com')
0
- Person.authenticate('quentin2@example.com', 'test').should == people(:quentin)
0
+ @person.update_attributes(:email => 'quentin2@example.com')
0
+ Person.authenticate('quentin2@example.com', 'test').should == @person
0
   end
0
 
0
   it 'authenticates person' do
0
- Person.authenticate('queNTin@eXample.com', 'test').should == people(:quentin)
0
+ Person.authenticate('quentin@example.com', 'test').should == @person
0
+ end
0
+
0
+ it "should authenticate case-insensitively" do
0
+ Person.authenticate('queNTin@eXample.com', 'test').should == @person
0
   end
0
 
0
   it 'sets remember token' do
0
- people(:quentin).remember_me
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should_not be_nil
0
+ @person.remember_me
0
+ @person.remember_token.should_not be_nil
0
+ @person.remember_token_expires_at.should_not be_nil
0
   end
0
 
0
   it 'unsets remember token' do
0
- people(:quentin).remember_me
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).forget_me
0
- people(:quentin).remember_token.should be_nil
0
+ @person.remember_me
0
+ @person.remember_token.should_not be_nil
0
+ @person.forget_me
0
+ @person.remember_token.should be_nil
0
   end
0
 
0
   it 'remembers me for one week' do
0
     before = 1.week.from_now.utc
0
- people(:quentin).remember_me_for 1.week
0
+ @person.remember_me_for 1.week
0
     after = 1.week.from_now.utc
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should_not be_nil
0
- people(:quentin).remember_token_expires_at.between?(before, after).should be_true
0
+ @person.remember_token.should_not be_nil
0
+ @person.remember_token_expires_at.should_not be_nil
0
+ @person.remember_token_expires_at.between?(before, after).should be_true
0
   end
0
 
0
   it 'remembers me until one week' do
0
     time = 1.week.from_now.utc
0
- people(:quentin).remember_me_until time
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should == time
0
+ @person.remember_me_until time
0
+ @person.remember_token.should_not be_nil
0
+ @person.remember_token_expires_at.should_not be_nil
0
+ @person.remember_token_expires_at.should == time
0
   end
0
 
0
   it 'remembers me default two weeks' do
0
     before = 2.weeks.from_now.utc
0
- people(:quentin).remember_me
0
+ @person.remember_me
0
     after = 2.weeks.from_now.utc
0
- people(:quentin).remember_token.should_not be_nil
0
- people(:quentin).remember_token_expires_at.should_not be_nil
0
- people(:quentin).remember_token_expires_at.between?(before, after).should be_true
0
+ @person.remember_token.should_not be_nil
0
+ @person.remember_token_expires_at.should_not be_nil
0
+ @person.remember_token_expires_at.between?(before, after).should be_true
0
   end
0
 
0
 protected
0
   def create_person(options = {})
0
- record = Person.new({ :email => 'quire@example.com', :password => 'quire', :password_confirmation => 'quire' }.merge(options))
0
- record.save
0
+ record = Person.new({ :email => 'quire@example.com',
0
+ :password => 'quire',
0
+ :password_confirmation => 'quire' }.merge(options))
0
+ record.valid?
0
     record
0
   end
0
 end
...
23
24
25
26
 
27
28
29
...
23
24
25
 
26
27
28
29
0
@@ -23,7 +23,7 @@ Spec::Runner.configure do |config|
0
   # do so right here. Just uncomment the next line and replace the fixture
0
   # names with your fixtures.
0
   #
0
- # config.global_fixtures = :table_a, :table_b
0
+ config.global_fixtures = :all
0
   #
0
   # If you declare global fixtures, be aware that they will be declared
0
   # for all of your examples, even those that don't use them.

Comments

    No one has commented yet.