active_mocker 1.2.pre → 1.2.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_mocker/version.rb +1 -1
  3. data/sample_app_rails_4/.idea/.generators +8 -0
  4. data/sample_app_rails_4/.idea/.name +1 -0
  5. data/sample_app_rails_4/.idea/.rakeTasks +7 -0
  6. data/sample_app_rails_4/.idea/dataSources.ids +141 -0
  7. data/sample_app_rails_4/.idea/dataSources.xml +36 -0
  8. data/sample_app_rails_4/.idea/dictionaries/zeisler.xml +3 -0
  9. data/sample_app_rails_4/.idea/encodings.xml +5 -0
  10. data/sample_app_rails_4/.idea/inspectionProfiles/Project_Default.xml +20 -0
  11. data/sample_app_rails_4/.idea/inspectionProfiles/profiles_settings.xml +7 -0
  12. data/sample_app_rails_4/.idea/misc.xml +5 -0
  13. data/sample_app_rails_4/.idea/modules.xml +10 -0
  14. data/sample_app_rails_4/.idea/runConfigurations/Development__sample_app_rails_4.xml +28 -0
  15. data/sample_app_rails_4/.idea/runConfigurations/Production__sample_app_rails_4.xml +28 -0
  16. data/sample_app_rails_4/.idea/runConfigurations/spec__sample_app_rails_4.xml +26 -0
  17. data/sample_app_rails_4/.idea/runConfigurations/test__sample_app_rails_4.xml +28 -0
  18. data/sample_app_rails_4/.idea/sample_app_rails_4.iml +262 -0
  19. data/sample_app_rails_4/.idea/scopes/scope_settings.xml +5 -0
  20. data/sample_app_rails_4/.idea/vcs.xml +7 -0
  21. data/sample_app_rails_4/.idea/workspace.xml +969 -0
  22. data/sample_app_rails_4/.rspec +1 -0
  23. data/sample_app_rails_4/.secret +1 -0
  24. data/sample_app_rails_4/Gemfile +53 -0
  25. data/sample_app_rails_4/Guardfile +53 -0
  26. data/sample_app_rails_4/LICENSE +21 -0
  27. data/sample_app_rails_4/README.md +25 -0
  28. data/sample_app_rails_4/README.nitrous.md +20 -0
  29. data/sample_app_rails_4/Rakefile +6 -0
  30. data/sample_app_rails_4/app/assets/images/rails.png +0 -0
  31. data/sample_app_rails_4/app/assets/javascripts/application.js +17 -0
  32. data/sample_app_rails_4/app/assets/javascripts/sessions.js.coffee +3 -0
  33. data/sample_app_rails_4/app/assets/javascripts/static_pages.js.coffee +3 -0
  34. data/sample_app_rails_4/app/assets/javascripts/users.js.coffee +3 -0
  35. data/sample_app_rails_4/app/assets/stylesheets/application.css +13 -0
  36. data/sample_app_rails_4/app/assets/stylesheets/custom.css.scss +246 -0
  37. data/sample_app_rails_4/app/assets/stylesheets/sessions.css.scss +3 -0
  38. data/sample_app_rails_4/app/assets/stylesheets/static_pages.css.scss +3 -0
  39. data/sample_app_rails_4/app/assets/stylesheets/users.css.scss +3 -0
  40. data/sample_app_rails_4/app/controllers/application_controller.rb +6 -0
  41. data/sample_app_rails_4/app/controllers/concerns/.keep +0 -0
  42. data/sample_app_rails_4/app/controllers/microposts_controller.rb +31 -0
  43. data/sample_app_rails_4/app/controllers/relationships_controller.rb +21 -0
  44. data/sample_app_rails_4/app/controllers/sessions_controller.rb +21 -0
  45. data/sample_app_rails_4/app/controllers/static_pages_controller.rb +18 -0
  46. data/sample_app_rails_4/app/controllers/users_controller.rb +80 -0
  47. data/sample_app_rails_4/app/helpers/application_helper.rb +12 -0
  48. data/sample_app_rails_4/app/helpers/sessions_helper.rb +49 -0
  49. data/sample_app_rails_4/app/helpers/static_pages_helper.rb +2 -0
  50. data/sample_app_rails_4/app/helpers/users_helper.rb +10 -0
  51. data/sample_app_rails_4/app/mailers/.keep +0 -0
  52. data/sample_app_rails_4/app/models/.keep +0 -0
  53. data/sample_app_rails_4/app/models/concerns/.keep +0 -0
  54. data/sample_app_rails_4/app/models/micropost.rb +14 -0
  55. data/sample_app_rails_4/app/models/relationship.rb +6 -0
  56. data/sample_app_rails_4/app/models/user.rb +47 -0
  57. data/sample_app_rails_4/app/views/layouts/_footer.html.erb +13 -0
  58. data/sample_app_rails_4/app/views/layouts/_header.html.erb +31 -0
  59. data/sample_app_rails_4/app/views/layouts/_shim.html.erb +3 -0
  60. data/sample_app_rails_4/app/views/layouts/application.html.erb +22 -0
  61. data/sample_app_rails_4/app/views/microposts/_micropost.html.erb +11 -0
  62. data/sample_app_rails_4/app/views/relationships/create.js.erb +2 -0
  63. data/sample_app_rails_4/app/views/relationships/destroy.js.erb +2 -0
  64. data/sample_app_rails_4/app/views/sessions/new.html.erb +19 -0
  65. data/sample_app_rails_4/app/views/shared/_error_messages.html.erb +12 -0
  66. data/sample_app_rails_4/app/views/shared/_feed.html.erb +6 -0
  67. data/sample_app_rails_4/app/views/shared/_feed_item.html.erb +15 -0
  68. data/sample_app_rails_4/app/views/shared/_micropost_form.html.erb +7 -0
  69. data/sample_app_rails_4/app/views/shared/_stats.html.erb +15 -0
  70. data/sample_app_rails_4/app/views/shared/_user_info.html.erb +12 -0
  71. data/sample_app_rails_4/app/views/static_pages/about.html.erb +8 -0
  72. data/sample_app_rails_4/app/views/static_pages/contact.html.erb +6 -0
  73. data/sample_app_rails_4/app/views/static_pages/help.html.erb +8 -0
  74. data/sample_app_rails_4/app/views/static_pages/home.html.erb +34 -0
  75. data/sample_app_rails_4/app/views/static_pages/show.html.erb +0 -0
  76. data/sample_app_rails_4/app/views/users/_follow.html.erb +5 -0
  77. data/sample_app_rails_4/app/views/users/_follow_form.html.erb +9 -0
  78. data/sample_app_rails_4/app/views/users/_unfollow.html.erb +5 -0
  79. data/sample_app_rails_4/app/views/users/_user.html.erb +8 -0
  80. data/sample_app_rails_4/app/views/users/edit.html.erb +27 -0
  81. data/sample_app_rails_4/app/views/users/index.html.erb +10 -0
  82. data/sample_app_rails_4/app/views/users/new.html.erb +24 -0
  83. data/sample_app_rails_4/app/views/users/show.html.erb +24 -0
  84. data/sample_app_rails_4/app/views/users/show_follow.html.erb +30 -0
  85. data/sample_app_rails_4/bin/bundle +3 -0
  86. data/sample_app_rails_4/bin/rails +4 -0
  87. data/sample_app_rails_4/bin/rake +4 -0
  88. data/sample_app_rails_4/config.ru +4 -0
  89. data/sample_app_rails_4/config/application.rb +31 -0
  90. data/sample_app_rails_4/config/boot.rb +4 -0
  91. data/sample_app_rails_4/config/cucumber.yml +8 -0
  92. data/sample_app_rails_4/config/database.yml +28 -0
  93. data/sample_app_rails_4/config/environment.rb +5 -0
  94. data/sample_app_rails_4/config/environments/development.rb +27 -0
  95. data/sample_app_rails_4/config/environments/production.rb +79 -0
  96. data/sample_app_rails_4/config/environments/test.rb +39 -0
  97. data/sample_app_rails_4/config/initializers/active_mocker.rb +10 -0
  98. data/sample_app_rails_4/config/initializers/backtrace_silencers.rb +7 -0
  99. data/sample_app_rails_4/config/initializers/filter_parameter_logging.rb +4 -0
  100. data/sample_app_rails_4/config/initializers/inflections.rb +16 -0
  101. data/sample_app_rails_4/config/initializers/mime_types.rb +5 -0
  102. data/sample_app_rails_4/config/initializers/secret_token.rb +22 -0
  103. data/sample_app_rails_4/config/initializers/session_store.rb +3 -0
  104. data/sample_app_rails_4/config/initializers/wrap_parameters.rb +14 -0
  105. data/sample_app_rails_4/config/locales/en.yml +23 -0
  106. data/sample_app_rails_4/config/routes.rb +17 -0
  107. data/sample_app_rails_4/db/development.sqlite3 +0 -0
  108. data/sample_app_rails_4/db/migrate/20130311191400_create_users.rb +10 -0
  109. data/sample_app_rails_4/db/migrate/20130311194153_add_index_to_users_email.rb +5 -0
  110. data/sample_app_rails_4/db/migrate/20130311201841_add_password_digest_to_users.rb +5 -0
  111. data/sample_app_rails_4/db/migrate/20130314184954_add_remember_token_to_users.rb +6 -0
  112. data/sample_app_rails_4/db/migrate/20130315015932_add_admin_to_users.rb +5 -0
  113. data/sample_app_rails_4/db/migrate/20130315175534_create_microposts.rb +11 -0
  114. data/sample_app_rails_4/db/migrate/20130315230445_create_relationships.rb +13 -0
  115. data/sample_app_rails_4/db/schema.rb +49 -0
  116. data/sample_app_rails_4/db/seeds.rb +7 -0
  117. data/sample_app_rails_4/db/test.sqlite3 +0 -0
  118. data/sample_app_rails_4/features/signing_in.feature +13 -0
  119. data/sample_app_rails_4/features/step_definitions/authentication_steps.rb +30 -0
  120. data/sample_app_rails_4/features/support/env.rb +59 -0
  121. data/sample_app_rails_4/lib/assets/.keep +0 -0
  122. data/sample_app_rails_4/lib/tasks/.keep +0 -0
  123. data/sample_app_rails_4/lib/tasks/cucumber.rake +65 -0
  124. data/sample_app_rails_4/lib/tasks/mocks.rake +10 -0
  125. data/sample_app_rails_4/lib/tasks/sample_data.rake +42 -0
  126. data/sample_app_rails_4/log/.keep +0 -0
  127. data/sample_app_rails_4/log/development.log +603 -0
  128. data/sample_app_rails_4/log/test.log +6727 -0
  129. data/sample_app_rails_4/public/404.html +27 -0
  130. data/sample_app_rails_4/public/422.html +26 -0
  131. data/sample_app_rails_4/public/500.html +26 -0
  132. data/sample_app_rails_4/public/assets/application-4962059d8f80f9bb096692bacc29c4e8.css +5091 -0
  133. data/sample_app_rails_4/public/assets/application-4962059d8f80f9bb096692bacc29c4e8.css.gz +0 -0
  134. data/sample_app_rails_4/public/assets/application-eeb856e3fe2c8f879c91d0e81d59cb40.js +12952 -0
  135. data/sample_app_rails_4/public/assets/application-eeb856e3fe2c8f879c91d0e81d59cb40.js.gz +0 -0
  136. data/sample_app_rails_4/public/assets/glyphicons-halflings-c806376f05e4ccabe2c5315a8e95667c.png +0 -0
  137. data/sample_app_rails_4/public/assets/glyphicons-halflings-white-62b67d9edee3db90d18833087f848d6e.png +0 -0
  138. data/sample_app_rails_4/public/assets/manifest-802de9eb1c853769101852422b620883.json +1 -0
  139. data/sample_app_rails_4/public/assets/rails-231a680f23887d9dd70710ea5efd3c62.png +0 -0
  140. data/sample_app_rails_4/public/favicon.ico +0 -0
  141. data/sample_app_rails_4/public/robots.txt +5 -0
  142. data/sample_app_rails_4/script/cucumber +10 -0
  143. data/sample_app_rails_4/spec/controllers/relationships_controller_spec.rb +42 -0
  144. data/sample_app_rails_4/spec/factories.rb +17 -0
  145. data/sample_app_rails_4/spec/helpers/application_helper_spec.rb +18 -0
  146. data/sample_app_rails_4/spec/models/micropost_spec.rb +30 -0
  147. data/sample_app_rails_4/spec/models/relationship_spec.rb +29 -0
  148. data/sample_app_rails_4/spec/models/user_spec.rb +194 -0
  149. data/sample_app_rails_4/spec/spec_helper.rb +49 -0
  150. data/sample_app_rails_4/spec/support/utilities.rb +21 -0
  151. data/sample_app_rails_4/vendor/assets/javascripts/.keep +0 -0
  152. data/sample_app_rails_4/vendor/assets/stylesheets/.keep +0 -0
  153. metadata +151 -1
@@ -0,0 +1 @@
1
+ {"files":{"rails-231a680f23887d9dd70710ea5efd3c62.png":{"logical_path":"rails.png","mtime":"2013-03-06T18:36:31-08:00","size":6646,"digest":"231a680f23887d9dd70710ea5efd3c62"},"application-eeb856e3fe2c8f879c91d0e81d59cb40.js":{"logical_path":"application.js","mtime":"2013-09-06T09:23:56-07:00","size":363970,"digest":"eeb856e3fe2c8f879c91d0e81d59cb40"},"application-4962059d8f80f9bb096692bacc29c4e8.css":{"logical_path":"application.css","mtime":"2013-09-06T13:20:19-07:00","size":134254,"digest":"4962059d8f80f9bb096692bacc29c4e8"},"glyphicons-halflings-white-62b67d9edee3db90d18833087f848d6e.png":{"logical_path":"glyphicons-halflings-white.png","mtime":"2013-06-24T16:40:09-07:00","size":8777,"digest":"62b67d9edee3db90d18833087f848d6e"},"glyphicons-halflings-c806376f05e4ccabe2c5315a8e95667c.png":{"logical_path":"glyphicons-halflings.png","mtime":"2013-06-24T16:40:09-07:00","size":12799,"digest":"c806376f05e4ccabe2c5315a8e95667c"}},"assets":{"rails.png":"rails-231a680f23887d9dd70710ea5efd3c62.png","application.js":"application-eeb856e3fe2c8f879c91d0e81d59cb40.js","application.css":"application-4962059d8f80f9bb096692bacc29c4e8.css","glyphicons-halflings-white.png":"glyphicons-halflings-white-62b67d9edee3db90d18833087f848d6e.png","glyphicons-halflings.png":"glyphicons-halflings-c806376f05e4ccabe2c5315a8e95667c.png"}}
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
4
+ if vendored_cucumber_bin
5
+ load File.expand_path(vendored_cucumber_bin)
6
+ else
7
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
8
+ require 'cucumber'
9
+ load Cucumber::BINARY
10
+ end
@@ -0,0 +1,42 @@
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
@@ -0,0 +1,17 @@
1
+ FactoryGirl.define do
2
+ factory :user do
3
+ sequence(:name) { |n| "Person #{n}" }
4
+ sequence(:email) { |n| "person_#{n}@example.com"}
5
+ password "foobar"
6
+ password_confirmation "foobar"
7
+
8
+ factory :admin do
9
+ admin true
10
+ end
11
+ end
12
+
13
+ factory :micropost do
14
+ content "Lorem ipsum"
15
+ user
16
+ end
17
+ end
@@ -0,0 +1,18 @@
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
@@ -0,0 +1,30 @@
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
@@ -0,0 +1,29 @@
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
@@ -0,0 +1,194 @@
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
@@ -0,0 +1,49 @@
1
+ require 'rubygems'
2
+
3
+ ENV["RAILS_ENV"] ||= 'test'
4
+ require File.expand_path("../../config/environment", __FILE__)
5
+ require 'rspec/rails'
6
+ require 'rspec/autorun'
7
+
8
+ # Requires supporting ruby files with custom matchers and macros, etc,
9
+ # in spec/support/ and its subdirectories.
10
+ Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
11
+
12
+ # Checks for pending migrations before tests are run.
13
+ # If you are not using ActiveRecord, you can remove this line.
14
+ ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration)
15
+
16
+ RSpec.configure do |config|
17
+ # ## Mock Framework
18
+ #
19
+ # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
20
+ #
21
+ # config.mock_with :mocha
22
+ # config.mock_with :flexmock
23
+ # config.mock_with :rr
24
+
25
+ # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
26
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
27
+
28
+ # If you're not using ActiveRecord, or you'd prefer not to run each of your
29
+ # examples within a transaction, remove the following line or assign false
30
+ # instead of true.
31
+ config.use_transactional_fixtures = true
32
+
33
+ # If true, the base class of anonymous controllers will be inferred
34
+ # automatically. This will be the default behavior in future versions of
35
+ # rspec-rails.
36
+ config.infer_base_class_for_anonymous_controllers = false
37
+
38
+ # Run specs in random order to surface order dependencies. If you find an
39
+ # order dependency and want to debug it, you can fix the order by providing
40
+ # the seed, which is printed after each run.
41
+ # --seed 1234
42
+ config.order = "random"
43
+ # Include the Capybara DSL so that specs in spec/requests still work.
44
+ config.include Capybara::DSL
45
+ # Disable the old-style object.should syntax.
46
+ config.expect_with :rspec do |c|
47
+ c.syntax = :expect
48
+ end
49
+ end
@@ -0,0 +1,21 @@
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