active_mocker 1.2.pre.10 → 1.2.pre.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,42 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe RelationshipsController do
4
-
5
- let(:user) { FactoryGirl.create(:user) }
6
- let(:other_user) { FactoryGirl.create(:user) }
7
-
8
- before { sign_in user, no_capybara: true }
9
-
10
- describe "creating a relationship with Ajax" do
11
-
12
- it "should increment the Relationship count" do
13
- expect do
14
- xhr :post, :create, relationship: { followed_id: other_user.id }
15
- end.to change(Relationship, :count).by(1)
16
- end
17
-
18
- it "should respond with success" do
19
- xhr :post, :create, relationship: { followed_id: other_user.id }
20
- expect(response).to be_success
21
- end
22
- end
23
-
24
- describe "destroying a relationship with Ajax" do
25
-
26
- before { user.follow!(other_user) }
27
- let(:relationship) do
28
- user.relationships.find_by(followed_id: other_user.id)
29
- end
30
-
31
- it "should decrement the Relationship count" do
32
- expect do
33
- xhr :delete, :destroy, id: relationship.id
34
- end.to change(Relationship, :count).by(-1)
35
- end
36
-
37
- it "should respond with success" do
38
- xhr :delete, :destroy, id: relationship.id
39
- expect(response).to be_success
40
- end
41
- end
42
- end
@@ -1,18 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ApplicationHelper do
4
-
5
- describe "full_title" do
6
- it "should include the page title" do
7
- expect(full_title("foo")).to match(/foo/)
8
- end
9
-
10
- it "should include the base title" do
11
- expect(full_title("foo")).to match(/^Ruby on Rails Tutorial Sample App/)
12
- end
13
-
14
- it "should not include a bar for the home page" do
15
- expect(full_title("")).not_to match(/\|/)
16
- end
17
- end
18
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Micropost do
4
-
5
- let(:user) { FactoryGirl.create(:user) }
6
- before do
7
- # This code is not idiomatically correct.
8
- @micropost = Micropost.new(content: "Lorem ipsum", user_id: user.id)
9
- end
10
-
11
- subject { @micropost }
12
-
13
- it { should respond_to(:content) }
14
- it { should respond_to(:user_id) }
15
-
16
- describe "when user_id is not present" do
17
- before { @micropost.user_id = nil }
18
- it { should_not be_valid }
19
- end
20
-
21
- describe "with blank content" do
22
- before { @micropost.content = " " }
23
- it { should_not be_valid }
24
- end
25
-
26
- describe "with content that is too long" do
27
- before { @micropost.content = "a" * 141 }
28
- it { should_not be_valid }
29
- end
30
- end
@@ -1,29 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Relationship do
4
-
5
- let(:follower) { FactoryGirl.create(:user) }
6
- let(:followed) { FactoryGirl.create(:user) }
7
- let(:relationship) { follower.relationships.build(followed_id: followed.id) }
8
-
9
- subject { relationship }
10
-
11
- it { should be_valid }
12
-
13
- describe "follower methods" do
14
- it { should respond_to(:follower) }
15
- it { should respond_to(:followed) }
16
- its(:follower) { should eq follower }
17
- its(:followed) { should eq followed }
18
- end
19
-
20
- describe "when followed id is not present" do
21
- before { relationship.followed_id = nil }
22
- it { should_not be_valid }
23
- end
24
-
25
- describe "when follower id is not present" do
26
- before { relationship.follower_id = nil }
27
- it { should_not be_valid }
28
- end
29
- end
@@ -1,194 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe User do
4
-
5
- before do
6
- @user = User.new(name: "Example User", email: "user@example.com",
7
- password: "foobar", password_confirmation: "foobar")
8
- end
9
-
10
- subject { @user }
11
-
12
- it { should respond_to(:name) }
13
- it { should respond_to(:email) }
14
- it { should respond_to(:password_digest) }
15
- it { should respond_to(:password) }
16
- it { should respond_to(:password_confirmation) }
17
- it { should respond_to(:remember_token) }
18
- it { should respond_to(:authenticate) }
19
- it { should respond_to(:admin) }
20
- it { should respond_to(:microposts) }
21
- it { should respond_to(:feed) }
22
- it { should respond_to(:relationships) }
23
- it { should respond_to(:followed_users) }
24
- it { should respond_to(:reverse_relationships) }
25
- it { should respond_to(:followers) }
26
- it { should respond_to(:following?) }
27
- it { should respond_to(:follow!) }
28
- it { should respond_to(:unfollow!) }
29
-
30
- it { should be_valid }
31
- it { should_not be_admin }
32
-
33
- describe "with admin attribute set to 'true'" do
34
- before do
35
- @user.save!
36
- @user.toggle!(:admin)
37
- end
38
-
39
- it { should be_admin }
40
- end
41
-
42
- describe "when name is not present" do
43
- before { @user.name = " " }
44
- it { should_not be_valid }
45
- end
46
-
47
- describe "when email is not present" do
48
- before { @user.email = " " }
49
- it { should_not be_valid }
50
- end
51
-
52
- describe "when name is too long" do
53
- before { @user.name = "a" * 51 }
54
- it { should_not be_valid }
55
- end
56
-
57
- describe "when email format is invalid" do
58
- it "should be invalid" do
59
- addresses = %w[user@foo,com user_at_foo.org example.user@foo.
60
- foo@bar_baz.com foo@bar+baz.com foo@bar..com]
61
- addresses.each do |invalid_address|
62
- @user.email = invalid_address
63
- expect(@user).not_to be_valid
64
- end
65
- end
66
- end
67
-
68
- describe "when email format is valid" do
69
- it "should be valid" do
70
- addresses = %w[user@foo.COM A_US-ER@f.b.org frst.lst@foo.jp a+b@baz.cn]
71
- addresses.each do |valid_address|
72
- @user.email = valid_address
73
- expect(@user).to be_valid
74
- end
75
- end
76
- end
77
-
78
- describe "when email address is already taken" do
79
- before do
80
- user_with_same_email = @user.dup
81
- user_with_same_email.email = @user.email.upcase
82
- user_with_same_email.save
83
- end
84
-
85
- it { should_not be_valid }
86
- end
87
-
88
- describe "when password is not present" do
89
- before do
90
- @user = User.new(name: "Example User", email: "user@example.com",
91
- password: " ", password_confirmation: " ")
92
- end
93
- it { should_not be_valid }
94
- end
95
-
96
- describe "when password doesn't match confirmation" do
97
- before { @user.password_confirmation = "mismatch" }
98
- it { should_not be_valid }
99
- end
100
-
101
- describe "with a password that's too short" do
102
- before { @user.password = @user.password_confirmation = "a" * 5 }
103
- it { should be_invalid }
104
- end
105
-
106
- describe "return value of authenticate method" do
107
- before { @user.save }
108
- let(:found_user) { User.find_by(email: @user.email) }
109
-
110
- describe "with valid password" do
111
- it { should eq found_user.authenticate(@user.password) }
112
- end
113
-
114
- describe "with invalid password" do
115
- let(:user_for_invalid_password) { found_user.authenticate("invalid") }
116
-
117
- it { should_not eq user_for_invalid_password }
118
- specify { expect(user_for_invalid_password).to be_false }
119
- end
120
- end
121
-
122
- describe "remember token" do
123
- before { @user.save }
124
- its(:remember_token) { should_not be_blank }
125
- end
126
-
127
- describe "micropost associations" do
128
-
129
- before { @user.save }
130
- let!(:older_micropost) do
131
- FactoryGirl.create(:micropost, user: @user, created_at: 1.day.ago)
132
- end
133
- let!(:newer_micropost) do
134
- FactoryGirl.create(:micropost, user: @user, created_at: 1.hour.ago)
135
- end
136
-
137
- it "should have the right microposts in the right order" do
138
- expect(@user.microposts.to_a).to eq [newer_micropost, older_micropost]
139
- end
140
-
141
- it "should destroy associated microposts" do
142
- microposts = @user.microposts.to_a
143
- @user.destroy
144
- expect(microposts).not_to be_empty
145
- microposts.each do |micropost|
146
- expect(Micropost.where(id: micropost.id)).to be_empty
147
- end
148
- end
149
-
150
- describe "status" do
151
- let(:unfollowed_post) do
152
- FactoryGirl.create(:micropost, user: FactoryGirl.create(:user))
153
- end
154
- let(:followed_user) { FactoryGirl.create(:user) }
155
-
156
- before do
157
- @user.follow!(followed_user)
158
- 3.times { followed_user.microposts.create!(content: "Lorem ipsum") }
159
- end
160
-
161
- its(:feed) { should include(newer_micropost) }
162
- its(:feed) { should include(older_micropost) }
163
- its(:feed) { should_not include(unfollowed_post) }
164
- its(:feed) do
165
- followed_user.microposts.each do |micropost|
166
- should include(micropost)
167
- end
168
- end
169
- end
170
- end
171
-
172
- describe "following" do
173
- let(:other_user) { FactoryGirl.create(:user) }
174
- before do
175
- @user.save
176
- @user.follow!(other_user)
177
- end
178
-
179
- it { should be_following(other_user) }
180
- its(:followed_users) { should include(other_user) }
181
-
182
- describe "followed user" do
183
- subject { other_user }
184
- its(:followers) { should include(@user) }
185
- end
186
-
187
- describe "and unfollowing" do
188
- before { @user.unfollow!(other_user) }
189
-
190
- it { should_not be_following(other_user) }
191
- its(:followed_users) { should_not include(other_user) }
192
- end
193
- end
194
- end
@@ -1,21 +0,0 @@
1
- include ApplicationHelper
2
-
3
- def sign_in(user, options={})
4
- if options[:no_capybara]
5
- # Sign in when not using Capybara as well.
6
- remember_token = User.new_remember_token
7
- cookies[:remember_token] = remember_token
8
- user.update_attribute(:remember_token, User.digest(remember_token))
9
- else
10
- visit signin_path
11
- fill_in "Email", with: user.email
12
- fill_in "Password", with: user.password
13
- click_button "Sign in"
14
- end
15
- end
16
-
17
- RSpec::Matchers.define :have_error_message do |message|
18
- match do |page|
19
- expect(page).to have_selector('div.alert.alert-error', text: message)
20
- end
21
- end