Commit 34aa640c01a58dc941e2637081997aa3aad09959
1 parent
2932cb6f
Exists in
master
and in
1 other branch
upgrade to rspec 3
Showing
80 changed files
with
377 additions
and
549 deletions
Show diff stats
.travis.yml
@@ -7,7 +7,7 @@ rvm: | @@ -7,7 +7,7 @@ rvm: | ||
7 | - ruby-head | 7 | - ruby-head |
8 | 8 | ||
9 | env: | 9 | env: |
10 | - - COVERAGE=true | 10 | + - RAILS_ENV=test COVERAGE=true |
11 | 11 | ||
12 | sudo: false | 12 | sudo: false |
13 | 13 | ||
@@ -15,7 +15,8 @@ cache: bundler | @@ -15,7 +15,8 @@ cache: bundler | ||
15 | 15 | ||
16 | services: mongodb | 16 | services: mongodb |
17 | 17 | ||
18 | -script: bundle exec rake errbit:bootstrap spec | 18 | +before_script: bundle exec rake errbit:bootstrap |
19 | +script: bundle exec rspec | ||
19 | 20 | ||
20 | matrix: | 21 | matrix: |
21 | allow_failures: | 22 | allow_failures: |
Gemfile
@@ -56,8 +56,7 @@ gem 'yajl-ruby', :require => "yajl" | @@ -56,8 +56,7 @@ gem 'yajl-ruby', :require => "yajl" | ||
56 | group :development, :test do | 56 | group :development, :test do |
57 | gem 'airbrake', :require => false | 57 | gem 'airbrake', :require => false |
58 | gem 'pry-rails' | 58 | gem 'pry-rails' |
59 | -# gem 'rpm_contrib' | ||
60 | -# gem 'newrelic_rpm' | 59 | + gem 'pry-byebug', platforms: [:mri] |
61 | gem 'quiet_assets' | 60 | gem 'quiet_assets' |
62 | end | 61 | end |
63 | 62 | ||
@@ -75,7 +74,10 @@ group :development do | @@ -75,7 +74,10 @@ group :development do | ||
75 | end | 74 | end |
76 | 75 | ||
77 | group :test do | 76 | group :test do |
78 | - gem 'rspec-rails', require: false | 77 | + gem 'rspec' |
78 | + gem 'rspec-rails', '~> 3.0', require: false | ||
79 | + gem 'rspec-activemodel-mocks' | ||
80 | + gem 'rspec-its' | ||
79 | gem 'mongoid-rspec', require: false | 81 | gem 'mongoid-rspec', require: false |
80 | gem 'fabrication' | 82 | gem 'fabrication' |
81 | gem 'capybara' | 83 | gem 'capybara' |
Gemfile.lock
@@ -45,7 +45,7 @@ GEM | @@ -45,7 +45,7 @@ GEM | ||
45 | minitest (~> 5.1) | 45 | minitest (~> 5.1) |
46 | thread_safe (~> 0.1) | 46 | thread_safe (~> 0.1) |
47 | tzinfo (~> 1.1) | 47 | tzinfo (~> 1.1) |
48 | - addressable (2.3.5) | 48 | + addressable (2.3.6) |
49 | airbrake (3.1.14) | 49 | airbrake (3.1.14) |
50 | builder | 50 | builder |
51 | json | 51 | json |
@@ -58,6 +58,9 @@ GEM | @@ -58,6 +58,9 @@ GEM | ||
58 | debug_inspector (>= 0.0.1) | 58 | debug_inspector (>= 0.0.1) |
59 | bson (2.3.0) | 59 | bson (2.3.0) |
60 | builder (3.2.2) | 60 | builder (3.2.2) |
61 | + byebug (2.7.0) | ||
62 | + columnize (~> 0.3) | ||
63 | + debugger-linecache (~> 1.2) | ||
61 | callsite (0.0.11) | 64 | callsite (0.0.11) |
62 | campy (1.0.0) | 65 | campy (1.0.0) |
63 | capistrano (3.3.5) | 66 | capistrano (3.3.5) |
@@ -75,7 +78,7 @@ GEM | @@ -75,7 +78,7 @@ GEM | ||
75 | capistrano (~> 3.1) | 78 | capistrano (~> 3.1) |
76 | sshkit (~> 1.3) | 79 | sshkit (~> 1.3) |
77 | capistrano-stats (1.1.1) | 80 | capistrano-stats (1.1.1) |
78 | - capybara (2.1.0) | 81 | + capybara (2.4.4) |
79 | mime-types (>= 1.16) | 82 | mime-types (>= 1.16) |
80 | nokogiri (>= 1.3.3) | 83 | nokogiri (>= 1.3.3) |
81 | rack (>= 1.0.0) | 84 | rack (>= 1.0.0) |
@@ -91,6 +94,7 @@ GEM | @@ -91,6 +94,7 @@ GEM | ||
91 | execjs | 94 | execjs |
92 | coffee-script-source (1.8.0) | 95 | coffee-script-source (1.8.0) |
93 | colorize (0.7.5) | 96 | colorize (0.7.5) |
97 | + columnize (0.9.0) | ||
94 | connection_pool (2.1.0) | 98 | connection_pool (2.1.0) |
95 | coveralls (0.7.0) | 99 | coveralls (0.7.0) |
96 | multi_json (~> 1.3) | 100 | multi_json (~> 1.3) |
@@ -102,6 +106,7 @@ GEM | @@ -102,6 +106,7 @@ GEM | ||
102 | addressable | 106 | addressable |
103 | database_cleaner (1.2.0) | 107 | database_cleaner (1.2.0) |
104 | debug_inspector (0.0.2) | 108 | debug_inspector (0.0.2) |
109 | + debugger-linecache (1.2.0) | ||
105 | decent_exposure (2.3.2) | 110 | decent_exposure (2.3.2) |
106 | devise (3.4.1) | 111 | devise (3.4.1) |
107 | bcrypt (~> 3.0) | 112 | bcrypt (~> 3.0) |
@@ -110,14 +115,14 @@ GEM | @@ -110,14 +115,14 @@ GEM | ||
110 | responders | 115 | responders |
111 | thread_safe (~> 0.1) | 116 | thread_safe (~> 0.1) |
112 | warden (~> 1.2.3) | 117 | warden (~> 1.2.3) |
113 | - diff-lcs (1.2.4) | 118 | + diff-lcs (1.2.5) |
114 | dotenv (0.9.0) | 119 | dotenv (0.9.0) |
115 | - draper (1.3.0) | 120 | + draper (1.4.0) |
116 | actionpack (>= 3.0) | 121 | actionpack (>= 3.0) |
117 | activemodel (>= 3.0) | 122 | activemodel (>= 3.0) |
118 | activesupport (>= 3.0) | 123 | activesupport (>= 3.0) |
119 | - request_store (~> 1.0.3) | ||
120 | - email_spec (1.5.0) | 124 | + request_store (~> 1.0) |
125 | + email_spec (1.6.0) | ||
121 | launchy (~> 2.1) | 126 | launchy (~> 2.1) |
122 | mail (~> 2.2) | 127 | mail (~> 2.2) |
123 | erubis (2.7.0) | 128 | erubis (2.7.0) |
@@ -152,14 +157,14 @@ GEM | @@ -152,14 +157,14 @@ GEM | ||
152 | jquery-rails (2.1.4) | 157 | jquery-rails (2.1.4) |
153 | railties (>= 3.0, < 5.0) | 158 | railties (>= 3.0, < 5.0) |
154 | thor (>= 0.14, < 2.0) | 159 | thor (>= 0.14, < 2.0) |
155 | - json (1.8.1) | 160 | + json (1.8.2) |
156 | jwt (0.1.8) | 161 | jwt (0.1.8) |
157 | multi_json (>= 1.5) | 162 | multi_json (>= 1.5) |
158 | kaminari (0.14.1) | 163 | kaminari (0.14.1) |
159 | actionpack (>= 3.0.0) | 164 | actionpack (>= 3.0.0) |
160 | activesupport (>= 3.0.0) | 165 | activesupport (>= 3.0.0) |
161 | kgio (2.9.2) | 166 | kgio (2.9.2) |
162 | - launchy (2.3.0) | 167 | + launchy (2.4.3) |
163 | addressable (~> 2.3) | 168 | addressable (~> 2.3) |
164 | mail (2.6.3) | 169 | mail (2.6.3) |
165 | mime-types (>= 1.16, < 3) | 170 | mime-types (>= 1.16, < 3) |
@@ -169,23 +174,23 @@ GEM | @@ -169,23 +174,23 @@ GEM | ||
169 | railties | 174 | railties |
170 | method_source (0.8.2) | 175 | method_source (0.8.2) |
171 | mime-types (1.25.1) | 176 | mime-types (1.25.1) |
172 | - mini_portile (0.6.1) | ||
173 | - minitest (5.5.0) | 177 | + mini_portile (0.6.2) |
178 | + minitest (5.5.1) | ||
174 | mongoid (4.0.0) | 179 | mongoid (4.0.0) |
175 | activemodel (~> 4.0) | 180 | activemodel (~> 4.0) |
176 | moped (~> 2.0.0) | 181 | moped (~> 2.0.0) |
177 | origin (~> 2.1) | 182 | origin (~> 2.1) |
178 | tzinfo (>= 0.3.37) | 183 | tzinfo (>= 0.3.37) |
179 | - mongoid-rspec (1.9.0) | ||
180 | - mongoid (>= 3.0.1) | 184 | + mongoid-rspec (2.0.0) |
185 | + mongoid (~> 4.0.0) | ||
181 | rake | 186 | rake |
182 | - rspec (>= 2.14) | 187 | + rspec (~> 3.1) |
183 | mongoid_rails_migrations (1.0.1) | 188 | mongoid_rails_migrations (1.0.1) |
184 | activesupport (>= 3.2.0) | 189 | activesupport (>= 3.2.0) |
185 | bundler (>= 1.0.0) | 190 | bundler (>= 1.0.0) |
186 | rails (>= 3.2.0) | 191 | rails (>= 3.2.0) |
187 | railties (>= 3.2.0) | 192 | railties (>= 3.2.0) |
188 | - moped (2.0.2) | 193 | + moped (2.0.3) |
189 | bson (~> 2.2) | 194 | bson (~> 2.2) |
190 | connection_pool (~> 2.0) | 195 | connection_pool (~> 2.0) |
191 | optionable (~> 0.2.0) | 196 | optionable (~> 0.2.0) |
@@ -195,7 +200,7 @@ GEM | @@ -195,7 +200,7 @@ GEM | ||
195 | net-scp (1.2.1) | 200 | net-scp (1.2.1) |
196 | net-ssh (>= 2.6.5) | 201 | net-ssh (>= 2.6.5) |
197 | net-ssh (2.9.1) | 202 | net-ssh (2.9.1) |
198 | - nokogiri (1.6.4.1) | 203 | + nokogiri (1.6.5) |
199 | mini_portile (~> 0.6.0) | 204 | mini_portile (~> 0.6.0) |
200 | oauth2 (0.8.1) | 205 | oauth2 (0.8.1) |
201 | faraday (~> 0.8) | 206 | faraday (~> 0.8) |
@@ -232,6 +237,9 @@ GEM | @@ -232,6 +237,9 @@ GEM | ||
232 | coderay (~> 1.0.5) | 237 | coderay (~> 1.0.5) |
233 | method_source (~> 0.8) | 238 | method_source (~> 0.8) |
234 | slop (~> 3.4) | 239 | slop (~> 3.4) |
240 | + pry-byebug (1.3.2) | ||
241 | + byebug (~> 2.7) | ||
242 | + pry (~> 0.9.12) | ||
235 | pry-rails (0.3.2) | 243 | pry-rails (0.3.2) |
236 | pry (>= 0.9.10) | 244 | pry (>= 0.9.10) |
237 | quiet_assets (1.0.2) | 245 | quiet_assets (1.0.2) |
@@ -242,7 +250,7 @@ GEM | @@ -242,7 +250,7 @@ GEM | ||
242 | rack-ssl (1.4.0) | 250 | rack-ssl (1.4.0) |
243 | rack | 251 | rack |
244 | rack-ssl-enforcer (0.2.6) | 252 | rack-ssl-enforcer (0.2.6) |
245 | - rack-test (0.6.2) | 253 | + rack-test (0.6.3) |
246 | rack (>= 1.0) | 254 | rack (>= 1.0) |
247 | rails (4.1.8) | 255 | rails (4.1.8) |
248 | actionmailer (= 4.1.8) | 256 | actionmailer (= 4.1.8) |
@@ -265,28 +273,40 @@ GEM | @@ -265,28 +273,40 @@ GEM | ||
265 | rake (10.4.2) | 273 | rake (10.4.2) |
266 | rdoc (4.1.2) | 274 | rdoc (4.1.2) |
267 | json (~> 1.4) | 275 | json (~> 1.4) |
268 | - request_store (1.0.6) | 276 | + request_store (1.1.0) |
269 | responders (1.1.2) | 277 | responders (1.1.2) |
270 | railties (>= 3.2, < 4.2) | 278 | railties (>= 3.2, < 4.2) |
271 | rest-client (1.6.8) | 279 | rest-client (1.6.8) |
272 | mime-types (~> 1.16) | 280 | mime-types (~> 1.16) |
273 | rdoc (>= 2.4.2) | 281 | rdoc (>= 2.4.2) |
274 | ri_cal (0.8.8) | 282 | ri_cal (0.8.8) |
275 | - rspec (2.14.1) | ||
276 | - rspec-core (~> 2.14.0) | ||
277 | - rspec-expectations (~> 2.14.0) | ||
278 | - rspec-mocks (~> 2.14.0) | ||
279 | - rspec-core (2.14.6) | ||
280 | - rspec-expectations (2.14.3) | ||
281 | - diff-lcs (>= 1.1.3, < 2.0) | ||
282 | - rspec-mocks (2.14.4) | ||
283 | - rspec-rails (2.14.0) | 283 | + rspec (3.1.0) |
284 | + rspec-core (~> 3.1.0) | ||
285 | + rspec-expectations (~> 3.1.0) | ||
286 | + rspec-mocks (~> 3.1.0) | ||
287 | + rspec-activemodel-mocks (1.0.1) | ||
288 | + activemodel (>= 3.0) | ||
289 | + activesupport (>= 3.0) | ||
290 | + rspec-mocks (>= 2.99, < 4.0) | ||
291 | + rspec-core (3.1.7) | ||
292 | + rspec-support (~> 3.1.0) | ||
293 | + rspec-expectations (3.1.2) | ||
294 | + diff-lcs (>= 1.2.0, < 2.0) | ||
295 | + rspec-support (~> 3.1.0) | ||
296 | + rspec-its (1.1.0) | ||
297 | + rspec-core (>= 3.0.0) | ||
298 | + rspec-expectations (>= 3.0.0) | ||
299 | + rspec-mocks (3.1.3) | ||
300 | + rspec-support (~> 3.1.0) | ||
301 | + rspec-rails (3.1.0) | ||
284 | actionpack (>= 3.0) | 302 | actionpack (>= 3.0) |
285 | activesupport (>= 3.0) | 303 | activesupport (>= 3.0) |
286 | railties (>= 3.0) | 304 | railties (>= 3.0) |
287 | - rspec-core (~> 2.14.0) | ||
288 | - rspec-expectations (~> 2.14.0) | ||
289 | - rspec-mocks (~> 2.14.0) | 305 | + rspec-core (~> 3.1.0) |
306 | + rspec-expectations (~> 3.1.0) | ||
307 | + rspec-mocks (~> 3.1.0) | ||
308 | + rspec-support (~> 3.1.0) | ||
309 | + rspec-support (3.1.2) | ||
290 | rushover (0.3.0) | 310 | rushover (0.3.0) |
291 | json | 311 | json |
292 | rest-client | 312 | rest-client |
@@ -340,7 +360,9 @@ GEM | @@ -340,7 +360,9 @@ GEM | ||
340 | useragent (0.9.0) | 360 | useragent (0.9.0) |
341 | warden (1.2.3) | 361 | warden (1.2.3) |
342 | rack (>= 1.0) | 362 | rack (>= 1.0) |
343 | - websocket-driver (0.3.3) | 363 | + websocket-driver (0.5.1) |
364 | + websocket-extensions (>= 0.1.0) | ||
365 | + websocket-extensions (0.1.1) | ||
344 | xmpp4r (0.5.5) | 366 | xmpp4r (0.5.5) |
345 | xpath (2.0.0) | 367 | xpath (2.0.0) |
346 | nokogiri (~> 1.3) | 368 | nokogiri (~> 1.3) |
@@ -391,6 +413,7 @@ DEPENDENCIES | @@ -391,6 +413,7 @@ DEPENDENCIES | ||
391 | omniauth-github | 413 | omniauth-github |
392 | pjax_rails | 414 | pjax_rails |
393 | poltergeist | 415 | poltergeist |
416 | + pry-byebug | ||
394 | pry-rails | 417 | pry-rails |
395 | quiet_assets | 418 | quiet_assets |
396 | rack-ssl | 419 | rack-ssl |
@@ -398,7 +421,10 @@ DEPENDENCIES | @@ -398,7 +421,10 @@ DEPENDENCIES | ||
398 | rails_autolink | 421 | rails_autolink |
399 | railties (~> 4.1.8) | 422 | railties (~> 4.1.8) |
400 | ri_cal | 423 | ri_cal |
401 | - rspec-rails | 424 | + rspec |
425 | + rspec-activemodel-mocks | ||
426 | + rspec-its | ||
427 | + rspec-rails (~> 3.0) | ||
402 | rushover | 428 | rushover |
403 | sass-rails | 429 | sass-rails |
404 | test-unit | 430 | test-unit |
spec/acceptance/acceptance_helper.rb
spec/acceptance/sign_in_with_github_spec.rb
@@ -3,7 +3,7 @@ require 'acceptance/acceptance_helper' | @@ -3,7 +3,7 @@ require 'acceptance/acceptance_helper' | ||
3 | feature 'Sign in with GitHub' do | 3 | feature 'Sign in with GitHub' do |
4 | 4 | ||
5 | background do | 5 | background do |
6 | - Errbit::Config.stub(:github_authentication) { true } | 6 | + allow(Errbit::Config).to receive(:github_authentication).and_return(true) |
7 | Fabricate(:user, :github_login => 'nashby') | 7 | Fabricate(:user, :github_login => 'nashby') |
8 | end | 8 | end |
9 | 9 |
spec/controllers/api/v1/notices_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Api::V1::NoticesController do | ||
4 | - | 1 | +describe Api::V1::NoticesController, type: 'controller' do |
5 | context "when logged in" do | 2 | context "when logged in" do |
6 | before do | 3 | before do |
7 | @user = Fabricate(:user) | 4 | @user = Fabricate(:user) |
@@ -50,5 +47,4 @@ describe Api::V1::NoticesController do | @@ -50,5 +47,4 @@ describe Api::V1::NoticesController do | ||
50 | 47 | ||
51 | end | 48 | end |
52 | end | 49 | end |
53 | - | ||
54 | end | 50 | end |
spec/controllers/api/v1/problems_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Api::V1::ProblemsController do | ||
4 | - | 1 | +describe Api::V1::ProblemsController, type: 'controller' do |
5 | context "when logged in" do | 2 | context "when logged in" do |
6 | before do | 3 | before do |
7 | @user = Fabricate(:user) | 4 | @user = Fabricate(:user) |
@@ -69,8 +66,6 @@ describe Api::V1::ProblemsController do | @@ -69,8 +66,6 @@ describe Api::V1::ProblemsController do | ||
69 | Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 30)) | 66 | Fabricate(:problem, :first_notice_at => Date.new(2012, 8, 30)) |
70 | end | 67 | end |
71 | 68 | ||
72 | - | ||
73 | - | ||
74 | it "should return JSON if JSON is requested" do | 69 | it "should return JSON if JSON is requested" do |
75 | get :index, :auth_token => @user.authentication_token, :format => "json" | 70 | get :index, :auth_token => @user.authentication_token, :format => "json" |
76 | expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError) | 71 | expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError) |
@@ -86,17 +81,13 @@ describe Api::V1::ProblemsController do | @@ -86,17 +81,13 @@ describe Api::V1::ProblemsController do | ||
86 | expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError) | 81 | expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError) |
87 | end | 82 | end |
88 | 83 | ||
89 | - | ||
90 | - | ||
91 | describe "given a date range" do | 84 | describe "given a date range" do |
92 | - | ||
93 | it "should return only the problems open during the date range" do | 85 | it "should return only the problems open during the date range" do |
94 | get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27"} | 86 | get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27"} |
95 | expect(response).to be_success | 87 | expect(response).to be_success |
96 | problems = JSON.load response.body | 88 | problems = JSON.load response.body |
97 | expect(problems.length).to eq 2 | 89 | expect(problems.length).to eq 2 |
98 | end | 90 | end |
99 | - | ||
100 | end | 91 | end |
101 | 92 | ||
102 | it "should return all problems" do | 93 | it "should return all problems" do |
@@ -105,8 +96,6 @@ describe Api::V1::ProblemsController do | @@ -105,8 +96,6 @@ describe Api::V1::ProblemsController do | ||
105 | problems = JSON.load response.body | 96 | problems = JSON.load response.body |
106 | expect(problems.length).to eq 4 | 97 | expect(problems.length).to eq 4 |
107 | end | 98 | end |
108 | - | ||
109 | end | 99 | end |
110 | end | 100 | end |
111 | - | ||
112 | end | 101 | end |
spec/controllers/apps_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe AppsController do | ||
4 | - | 1 | +describe AppsController, type: 'controller' do |
5 | it_requires_authentication | 2 | it_requires_authentication |
6 | it_requires_admin_privileges :for => {:new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete} | 3 | it_requires_admin_privileges :for => {:new => :get, :edit => :get, :create => :post, :update => :put, :destroy => :delete} |
7 | 4 | ||
@@ -218,7 +215,7 @@ describe AppsController do | @@ -218,7 +215,7 @@ describe AppsController do | ||
218 | describe "POST /apps" do | 215 | describe "POST /apps" do |
219 | before do | 216 | before do |
220 | @app = Fabricate(:app) | 217 | @app = Fabricate(:app) |
221 | - App.stub(:new).and_return(@app) | 218 | + allow(App).to receive(:new).and_return(@app) |
222 | end | 219 | end |
223 | 220 | ||
224 | context "when the create is successful" do | 221 | context "when the create is successful" do |
spec/controllers/comments_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe CommentsController do | 1 | +describe CommentsController, type: 'controller' do |
4 | let(:app) { Fabricate(:app) } | 2 | let(:app) { Fabricate(:app) } |
5 | let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production")) } | 3 | let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production")) } |
6 | 4 |
spec/controllers/deploys_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe DeploysController do | 1 | +describe DeploysController, type: 'controller' do |
4 | render_views | 2 | render_views |
5 | 3 | ||
6 | context 'POST #create' do | 4 | context 'POST #create' do |
@@ -21,7 +19,7 @@ describe DeploysController do | @@ -21,7 +19,7 @@ describe DeploysController do | ||
21 | end | 19 | end |
22 | 20 | ||
23 | it 'creates a deploy' do | 21 | it 'creates a deploy' do |
24 | - App.stub(:find_by_api_key!).and_return(@app) | 22 | + expect(App).to receive(:find_by_api_key!).and_return(@app) |
25 | expect(@app.deploys).to receive(:create!). | 23 | expect(@app.deploys).to receive(:create!). |
26 | with({ | 24 | with({ |
27 | :username => 'john.doe', | 25 | :username => 'john.doe', |
@@ -40,7 +38,6 @@ describe DeploysController do | @@ -40,7 +38,6 @@ describe DeploysController do | ||
40 | expect(email.to).to include(@app.watchers.first.email) | 38 | expect(email.to).to include(@app.watchers.first.email) |
41 | expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe" | 39 | expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe" |
42 | end | 40 | end |
43 | - | ||
44 | end | 41 | end |
45 | 42 | ||
46 | context "GET #index" do | 43 | context "GET #index" do |
@@ -59,6 +56,4 @@ describe DeploysController do | @@ -59,6 +56,4 @@ describe DeploysController do | ||
59 | expect(response.body).to match(@deploy.app.name) | 56 | expect(response.body).to match(@deploy.app.name) |
60 | end | 57 | end |
61 | end | 58 | end |
62 | - | ||
63 | end | 59 | end |
64 | - |
spec/controllers/devise_sessions_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Devise::SessionsController do | 1 | +describe Devise::SessionsController, type: 'controller' do |
4 | render_views | 2 | render_views |
5 | 3 | ||
6 | describe "POST /users/sign_in" do | 4 | describe "POST /users/sign_in" do |
@@ -23,4 +21,3 @@ describe Devise::SessionsController do | @@ -23,4 +21,3 @@ describe Devise::SessionsController do | ||
23 | end | 21 | end |
24 | end | 22 | end |
25 | end | 23 | end |
26 | - |
spec/controllers/notices_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NoticesController do | 1 | +describe NoticesController, type: 'controller' do |
4 | it_requires_authentication :for => { :locate => :get } | 2 | it_requires_authentication :for => { :locate => :get } |
5 | 3 | ||
6 | let(:notice) { Fabricate(:notice) } | 4 | let(:notice) { Fabricate(:notice) } |
@@ -78,6 +76,4 @@ describe NoticesController do | @@ -78,6 +76,4 @@ describe NoticesController do | ||
78 | end | 76 | end |
79 | end | 77 | end |
80 | end | 78 | end |
81 | - | ||
82 | end | 79 | end |
83 | - |
spec/controllers/problems_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe ProblemsController do | ||
4 | - | 1 | +describe ProblemsController, type: 'controller' do |
5 | it_requires_authentication :for => { | 2 | it_requires_authentication :for => { |
6 | :index => :get, :show => :get, :resolve => :put, :search => :get | 3 | :index => :get, :show => :get, :resolve => :put, :search => :get |
7 | }, | 4 | }, |
@@ -218,38 +215,35 @@ describe ProblemsController do | @@ -218,38 +215,35 @@ describe ProblemsController do | ||
218 | before do | 215 | before do |
219 | sign_in admin | 216 | sign_in admin |
220 | 217 | ||
221 | - @problem = Fabricate(:err) | ||
222 | - App.stub(:find).with(@problem.app.id.to_s).and_return(@problem.app) | ||
223 | - @problem.app.problems.stub(:find).and_return(@problem.problem) | ||
224 | - @problem.problem.stub(:resolve!) | 218 | + @err = Fabricate(:err) |
225 | end | 219 | end |
226 | 220 | ||
227 | - it 'finds the app and the problem' do | ||
228 | - expect(App).to receive(:find).with(@problem.app.id.to_s).and_return(@problem.app) | ||
229 | - expect(@problem.app.problems).to receive(:find).and_return(@problem.problem) | ||
230 | - put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | ||
231 | - expect(controller.app).to eq @problem.app | ||
232 | - expect(controller.problem).to eq @problem.problem | 221 | + it 'finds the app and the err' do |
222 | + expect(App).to receive(:find).with(@err.app.id.to_s).and_return(@err.app) | ||
223 | + expect(@err.app.problems).to receive(:find).and_return(@err.problem) | ||
224 | + put :resolve, :app_id => @err.app.id, :id => @err.problem.id | ||
225 | + expect(controller.app).to eq @err.app | ||
226 | + expect(controller.problem).to eq @err.problem | ||
233 | end | 227 | end |
234 | 228 | ||
235 | it "should resolve the issue" do | 229 | it "should resolve the issue" do |
236 | - expect(@problem.problem).to receive(:resolve!).and_return(true) | ||
237 | - put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | 230 | + put :resolve, :app_id => @err.app.id, :id => @err.problem.id |
231 | + expect(@err.problem.reload.resolved).to be(true) | ||
238 | end | 232 | end |
239 | 233 | ||
240 | it "should display a message" do | 234 | it "should display a message" do |
241 | - put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | 235 | + put :resolve, :app_id => @err.app.id, :id => @err.problem.id |
242 | expect(request.flash[:success]).to match(/Great news/) | 236 | expect(request.flash[:success]).to match(/Great news/) |
243 | end | 237 | end |
244 | 238 | ||
245 | it "should redirect to the app page" do | 239 | it "should redirect to the app page" do |
246 | - put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | ||
247 | - expect(response).to redirect_to(app_path(@problem.app)) | 240 | + put :resolve, :app_id => @err.app.id, :id => @err.problem.id |
241 | + expect(response).to redirect_to(app_path(@err.app)) | ||
248 | end | 242 | end |
249 | 243 | ||
250 | it "should redirect back to problems page" do | 244 | it "should redirect back to problems page" do |
251 | request.env["HTTP_REFERER"] = problems_path | 245 | request.env["HTTP_REFERER"] = problems_path |
252 | - put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | 246 | + put :resolve, :app_id => @err.app.id, :id => @err.problem.id |
253 | expect(response).to redirect_to(problems_path) | 247 | expect(response).to redirect_to(problems_path) |
254 | end | 248 | end |
255 | end | 249 | end |
@@ -268,8 +262,8 @@ describe ProblemsController do | @@ -268,8 +262,8 @@ describe ProblemsController do | ||
268 | 262 | ||
269 | before do | 263 | before do |
270 | problem.app.issue_tracker = issue_tracker | 264 | problem.app.issue_tracker = issue_tracker |
271 | - controller.stub(:problem).and_return(problem) | ||
272 | - controller.stub(:current_user).and_return(admin) | 265 | + allow(controller).to receive(:problem).and_return(problem) |
266 | + allow(controller).to receive(:current_user).and_return(admin) | ||
273 | end | 267 | end |
274 | 268 | ||
275 | it "should redirect to problem page" do | 269 | it "should redirect to problem page" do |
@@ -461,7 +455,5 @@ describe ProblemsController do | @@ -461,7 +455,5 @@ describe ProblemsController do | ||
461 | expect(response).to redirect_to(edit_app_path(@app)) | 455 | expect(response).to redirect_to(edit_app_path(@app)) |
462 | end | 456 | end |
463 | end | 457 | end |
464 | - | ||
465 | end | 458 | end |
466 | - | ||
467 | end | 459 | end |
spec/controllers/users/omniauth_callbacks_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Users::OmniauthCallbacksController do | ||
4 | - | 1 | +describe Users::OmniauthCallbacksController, type: 'controller' do |
5 | def stub_env_for_github_omniauth(login, token = nil) | 2 | def stub_env_for_github_omniauth(login, token = nil) |
6 | # This a Devise specific thing for functional tests. See https://github.com/plataformatec/devise/issues/closed#issue/608 | 3 | # This a Devise specific thing for functional tests. See https://github.com/plataformatec/devise/issues/closed#issue/608 |
7 | request.env["devise.mapping"] = Devise.mappings[:user] | 4 | request.env["devise.mapping"] = Devise.mappings[:user] |
@@ -12,7 +9,7 @@ describe Users::OmniauthCallbacksController do | @@ -12,7 +9,7 @@ describe Users::OmniauthCallbacksController do | ||
12 | :credentials => { :token => token } | 9 | :credentials => { :token => token } |
13 | ) | 10 | ) |
14 | } | 11 | } |
15 | - @controller.stub(:env).and_return(env) | 12 | + allow(@controller).to receive(:env).and_return(env) |
16 | end | 13 | end |
17 | 14 | ||
18 | context 'Linking a GitHub account to a signed in user' do | 15 | context 'Linking a GitHub account to a signed in user' do |
spec/controllers/users_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe UsersController do | ||
4 | - | 1 | +describe UsersController, type: 'controller' do |
5 | it_requires_authentication | 2 | it_requires_authentication |
6 | it_requires_admin_privileges :for => { | 3 | it_requires_admin_privileges :for => { |
7 | :index => :get, | 4 | :index => :get, |
@@ -16,7 +13,6 @@ describe UsersController do | @@ -16,7 +13,6 @@ describe UsersController do | ||
16 | let(:other_user) { Fabricate(:user) } | 13 | let(:other_user) { Fabricate(:user) } |
17 | 14 | ||
18 | context 'Signed in as a regular user' do | 15 | context 'Signed in as a regular user' do |
19 | - | ||
20 | before do | 16 | before do |
21 | sign_in user | 17 | sign_in user |
22 | end | 18 | end |
@@ -104,16 +100,12 @@ describe UsersController do | @@ -104,16 +100,12 @@ describe UsersController do | ||
104 | end | 100 | end |
105 | 101 | ||
106 | context "GET /users" do | 102 | context "GET /users" do |
107 | - | ||
108 | it 'paginates all users' do | 103 | it 'paginates all users' do |
109 | admin.update_attribute :per_page, 2 | 104 | admin.update_attribute :per_page, 2 |
110 | - users = 3.times { | ||
111 | - Fabricate(:user) | ||
112 | - } | 105 | + 3.times { Fabricate(:user) } |
113 | get :index | 106 | get :index |
114 | expect(controller.users.to_a.size).to eq 2 | 107 | expect(controller.users.to_a.size).to eq 2 |
115 | end | 108 | end |
116 | - | ||
117 | end | 109 | end |
118 | 110 | ||
119 | context "GET /users/:id" do | 111 | context "GET /users/:id" do |
@@ -140,7 +132,7 @@ describe UsersController do | @@ -140,7 +132,7 @@ describe UsersController do | ||
140 | 132 | ||
141 | context "POST /users" do | 133 | context "POST /users" do |
142 | context "when the create is successful" do | 134 | context "when the create is successful" do |
143 | - let(:attrs) { {:user => Fabricate.attributes_for(:user)} } | 135 | + let(:attrs) { {:user => Fabricate.to_params(:user)} } |
144 | 136 | ||
145 | it "sets a message to display" do | 137 | it "sets a message to display" do |
146 | post :create, attrs | 138 | post :create, attrs |
@@ -156,7 +148,7 @@ describe UsersController do | @@ -156,7 +148,7 @@ describe UsersController do | ||
156 | attrs[:user][:admin] = true | 148 | attrs[:user][:admin] = true |
157 | post :create, attrs | 149 | post :create, attrs |
158 | expect(response).to be_redirect | 150 | expect(response).to be_redirect |
159 | - expect(User.find(controller.user.to_param).admin).to be_true | 151 | + expect(User.find(controller.user.to_param).admin).to be(true) |
160 | end | 152 | end |
161 | 153 | ||
162 | it "should has auth token" do | 154 | it "should has auth token" do |
@@ -205,7 +197,6 @@ describe UsersController do | @@ -205,7 +197,6 @@ describe UsersController do | ||
205 | end | 197 | end |
206 | 198 | ||
207 | context "DELETE /users/:id" do | 199 | context "DELETE /users/:id" do |
208 | - | ||
209 | context "with a destroy success" do | 200 | context "with a destroy success" do |
210 | let(:user_destroy) { double(:destroy => true) } | 201 | let(:user_destroy) { double(:destroy => true) } |
211 | 202 | ||
@@ -236,8 +227,10 @@ describe UsersController do | @@ -236,8 +227,10 @@ describe UsersController do | ||
236 | describe "#user_params" do | 227 | describe "#user_params" do |
237 | context "with current user not admin" do | 228 | context "with current user not admin" do |
238 | before { | 229 | before { |
239 | - controller.stub(:current_user).and_return(user) | ||
240 | - controller.stub(:params).and_return(ActionController::Parameters.new(user_param)) | 230 | + allow(controller).to receive(:current_user).and_return(user) |
231 | + allow(controller).to receive(:params).and_return( | ||
232 | + ActionController::Parameters.new(user_param) | ||
233 | + ) | ||
241 | } | 234 | } |
242 | let(:user_param) { {'user' => { :name => 'foo', :admin => true }} } | 235 | let(:user_param) { {'user' => { :name => 'foo', :admin => true }} } |
243 | it 'not have admin field' do | 236 | it 'not have admin field' do |
@@ -261,7 +254,5 @@ describe UsersController do | @@ -261,7 +254,5 @@ describe UsersController do | ||
261 | end | 254 | end |
262 | end | 255 | end |
263 | end | 256 | end |
264 | - | ||
265 | end | 257 | end |
266 | - | ||
267 | end | 258 | end |
spec/controllers/watchers_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe WatchersController do | 1 | +describe WatchersController, type: 'controller' do |
4 | let(:app) do | 2 | let(:app) do |
5 | a = Fabricate(:app) | 3 | a = Fabricate(:app) |
6 | Fabricate(:user_watcher, :app => a) | 4 | Fabricate(:user_watcher, :app => a) |
@@ -8,7 +6,6 @@ describe WatchersController do | @@ -8,7 +6,6 @@ describe WatchersController do | ||
8 | end | 6 | end |
9 | 7 | ||
10 | describe "DELETE /apps/:app_id/watchers/:id/destroy" do | 8 | describe "DELETE /apps/:app_id/watchers/:id/destroy" do |
11 | - | ||
12 | context "with admin user" do | 9 | context "with admin user" do |
13 | before(:each) do | 10 | before(:each) do |
14 | sign_in Fabricate(:admin) | 11 | sign_in Fabricate(:admin) |
spec/decorators/app_decorator_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | describe AppDecorator do | 1 | describe AppDecorator do |
4 | - | ||
5 | describe "#email_at_notices" do | 2 | describe "#email_at_notices" do |
6 | - | ||
7 | it 'return the list separate by comma' do | 3 | it 'return the list separate by comma' do |
8 | expect(AppDecorator.new(double(:email_at_notices => [2,3])).email_at_notices).to eql '2, 3' | 4 | expect(AppDecorator.new(double(:email_at_notices => [2,3])).email_at_notices).to eql '2, 3' |
9 | end | 5 | end |
10 | - | ||
11 | end | 6 | end |
12 | 7 | ||
13 | describe "#notify_user_display" do | 8 | describe "#notify_user_display" do |
14 | - | ||
15 | it 'return display:none if notify' do | 9 | it 'return display:none if notify' do |
16 | expect(AppDecorator.new(double(:notify_all_users => true)).notify_user_display).to eql 'display: none;' | 10 | expect(AppDecorator.new(double(:notify_all_users => true)).notify_user_display).to eql 'display: none;' |
17 | end | 11 | end |
@@ -19,11 +13,9 @@ describe AppDecorator do | @@ -19,11 +13,9 @@ describe AppDecorator do | ||
19 | it 'return blank if no notify' do | 13 | it 'return blank if no notify' do |
20 | expect(AppDecorator.new(double(:notify_all_users => false)).notify_user_display).to eql '' | 14 | expect(AppDecorator.new(double(:notify_all_users => false)).notify_user_display).to eql '' |
21 | end | 15 | end |
22 | - | ||
23 | end | 16 | end |
24 | 17 | ||
25 | describe "#notify_err_display" do | 18 | describe "#notify_err_display" do |
26 | - | ||
27 | it 'return display:none if no notify' do | 19 | it 'return display:none if no notify' do |
28 | expect(AppDecorator.new(double(:notify_on_errs => false)).notify_err_display).to eql 'display: none;' | 20 | expect(AppDecorator.new(double(:notify_on_errs => false)).notify_err_display).to eql 'display: none;' |
29 | end | 21 | end |
@@ -31,7 +23,5 @@ describe AppDecorator do | @@ -31,7 +23,5 @@ describe AppDecorator do | ||
31 | it 'return blank if no notify' do | 23 | it 'return blank if no notify' do |
32 | expect(AppDecorator.new(double(:notify_on_errs => true)).notify_err_display).to eql '' | 24 | expect(AppDecorator.new(double(:notify_on_errs => true)).notify_err_display).to eql '' |
33 | end | 25 | end |
34 | - | ||
35 | end | 26 | end |
36 | - | ||
37 | end | 27 | end |
spec/decorators/issue_tracker_decorator_spec.rb
spec/decorators/issue_tracker_field_decorator.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | describe IssueTrackerFieldDecorator do | 1 | describe IssueTrackerFieldDecorator do |
4 | - | ||
5 | describe "#label" do | 2 | describe "#label" do |
6 | it 'return the label of field_info by default' do | 3 | it 'return the label of field_info by default' do |
7 | expect(IssueTrackerFieldDecorator.new(:foo, {:label => 'hello'}).label).to eq 'hello' | 4 | expect(IssueTrackerFieldDecorator.new(:foo, {:label => 'hello'}).label).to eq 'hello' |
8 | end | 5 | end |
6 | + | ||
9 | it 'return the key of field if no label define' do | 7 | it 'return the key of field if no label define' do |
10 | expect(IssueTrackerFieldDecorator.new(:foo, {}).label).to eq 'foo' | 8 | expect(IssueTrackerFieldDecorator.new(:foo, {}).label).to eq 'foo' |
11 | end | 9 | end |
12 | end | 10 | end |
13 | - | ||
14 | end | 11 | end |
spec/decorators/watcher_decorator_spec.rb
spec/helpers/application_helper_spec.rb
spec/helpers/backtrace_line_helper.rb
spec/helpers/navigation_helper_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | describe NavigationHelper do | 1 | describe NavigationHelper do |
4 | describe '#page_count_from_end' do | 2 | describe '#page_count_from_end' do |
5 | it 'returns the page number when counting from the last occurrence of a notice' do | 3 | it 'returns the page number when counting from the last occurrence of a notice' do |
spec/helpers/problems_helper_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | describe ProblemsHelper do | 1 | describe ProblemsHelper do |
4 | describe '#truncated_problem_message' do | 2 | describe '#truncated_problem_message' do |
5 | it 'is html safe' do | 3 | it 'is html safe' do |
@@ -24,8 +22,8 @@ describe ProblemsHelper do | @@ -24,8 +22,8 @@ describe ProblemsHelper do | ||
24 | 22 | ||
25 | context "default config" do | 23 | context "default config" do |
26 | before do | 24 | before do |
27 | - Errbit::Config.stub(:use_gravatar).and_return(true) | ||
28 | - Errbit::Config.stub(:gravatar_default).and_return('identicon') | 25 | + allow(Errbit::Config).to receive(:use_gravatar).and_return(true) |
26 | + allow(Errbit::Config).to receive(:gravatar_default).and_return('identicon') | ||
29 | end | 27 | end |
30 | 28 | ||
31 | it "should render image_tag with correct alt and src" do | 29 | it "should render image_tag with correct alt and src" do |
@@ -69,7 +67,7 @@ describe ProblemsHelper do | @@ -69,7 +67,7 @@ describe ProblemsHelper do | ||
69 | let(:email_hash) { Digest::MD5.hexdigest email } | 67 | let(:email_hash) { Digest::MD5.hexdigest email } |
70 | 68 | ||
71 | it "should return the http url" do | 69 | it "should return the http url" do |
72 | - ActionController::TestRequest.any_instance.stub :ssl? => true | 70 | + allow(controller.request).to receive(:ssl?).and_return(true) |
73 | expect(helper.gravatar_url(email)).to eq("https://secure.gravatar.com/avatar/#{email_hash}?d=identicon") | 71 | expect(helper.gravatar_url(email)).to eq("https://secure.gravatar.com/avatar/#{email_hash}?d=identicon") |
74 | end | 72 | end |
75 | end | 73 | end |
spec/interactors/problem_destroy_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | describe ProblemDestroy do | 1 | describe ProblemDestroy do |
4 | let(:problem_destroy) { | 2 | let(:problem_destroy) { |
5 | ProblemDestroy.new(problem) | 3 | ProblemDestroy.new(problem) |
@@ -8,9 +6,9 @@ describe ProblemDestroy do | @@ -8,9 +6,9 @@ describe ProblemDestroy do | ||
8 | context "in unit way" do | 6 | context "in unit way" do |
9 | let(:problem) { | 7 | let(:problem) { |
10 | problem = Problem.new | 8 | problem = Problem.new |
11 | - problem.stub(:errs).and_return(double(:criteria, :only => [err_1, err_2])) | ||
12 | - problem.stub(:comments).and_return(double(:criteria, :only => [comment_1, comment_2])) | ||
13 | - problem.stub(:delete) | 9 | + allow(problem).to receive(:errs).and_return(double(:criteria, :only => [err_1, err_2])) |
10 | + allow(problem).to receive(:comments).and_return(double(:criteria, :only => [comment_1, comment_2])) | ||
11 | + allow(problem).to receive(:delete) | ||
14 | problem | 12 | problem |
15 | } | 13 | } |
16 | let(:err_1) { Err.new } | 14 | let(:err_1) { Err.new } |
@@ -73,5 +71,4 @@ describe ProblemDestroy do | @@ -73,5 +71,4 @@ describe ProblemDestroy do | ||
73 | expect(Notice.where(:_id => notice_2_2.id).entries).to be_empty | 71 | expect(Notice.where(:_id => notice_2_2.id).entries).to be_empty |
74 | end | 72 | end |
75 | end | 73 | end |
76 | - | ||
77 | end | 74 | end |
spec/interactors/problem_merge_spec.rb
spec/interactors/problem_updater_cache_spec.rb
spec/interactors/resolved_problem_clearer_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | describe ResolvedProblemClearer do | 1 | describe ResolvedProblemClearer do |
4 | let(:resolved_problem_clearer) { | 2 | let(:resolved_problem_clearer) { |
5 | ResolvedProblemClearer.new | 3 | ResolvedProblemClearer.new |
@@ -21,7 +19,7 @@ describe ResolvedProblemClearer do | @@ -21,7 +19,7 @@ describe ResolvedProblemClearer do | ||
21 | } | 19 | } |
22 | end | 20 | end |
23 | it 'not repair database' do | 21 | it 'not repair database' do |
24 | - Mongoid.default_session.stub(:command).and_call_original | 22 | + allow(Mongoid.default_session).to receive(:command).and_call_original |
25 | expect(Mongoid.default_session).to_not receive(:command).with({:repairDatabase => 1}) | 23 | expect(Mongoid.default_session).to_not receive(:command).with({:repairDatabase => 1}) |
26 | resolved_problem_clearer.execute | 24 | resolved_problem_clearer.execute |
27 | end | 25 | end |
@@ -29,8 +27,8 @@ describe ResolvedProblemClearer do | @@ -29,8 +27,8 @@ describe ResolvedProblemClearer do | ||
29 | 27 | ||
30 | context "with problem resolve" do | 28 | context "with problem resolve" do |
31 | before do | 29 | before do |
32 | - Mongoid.default_session.stub(:command).and_call_original | ||
33 | - Mongoid.default_session.stub(:command).with({:repairDatabase => 1}) | 30 | + allow(Mongoid.default_session).to receive(:command).and_call_original |
31 | + allow(Mongoid.default_session).to receive(:command).with({:repairDatabase => 1}) | ||
34 | problems.first.resolve! | 32 | problems.first.resolve! |
35 | problems.second.resolve! | 33 | problems.second.resolve! |
36 | end | 34 | end |
@@ -46,7 +44,6 @@ describe ResolvedProblemClearer do | @@ -46,7 +44,6 @@ describe ResolvedProblemClearer do | ||
46 | end | 44 | end |
47 | 45 | ||
48 | it 'repair database' do | 46 | it 'repair database' do |
49 | - Mongoid.default_session.stub(:command).and_call_original | ||
50 | expect(Mongoid.default_session).to receive(:command).with({:repairDatabase => 1}) | 47 | expect(Mongoid.default_session).to receive(:command).with({:repairDatabase => 1}) |
51 | resolved_problem_clearer.execute | 48 | resolved_problem_clearer.execute |
52 | end | 49 | end |
spec/interactors/user_destroy_spec.rb
spec/mailers/mailer_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | shared_examples "a notification email" do | 1 | shared_examples "a notification email" do |
4 | it "should have X-Mailer header" do | 2 | it "should have X-Mailer header" do |
5 | expect(@email).to have_header('X-Mailer', 'Errbit') | 3 | expect(@email).to have_header('X-Mailer', 'Errbit') |
@@ -36,6 +34,7 @@ describe Mailer do | @@ -36,6 +34,7 @@ describe Mailer do | ||
36 | let!(:user) { Fabricate(:admin) } | 34 | let!(:user) { Fabricate(:admin) } |
37 | 35 | ||
38 | before do | 36 | before do |
37 | + ActionMailer::Base.deliveries = [] | ||
39 | notice.backtrace.lines.last.update_attributes(:file => "[PROJECT_ROOT]/path/to/file.js") | 38 | notice.backtrace.lines.last.update_attributes(:file => "[PROJECT_ROOT]/path/to/file.js") |
40 | notice.app.update_attributes( | 39 | notice.app.update_attributes( |
41 | :asset_host => "http://example.com", | 40 | :asset_host => "http://example.com", |
@@ -78,12 +77,12 @@ describe Mailer do | @@ -78,12 +77,12 @@ describe Mailer do | ||
78 | include EmailSpec::Matchers | 77 | include EmailSpec::Matchers |
79 | 78 | ||
80 | let!(:notice) { Fabricate(:notice) } | 79 | let!(:notice) { Fabricate(:notice) } |
81 | - let!(:comment) { Fabricate.build(:comment, :err => notice.problem) } | 80 | + let!(:comment) { Fabricate(:comment, :err => notice.problem) } |
82 | let!(:watcher) { Fabricate(:watcher, :app => comment.app) } | 81 | let!(:watcher) { Fabricate(:watcher, :app => comment.app) } |
83 | let(:recipients) { ['recipient@example.com', 'another@example.com']} | 82 | let(:recipients) { ['recipient@example.com', 'another@example.com']} |
84 | 83 | ||
85 | before do | 84 | before do |
86 | - comment.stub(:notification_recipients).and_return(recipients) | 85 | + expect(comment).to receive(:notification_recipients).and_return(recipients) |
87 | Fabricate(:notice, :err => notice.err) | 86 | Fabricate(:notice, :err => notice.err) |
88 | @email = Mailer.comment_notification(comment).deliver | 87 | @email = Mailer.comment_notification(comment).deliver |
89 | end | 88 | end |
spec/models/app_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe App do | ||
4 | - | 1 | +describe App, type: 'model' do |
5 | context "Attributes" do | 2 | context "Attributes" do |
6 | it { should have_field(:_id).of_type(String) } | 3 | it { should have_field(:_id).of_type(String) } |
7 | it { should have_field(:name).of_type(String) } | 4 | it { should have_field(:name).of_type(String) } |
@@ -112,12 +109,12 @@ describe App do | @@ -112,12 +109,12 @@ describe App do | ||
112 | context '#github_repo?' do | 109 | context '#github_repo?' do |
113 | it 'is true when there is a github_repo' do | 110 | it 'is true when there is a github_repo' do |
114 | app = Fabricate(:app, :github_repo => "errbit/errbit") | 111 | app = Fabricate(:app, :github_repo => "errbit/errbit") |
115 | - expect(app.github_repo?).to be_true | 112 | + expect(app.github_repo?).to be(true) |
116 | end | 113 | end |
117 | 114 | ||
118 | it 'is false when no github_repo' do | 115 | it 'is false when no github_repo' do |
119 | app = Fabricate(:app) | 116 | app = Fabricate(:app) |
120 | - expect(app.github_repo?).to be_false | 117 | + expect(app.github_repo?).to be(false) |
121 | end | 118 | end |
122 | end | 119 | end |
123 | 120 | ||
@@ -137,19 +134,19 @@ describe App do | @@ -137,19 +134,19 @@ describe App do | ||
137 | it "should be true if notify on errs and there are notification recipients" do | 134 | it "should be true if notify on errs and there are notification recipients" do |
138 | app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) | 135 | app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) |
139 | 2.times { Fabricate(:watcher, :app => app) } | 136 | 2.times { Fabricate(:watcher, :app => app) } |
140 | - expect(app.emailable?).to be_true | 137 | + expect(app.emailable?).to be(true) |
141 | end | 138 | end |
142 | 139 | ||
143 | it "should be false if notify on errs is disabled" do | 140 | it "should be false if notify on errs is disabled" do |
144 | app = Fabricate(:app, :notify_on_errs => false, :notify_all_users => false) | 141 | app = Fabricate(:app, :notify_on_errs => false, :notify_all_users => false) |
145 | 2.times { Fabricate(:watcher, :app => app) } | 142 | 2.times { Fabricate(:watcher, :app => app) } |
146 | - expect(app.emailable?).to be_false | 143 | + expect(app.emailable?).to be(false) |
147 | end | 144 | end |
148 | 145 | ||
149 | it "should be false if there are no notification recipients" do | 146 | it "should be false if there are no notification recipients" do |
150 | app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) | 147 | app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) |
151 | expect(app.watchers).to be_empty | 148 | expect(app.watchers).to be_empty |
152 | - expect(app.emailable?).to be_false | 149 | + expect(app.emailable?).to be(false) |
153 | end | 150 | end |
154 | end | 151 | end |
155 | 152 |
spec/models/backtrace_line_normalizer_spec.rb
spec/models/backtrace_line_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe BacktraceLine do | 1 | +describe BacktraceLine, type: 'model' do |
4 | subject { described_class.new(raw_line) } | 2 | subject { described_class.new(raw_line) } |
5 | 3 | ||
6 | describe "root at the start of decorated filename" do | 4 | describe "root at the start of decorated filename" do |
spec/models/backtrace_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Backtrace do | 1 | +describe Backtrace, type: 'model' do |
4 | subject { described_class.new } | 2 | subject { described_class.new } |
5 | 3 | ||
6 | its(:fingerprint) { should be_present } | 4 | its(:fingerprint) { should be_present } |
@@ -19,7 +17,7 @@ describe Backtrace do | @@ -19,7 +17,7 @@ describe Backtrace do | ||
19 | } | 17 | } |
20 | let(:fingerprint) { "fingerprint" } | 18 | let(:fingerprint) { "fingerprint" } |
21 | 19 | ||
22 | - before { subject.stub(:fingerprint => fingerprint) } | 20 | + before { allow(subject).to receive(:fingerprint).and_return(fingerprint) } |
23 | 21 | ||
24 | its(:similar) { should == similar_backtrace } | 22 | its(:similar) { should == similar_backtrace } |
25 | end | 23 | end |
@@ -30,10 +28,10 @@ describe Backtrace do | @@ -30,10 +28,10 @@ describe Backtrace do | ||
30 | let(:attributes) { double :attributes } | 28 | let(:attributes) { double :attributes } |
31 | let(:backtrace) { double :backtrace } | 29 | let(:backtrace) { double :backtrace } |
32 | 30 | ||
33 | - before { described_class.stub(:new => backtrace) } | 31 | + before { allow(described_class).to receive(:new).and_return(backtrace) } |
34 | 32 | ||
35 | context "no similar backtrace" do | 33 | context "no similar backtrace" do |
36 | - before { backtrace.stub(:similar => nil) } | 34 | + before { allow(backtrace).to receive(:similar).and_return(nil) } |
37 | it "create new backtrace" do | 35 | it "create new backtrace" do |
38 | expect(described_class).to receive(:create).with(attributes) | 36 | expect(described_class).to receive(:create).with(attributes) |
39 | 37 | ||
@@ -43,7 +41,7 @@ describe Backtrace do | @@ -43,7 +41,7 @@ describe Backtrace do | ||
43 | 41 | ||
44 | context "similar backtrace exist" do | 42 | context "similar backtrace exist" do |
45 | let(:similar_backtrace) { double :similar_backtrace } | 43 | let(:similar_backtrace) { double :similar_backtrace } |
46 | - before { backtrace.stub(:similar => similar_backtrace) } | 44 | + before { allow(backtrace).to receive(:similar).and_return(similar_backtrace) } |
47 | 45 | ||
48 | it { should == similar_backtrace } | 46 | it { should == similar_backtrace } |
49 | end | 47 | end |
spec/models/comment_observer_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "Callback on Comment" do | 1 | +describe "Callback on Comment", type: 'model' do |
4 | context 'when a Comment is saved' do | 2 | context 'when a Comment is saved' do |
5 | let(:comment) { Fabricate.build(:comment) } | 3 | let(:comment) { Fabricate.build(:comment) } |
6 | 4 | ||
7 | context 'and it is emailable?' do | 5 | context 'and it is emailable?' do |
8 | - before { comment.stub(:emailable?).and_return(true) } | 6 | + before { allow(comment).to receive(:emailable?).and_return(true) } |
9 | 7 | ||
10 | it 'should send an email notification' do | 8 | it 'should send an email notification' do |
11 | expect(Mailer).to receive(:comment_notification). | 9 | expect(Mailer).to receive(:comment_notification). |
@@ -16,7 +14,7 @@ describe "Callback on Comment" do | @@ -16,7 +14,7 @@ describe "Callback on Comment" do | ||
16 | end | 14 | end |
17 | 15 | ||
18 | context 'and it is not emailable?' do | 16 | context 'and it is not emailable?' do |
19 | - before { comment.stub(:emailable?).and_return(false) } | 17 | + before { allow(comment).to receive(:emailable?).and_return(false) } |
20 | 18 | ||
21 | it 'should not send an email notification' do | 19 | it 'should not send an email notification' do |
22 | expect(Mailer).to_not receive(:comment_notification) | 20 | expect(Mailer).to_not receive(:comment_notification) |
spec/models/comment_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Comment do | 1 | +describe Comment, type: 'model' do |
4 | context 'validations' do | 2 | context 'validations' do |
5 | it 'should require a body' do | 3 | it 'should require a body' do |
6 | comment = Fabricate.build(:comment, :body => nil) | 4 | comment = Fabricate.build(:comment, :body => nil) |
@@ -37,19 +35,19 @@ describe Comment do | @@ -37,19 +35,19 @@ describe Comment do | ||
37 | end | 35 | end |
38 | 36 | ||
39 | it 'should be true if app is emailable? and there are notification recipients' do | 37 | it 'should be true if app is emailable? and there are notification recipients' do |
40 | - expect(comment.emailable?).to be_true | 38 | + expect(comment.emailable?).to be(true) |
41 | end | 39 | end |
42 | 40 | ||
43 | it 'should be false if app is not emailable?' do | 41 | it 'should be false if app is not emailable?' do |
44 | app.update_attribute(:notify_on_errs, false) | 42 | app.update_attribute(:notify_on_errs, false) |
45 | expect(comment.notification_recipients).to be_any | 43 | expect(comment.notification_recipients).to be_any |
46 | - expect(comment.emailable?).to be_false | 44 | + expect(comment.emailable?).to be(false) |
47 | end | 45 | end |
48 | 46 | ||
49 | it 'should be false if there are no notification recipients' do | 47 | it 'should be false if there are no notification recipients' do |
50 | watcher.destroy | 48 | watcher.destroy |
51 | - expect(app.emailable?).to be_true | ||
52 | - expect(comment.emailable?).to be_false | 49 | + expect(app.emailable?).to be(true) |
50 | + expect(comment.emailable?).to be(false) | ||
53 | end | 51 | end |
54 | end | 52 | end |
55 | end | 53 | end |
spec/models/deploy_observer_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "Callback on Deploy" do | 1 | +describe "Callback on Deploy", type: 'model' do |
4 | context 'when a Deploy is saved' do | 2 | context 'when a Deploy is saved' do |
5 | context 'and the app should notify on deploys' do | 3 | context 'and the app should notify on deploys' do |
6 | it 'should send an email notification' do | 4 | it 'should send an email notification' do |
spec/models/deploy_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Deploy do | ||
4 | - | 1 | +describe Deploy, type: 'model' do |
5 | context 'validations' do | 2 | context 'validations' do |
6 | it 'requires a username' do | 3 | it 'requires a username' do |
7 | deploy = Fabricate.build(:deploy, :username => nil) | 4 | deploy = Fabricate.build(:deploy, :username => nil) |
@@ -36,7 +33,6 @@ describe Deploy do | @@ -36,7 +33,6 @@ describe Deploy do | ||
36 | expect(@staging_errs.all?{|problem| problem.reload.resolved?}).to eq false | 33 | expect(@staging_errs.all?{|problem| problem.reload.resolved?}).to eq false |
37 | end | 34 | end |
38 | end | 35 | end |
39 | - | ||
40 | end | 36 | end |
41 | 37 | ||
42 | it "should produce a shortened revision with 7 characters" do | 38 | it "should produce a shortened revision with 7 characters" do |
spec/models/err_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Err do | ||
4 | - | 1 | +describe Err, type: 'model' do |
5 | context 'validations' do | 2 | context 'validations' do |
6 | it 'requires a fingerprint' do | 3 | it 'requires a fingerprint' do |
7 | err = Fabricate.build(:err, :fingerprint => nil) | 4 | err = Fabricate.build(:err, :fingerprint => nil) |
@@ -15,5 +12,4 @@ describe Err do | @@ -15,5 +12,4 @@ describe Err do | ||
15 | expect(err.errors[:problem_id]).to include("can't be blank") | 12 | expect(err.errors[:problem_id]).to include("can't be blank") |
16 | end | 13 | end |
17 | end | 14 | end |
18 | - | ||
19 | end | 15 | end |
spec/models/error_report_spec.rb
1 | -require 'spec_helper' | ||
2 | require 'airbrake/version' | 1 | require 'airbrake/version' |
3 | require 'airbrake/backtrace' | 2 | require 'airbrake/backtrace' |
4 | require 'airbrake/notice' | 3 | require 'airbrake/notice' |
@@ -41,22 +40,22 @@ describe ErrorReport do | @@ -41,22 +40,22 @@ describe ErrorReport do | ||
41 | end | 40 | end |
42 | 41 | ||
43 | describe "#backtrace" do | 42 | describe "#backtrace" do |
44 | - | ||
45 | it 'should have valid backtrace' do | 43 | it 'should have valid backtrace' do |
46 | expect(error_report.backtrace).to be_valid | 44 | expect(error_report.backtrace).to be_valid |
47 | end | 45 | end |
48 | end | 46 | end |
49 | 47 | ||
50 | describe "#fingerprint_strategy" do | 48 | describe "#fingerprint_strategy" do |
51 | - after(:all) { | ||
52 | - error_report.fingerprint_strategy = Fingerprint::Sha1 | ||
53 | - } | ||
54 | - | ||
55 | it "should be possible to change how fingerprints are generated" do | 49 | it "should be possible to change how fingerprints are generated" do |
56 | - strategy = double() | ||
57 | - strategy.should_receive(:generate){ 'fingerprints' } | ||
58 | - error_report.fingerprint_strategy = strategy | ||
59 | - error_report.generate_notice! | 50 | + def error_report.fingerprint_strategy |
51 | + Class.new do | ||
52 | + def self.generate(*args) | ||
53 | + 'fingerprintzzz' | ||
54 | + end | ||
55 | + end | ||
56 | + end | ||
57 | + | ||
58 | + expect(error_report.error.fingerprint).to eq('fingerprintzzz') | ||
60 | end | 59 | end |
61 | end | 60 | end |
62 | 61 | ||
@@ -68,6 +67,7 @@ describe ErrorReport do | @@ -68,6 +67,7 @@ describe ErrorReport do | ||
68 | app.reload.problems.count | 67 | app.reload.problems.count |
69 | }.by(1) | 68 | }.by(1) |
70 | end | 69 | end |
70 | + | ||
71 | context "with notice generate by Airbrake gem" do | 71 | context "with notice generate by Airbrake gem" do |
72 | let(:xml) { Airbrake::Notice.new( | 72 | let(:xml) { Airbrake::Notice.new( |
73 | :exception => Exception.new, | 73 | :exception => Exception.new, |
@@ -112,73 +112,74 @@ describe ErrorReport do | @@ -112,73 +112,74 @@ describe ErrorReport do | ||
112 | expect(subject.user_attributes['email']).to eq 'mr.bean@example.com' | 112 | expect(subject.user_attributes['email']).to eq 'mr.bean@example.com' |
113 | expect(subject.user_attributes['username']).to eq 'mrbean' | 113 | expect(subject.user_attributes['username']).to eq 'mrbean' |
114 | end | 114 | end |
115 | + | ||
115 | it 'valid env_vars' do | 116 | it 'valid env_vars' do |
116 | - # XML: <var key="SCRIPT_NAME"/> | ||
117 | - expect(subject.env_vars).to have_key('SCRIPT_NAME') | ||
118 | - expect(subject.env_vars['SCRIPT_NAME']).to be_nil # blank ends up nil | ||
119 | - | ||
120 | - # XML representation: | ||
121 | - # <var key="rack.session.options"> | ||
122 | - # <var key="secure">false</var> | ||
123 | - # <var key="httponly">true</var> | ||
124 | - # <var key="path">/</var> | ||
125 | - # <var key="expire_after"/> | ||
126 | - # <var key="domain"/> | ||
127 | - # <var key="id"/> | ||
128 | - # </var> | ||
129 | - expected = { | ||
130 | - 'secure' => 'false', | ||
131 | - 'httponly' => 'true', | ||
132 | - 'path' => '/', | ||
133 | - 'expire_after' => nil, | ||
134 | - 'domain' => nil, | ||
135 | - 'id' => nil | ||
136 | - } | ||
137 | - expect(subject.env_vars).to have_key('rack_session_options') | ||
138 | - expect(subject.env_vars['rack_session_options']).to eql(expected) | ||
139 | - end | 117 | + # XML: <var key="SCRIPT_NAME"/> |
118 | + expect(subject.env_vars).to have_key('SCRIPT_NAME') | ||
119 | + expect(subject.env_vars['SCRIPT_NAME']).to be_nil # blank ends up nil | ||
120 | + | ||
121 | + # XML representation: | ||
122 | + # <var key="rack.session.options"> | ||
123 | + # <var key="secure">false</var> | ||
124 | + # <var key="httponly">true</var> | ||
125 | + # <var key="path">/</var> | ||
126 | + # <var key="expire_after"/> | ||
127 | + # <var key="domain"/> | ||
128 | + # <var key="id"/> | ||
129 | + # </var> | ||
130 | + expected = { | ||
131 | + 'secure' => 'false', | ||
132 | + 'httponly' => 'true', | ||
133 | + 'path' => '/', | ||
134 | + 'expire_after' => nil, | ||
135 | + 'domain' => nil, | ||
136 | + 'id' => nil | ||
137 | + } | ||
138 | + expect(subject.env_vars).to have_key('rack_session_options') | ||
139 | + expect(subject.env_vars['rack_session_options']).to eql(expected) | ||
140 | + end | ||
140 | end | 141 | end |
142 | + end | ||
143 | + | ||
144 | + it 'save a notice assignes to err' do | ||
145 | + error_report.generate_notice! | ||
146 | + expect(error_report.notice.err).to be_a(Err) | ||
147 | + end | ||
141 | 148 | ||
142 | - it 'save a notice assignes to err' do | 149 | + it 'memoize the notice' do |
150 | + expect { | ||
143 | error_report.generate_notice! | 151 | error_report.generate_notice! |
144 | - expect(error_report.notice.err).to be_a(Err) | ||
145 | - end | 152 | + error_report.generate_notice! |
153 | + }.to change { | ||
154 | + Notice.count | ||
155 | + }.by(1) | ||
156 | + end | ||
146 | 157 | ||
147 | - it 'memoize the notice' do | ||
148 | - expect { | ||
149 | - error_report.generate_notice! | ||
150 | - error_report.generate_notice! | ||
151 | - }.to change { | ||
152 | - Notice.count | ||
153 | - }.by(1) | ||
154 | - end | 158 | + it 'find the correct err for the notice' do |
159 | + err = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)) | ||
155 | 160 | ||
156 | - it 'find the correct err for the notice' do | ||
157 | - err = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)) | 161 | + allow(error_report).to receive(:fingerprint).and_return(err.fingerprint) |
158 | 162 | ||
159 | - ErrorReport.any_instance.stub(:fingerprint).and_return(err.fingerprint) | 163 | + expect { |
164 | + error_report.generate_notice! | ||
165 | + }.to change { | ||
166 | + error_report.error.resolved? | ||
167 | + }.from(true).to(false) | ||
168 | + end | ||
160 | 169 | ||
161 | - expect { | ||
162 | - error_report.generate_notice! | ||
163 | - }.to change { | ||
164 | - error_report.error.resolved? | ||
165 | - }.from(true).to(false) | 170 | + context "with notification service configured" do |
171 | + before do | ||
172 | + app.notify_on_errs = true | ||
173 | + app.watchers.build(:email => 'foo@example.com') | ||
174 | + app.save | ||
166 | end | 175 | end |
167 | - | ||
168 | - context "with notification service configured" do | ||
169 | - before do | ||
170 | - app.notify_on_errs = true | ||
171 | - app.watchers.build(:email => 'foo@example.com') | ||
172 | - app.save | ||
173 | - end | ||
174 | - it 'send email' do | ||
175 | - notice = error_report.generate_notice! | ||
176 | - email = ActionMailer::Base.deliveries.last | ||
177 | - expect(email.to).to include(app.watchers.first.email) | ||
178 | - expect(email.subject).to include(notice.message.truncate(50)) | ||
179 | - expect(email.subject).to include("[#{app.name}]") | ||
180 | - expect(email.subject).to include("[#{notice.environment_name}]") | ||
181 | - end | 176 | + it 'send email' do |
177 | + notice = error_report.generate_notice! | ||
178 | + email = ActionMailer::Base.deliveries.last | ||
179 | + expect(email.to).to include(app.watchers.first.email) | ||
180 | + expect(email.subject).to include(notice.message.truncate(50)) | ||
181 | + expect(email.subject).to include("[#{app.name}]") | ||
182 | + expect(email.subject).to include("[#{notice.environment_name}]") | ||
182 | end | 183 | end |
183 | 184 | ||
184 | context "with xml without request section" do | 185 | context "with xml without request section" do |
@@ -270,8 +271,6 @@ describe ErrorReport do | @@ -270,8 +271,6 @@ describe ErrorReport do | ||
270 | expect(error_report.should_keep?).to be false | 271 | expect(error_report.should_keep?).to be false |
271 | end | 272 | end |
272 | end | 273 | end |
273 | - | ||
274 | end | 274 | end |
275 | - | ||
276 | end | 275 | end |
277 | end | 276 | end |
spec/models/fabricators_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | Fabrication::Config.fabricator_path.each do |folder| | 1 | Fabrication::Config.fabricator_path.each do |folder| |
4 | Dir.glob(File.join(Rails.root, folder, '**', '*.rb')).each do |file| | 2 | Dir.glob(File.join(Rails.root, folder, '**', '*.rb')).each do |file| |
5 | require file | 3 | require file |
spec/models/fingerprint/md5_spec.rb
spec/models/fingerprint/sha1_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Fingerprint::Sha1 do | ||
4 | - | 1 | +describe Fingerprint::Sha1, type: 'model' do |
5 | context '#generate' do | 2 | context '#generate' do |
6 | let(:backtrace) { | 3 | let(:backtrace) { |
7 | Backtrace.create(:raw => [ | 4 | Backtrace.create(:raw => [ |
@@ -80,8 +77,5 @@ describe Fingerprint::Sha1 do | @@ -80,8 +77,5 @@ describe Fingerprint::Sha1 do | ||
80 | should eq "#<ActiveSupport::HashWithIndifferentAccess> #<Object>" | 77 | should eq "#<ActiveSupport::HashWithIndifferentAccess> #<Object>" |
81 | end | 78 | end |
82 | end | 79 | end |
83 | - | ||
84 | end | 80 | end |
85 | - | ||
86 | end | 81 | end |
87 | - |
spec/models/issue_spec.rb
1 | -require "spec_helper" | ||
2 | - | ||
3 | -describe Issue do | ||
4 | - | 1 | +describe Issue, type: 'model' do |
5 | subject(:issue) { Issue.new(problem: problem, user: user, title: title, body: body) } | 2 | subject(:issue) { Issue.new(problem: problem, user: user, title: title, body: body) } |
6 | 3 | ||
7 | let(:problem) { notice.problem } | 4 | let(:problem) { notice.problem } |
@@ -33,15 +30,13 @@ describe Issue do | @@ -33,15 +30,13 @@ describe Issue do | ||
33 | context "when has no title" do | 30 | context "when has no title" do |
34 | let(:body) { "barrr" } | 31 | let(:body) { "barrr" } |
35 | 32 | ||
36 | - pending "returns an error" do | ||
37 | - end | 33 | + pending "returns an error" |
38 | end | 34 | end |
39 | 35 | ||
40 | context "when has no body" do | 36 | context "when has no body" do |
41 | let(:title) { "Foo" } | 37 | let(:title) { "Foo" } |
42 | 38 | ||
43 | - pending "returns an error" do | ||
44 | - end | 39 | + pending "returns an error" |
45 | end | 40 | end |
46 | 41 | ||
47 | context "when app has a issue tracker" do | 42 | context "when app has a issue tracker" do |
spec/models/issue_tracker_spec.rb
spec/models/notice_observer_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "Callback on Notice" do | 1 | +describe "Callback on Notice", type: 'model' do |
4 | describe "email notifications (configured individually for each app)" do | 2 | describe "email notifications (configured individually for each app)" do |
5 | custom_thresholds = [2, 4, 8, 16, 32, 64] | 3 | custom_thresholds = [2, 4, 8, 16, 32, 64] |
6 | 4 | ||
@@ -24,7 +22,6 @@ describe "Callback on Notice" do | @@ -24,7 +22,6 @@ describe "Callback on Notice" do | ||
24 | end | 22 | end |
25 | end | 23 | end |
26 | 24 | ||
27 | - | ||
28 | describe "email notifications for a resolved issue" do | 25 | describe "email notifications for a resolved issue" do |
29 | before do | 26 | before do |
30 | Errbit::Config.per_app_email_at_notices = true | 27 | Errbit::Config.per_app_email_at_notices = true |
spec/models/notice_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Notice do | 1 | +describe Notice, type: 'model' do |
4 | context 'validations' do | 2 | context 'validations' do |
5 | it 'requires a backtrace' do | 3 | it 'requires a backtrace' do |
6 | notice = Fabricate.build(:notice, :backtrace => nil) | 4 | notice = Fabricate.build(:notice, :backtrace => nil) |
spec/models/notification_service/campfire_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationService::CampfireService do | 1 | +describe NotificationService::CampfireService, type: 'model' do |
4 | it "it should send a notification to campfire" do | 2 | it "it should send a notification to campfire" do |
5 | # setup | 3 | # setup |
6 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
@@ -9,8 +7,8 @@ describe NotificationService::CampfireService do | @@ -9,8 +7,8 @@ describe NotificationService::CampfireService do | ||
9 | 7 | ||
10 | #campy stubbing | 8 | #campy stubbing |
11 | campy = double('CampfireService') | 9 | campy = double('CampfireService') |
12 | - Campy::Room.stub(:new).and_return(campy) | ||
13 | - campy.stub(:speak) { true } | 10 | + allow(Campy::Room).to receive(:new).and_return(campy) |
11 | + allow(campy).to receive(:speak).and_return(true) | ||
14 | 12 | ||
15 | #assert | 13 | #assert |
16 | expect(campy).to receive(:speak) | 14 | expect(campy).to receive(:speak) |
@@ -18,4 +16,3 @@ describe NotificationService::CampfireService do | @@ -18,4 +16,3 @@ describe NotificationService::CampfireService do | ||
18 | notification_service.create_notification(problem) | 16 | notification_service.create_notification(problem) |
19 | end | 17 | end |
20 | end | 18 | end |
21 | - |
spec/models/notification_service/flowdock_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationServices::FlowdockService do | 1 | +describe NotificationServices::FlowdockService, type: 'model' do |
4 | let(:service) { Fabricate.build(:flowdock_notification_service) } | 2 | let(:service) { Fabricate.build(:flowdock_notification_service) } |
5 | let(:app) { Fabricate(:app, :name => 'App #3') } | 3 | let(:app) { Fabricate(:app, :name => 'App #3') } |
6 | let(:problem) { Fabricate(:problem, :app => app, :message => '<3') } | 4 | let(:problem) { Fabricate(:problem, :app => app, :message => '<3') } |
7 | 5 | ||
8 | it 'sends message in appropriate format' do | 6 | it 'sends message in appropriate format' do |
9 | - Flowdock::Flow.any_instance.should_receive(:push_to_team_inbox) do |*args| | ||
10 | - expect(args.first[:content]).to_not include('<3') | ||
11 | - expect(args.first[:content]).to include('<3') | ||
12 | - | ||
13 | - expect(args.first[:project]).to eq('App3') | 7 | + allow_any_instance_of(Flowdock::Flow).to receive(:push_to_team_inbox) do |*args| |
8 | + expect(args[1][:content]).to_not include('<3') | ||
9 | + expect(args[1][:content]).to include('<3') | ||
10 | + expect(args[1][:project]).to eq('App3') | ||
14 | end | 11 | end |
12 | + | ||
15 | service.create_notification(problem) | 13 | service.create_notification(problem) |
16 | end | 14 | end |
17 | end | 15 | end |
spec/models/notification_service/gtalk_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationService::GtalkService do | 1 | +describe NotificationService::GtalkService, type: 'model' do |
4 | it "it should send a notification to gtalk" do | 2 | it "it should send a notification to gtalk" do |
5 | # setup | 3 | # setup |
6 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
@@ -47,8 +45,8 @@ describe NotificationService::GtalkService do | @@ -47,8 +45,8 @@ describe NotificationService::GtalkService do | ||
47 | expect(@gtalk).to receive(:connect) | 45 | expect(@gtalk).to receive(:connect) |
48 | expect(@gtalk).to receive(:auth) | 46 | expect(@gtalk).to receive(:auth) |
49 | jid = double("jid") | 47 | jid = double("jid") |
50 | - Jabber::JID.stub(:new).with(@notification_service.subdomain).and_return(jid) | ||
51 | - Jabber::Client.stub(:new).with(jid).and_return(@gtalk) | 48 | + allow(Jabber::JID).to receive(:new).with(@notification_service.subdomain).and_return(jid) |
49 | + allow(Jabber::Client).to receive(:new).with(jid).and_return(@gtalk) | ||
52 | end | 50 | end |
53 | it "should send a notification to all ',' separated users" do | 51 | it "should send a notification to all ',' separated users" do |
54 | expect(Jabber::Message).to receive(:new).with("first@domain.org", @error_msg) | 52 | expect(Jabber::Message).to receive(:new).with("first@domain.org", @error_msg) |
@@ -120,6 +118,4 @@ describe NotificationService::GtalkService do | @@ -120,6 +118,4 @@ describe NotificationService::GtalkService do | ||
120 | 118 | ||
121 | notification_service.create_notification(problem) | 119 | notification_service.create_notification(problem) |
122 | end | 120 | end |
123 | - | ||
124 | end | 121 | end |
125 | - |
spec/models/notification_service/hipchat_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationServices::HipchatService do | 1 | +describe NotificationServices::HipchatService, type: 'model' do |
4 | let(:service) { Fabricate.build(:hipchat_notification_service) } | 2 | let(:service) { Fabricate.build(:hipchat_notification_service) } |
5 | let(:problem) { Fabricate(:problem) } | 3 | let(:problem) { Fabricate(:problem) } |
6 | let(:room) { double } | 4 | let(:room) { double } |
7 | 5 | ||
8 | before do | 6 | before do |
9 | - HipChat::Client.any_instance.stub(:[] => room) | 7 | + allow_any_instance_of(HipChat::Client).to receive(:[]).and_return(room) |
10 | end | 8 | end |
11 | 9 | ||
12 | it 'sends message' do | 10 | it 'sends message' do |
@@ -15,7 +13,7 @@ describe NotificationServices::HipchatService do | @@ -15,7 +13,7 @@ describe NotificationServices::HipchatService do | ||
15 | end | 13 | end |
16 | 14 | ||
17 | it 'escapes html in message' do | 15 | it 'escapes html in message' do |
18 | - problem.stub(:message => '<3') | 16 | + allow(problem).to receive(:message).and_return('<3') |
19 | expect(room).to receive(:send) do |_, message| | 17 | expect(room).to receive(:send) do |_, message| |
20 | expect(message).to_not include('<3') | 18 | expect(message).to_not include('<3') |
21 | expect(message).to include('<3') | 19 | expect(message).to include('<3') |
spec/models/notification_service/hoiio_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationService::HoiioService do | 1 | +describe NotificationService::HoiioService, type: 'model' do |
4 | it "it should send a notification to hoiio" do | 2 | it "it should send a notification to hoiio" do |
5 | # setup | 3 | # setup |
6 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
@@ -9,8 +7,8 @@ describe NotificationService::HoiioService do | @@ -9,8 +7,8 @@ describe NotificationService::HoiioService do | ||
9 | 7 | ||
10 | # hoi stubbing | 8 | # hoi stubbing |
11 | sms = double('HoiioService') | 9 | sms = double('HoiioService') |
12 | - Hoi::SMS.stub(:new).and_return(sms) | ||
13 | - sms.stub(:send) { true } | 10 | + allow(Hoi::SMS).to receive(:new).and_return(sms) |
11 | + allow(sms).to receive(:send).and_return(true) | ||
14 | 12 | ||
15 | #assert | 13 | #assert |
16 | expect(sms).to receive(:send) | 14 | expect(sms).to receive(:send) |
@@ -18,4 +16,3 @@ describe NotificationService::HoiioService do | @@ -18,4 +16,3 @@ describe NotificationService::HoiioService do | ||
18 | notification_service.create_notification(problem) | 16 | notification_service.create_notification(problem) |
19 | end | 17 | end |
20 | end | 18 | end |
21 | - |
spec/models/notification_service/hubot_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationService::HubotService do | 1 | +describe NotificationService::HubotService, type: 'model' do |
4 | it "it should send a notification to Hubot" do | 2 | it "it should send a notification to Hubot" do |
5 | # setup | 3 | # setup |
6 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
spec/models/notification_service/notification_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationService do | 1 | +describe NotificationService, type: 'model' do |
4 | 2 | ||
5 | let(:notice) { Fabricate :notice } | 3 | let(:notice) { Fabricate :notice } |
6 | let(:notification_service) { Fabricate :notification_service, :app => notice.app } | 4 | let(:notification_service) { Fabricate :notification_service, :app => notice.app } |
7 | let(:problem) { notice.problem } | 5 | let(:problem) { notice.problem } |
8 | 6 | ||
9 | it "it should use http by default in #problem_url" do | 7 | it "it should use http by default in #problem_url" do |
10 | - notification_service.problem_url(problem).should start_with 'http://' | 8 | + expect(notification_service.problem_url(problem)).to start_with 'http://' |
11 | end | 9 | end |
12 | 10 | ||
13 | it "it should use the protocol value specified in the config in #problem_url" do | 11 | it "it should use the protocol value specified in the config in #problem_url" do |
14 | Errbit::Config.protocol = 'https' | 12 | Errbit::Config.protocol = 'https' |
15 | - notification_service.problem_url(problem).should start_with 'https://' | 13 | + expect(notification_service.problem_url(problem)).to start_with 'https://' |
16 | end | 14 | end |
17 | - | ||
18 | end | 15 | end |
spec/models/notification_service/pushover_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationService::PushoverService do | 1 | +describe NotificationService::PushoverService, type: 'model' do |
4 | it "it should send a notification to Pushover" do | 2 | it "it should send a notification to Pushover" do |
5 | # setup | 3 | # setup |
6 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
@@ -9,8 +7,8 @@ describe NotificationService::PushoverService do | @@ -9,8 +7,8 @@ describe NotificationService::PushoverService do | ||
9 | 7 | ||
10 | # hoi stubbing | 8 | # hoi stubbing |
11 | notification = double('PushoverService') | 9 | notification = double('PushoverService') |
12 | - Rushover::Client.stub(:new).and_return(notification) | ||
13 | - notification.stub(:notify) { true } | 10 | + allow(Rushover::Client).to receive(:new).and_return(notification) |
11 | + allow(notification).to receive(:notify).and_return(true) | ||
14 | 12 | ||
15 | #assert | 13 | #assert |
16 | expect(notification).to receive(:notify) | 14 | expect(notification).to receive(:notify) |
spec/models/notification_service/slack_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationService::SlackService do | 1 | +describe NotificationService::SlackService, type: 'model' do |
4 | it "it should send a notification to Slack with channel" do | 2 | it "it should send a notification to Slack with channel" do |
5 | # setup | 3 | # setup |
6 | notice = Fabricate :notice | 4 | notice = Fabricate :notice |
spec/models/notification_service/webhook_service_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe NotificationService::WebhookService do | 1 | +describe NotificationService::WebhookService, type: 'model' do |
4 | it "it should send a notification to a user-specified URL" do | 2 | it "it should send a notification to a user-specified URL" do |
5 | notice = Fabricate :notice | 3 | notice = Fabricate :notice |
6 | notification_service = Fabricate :webhook_notification_service, :app => notice.app | 4 | notification_service = Fabricate :webhook_notification_service, :app => notice.app |
7 | problem = notice.problem | 5 | problem = notice.problem |
8 | - | 6 | + |
9 | expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => {:problem => problem.to_json}).and_return(true) | 7 | expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => {:problem => problem.to_json}).and_return(true) |
10 | 8 | ||
11 | notification_service.create_notification(problem) | 9 | notification_service.create_notification(problem) |
spec/models/problem_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Problem do | ||
4 | - | 1 | +describe Problem, type: 'model' do |
5 | context 'validations' do | 2 | context 'validations' do |
6 | it 'requires an environment' do | 3 | it 'requires an environment' do |
7 | err = Fabricate.build(:problem, :environment => nil) | 4 | err = Fabricate.build(:problem, :environment => nil) |
@@ -59,7 +56,7 @@ describe Problem do | @@ -59,7 +56,7 @@ describe Problem do | ||
59 | notice1 = Fabricate(:notice, :err => err) | 56 | notice1 = Fabricate(:notice, :err => err) |
60 | expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) | 57 | expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) |
61 | 58 | ||
62 | - notice2 = Fabricate(:notice, :err => err) | 59 | + Fabricate(:notice, :err => err) |
63 | expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) | 60 | expect(problem.first_notice_at.to_i).to be_within(1).of(notice1.created_at.to_i) |
64 | end | 61 | end |
65 | end | 62 | end |
@@ -128,12 +125,12 @@ describe Problem do | @@ -128,12 +125,12 @@ describe Problem do | ||
128 | it "should throw an err if it's not successful" do | 125 | it "should throw an err if it's not successful" do |
129 | problem = Fabricate(:problem) | 126 | problem = Fabricate(:problem) |
130 | expect(problem).to_not be_resolved | 127 | expect(problem).to_not be_resolved |
131 | - problem.stub(:valid?).and_return(false) | 128 | + allow(problem).to receive(:valid?).and_return(false) |
132 | ## update_attributes not test #valid? but #errors.any? | 129 | ## update_attributes not test #valid? but #errors.any? |
133 | # https://github.com/mongoid/mongoid/blob/master/lib/mongoid/persistence.rb#L137 | 130 | # https://github.com/mongoid/mongoid/blob/master/lib/mongoid/persistence.rb#L137 |
134 | er = ActiveModel::Errors.new(problem) | 131 | er = ActiveModel::Errors.new(problem) |
135 | er.add_on_blank(:resolved) | 132 | er.add_on_blank(:resolved) |
136 | - problem.stub(:errors).and_return(er) | 133 | + allow(problem).to receive(:errors).and_return(er) |
137 | expect(problem).to_not be_valid | 134 | expect(problem).to_not be_valid |
138 | expect { | 135 | expect { |
139 | problem.resolve! | 136 | problem.resolve! |
@@ -210,7 +207,7 @@ describe Problem do | @@ -210,7 +207,7 @@ describe Problem do | ||
210 | end | 207 | end |
211 | 208 | ||
212 | it "removing a notice decreases #notices_count by 1" do | 209 | it "removing a notice decreases #notices_count by 1" do |
213 | - notice1 = Fabricate(:notice, :err => @err, :message => 'ERR 1') | 210 | + Fabricate(:notice, :err => @err, :message => 'ERR 1') |
214 | expect { | 211 | expect { |
215 | @err.notices.first.destroy | 212 | @err.notices.first.destroy |
216 | @problem.reload | 213 | @problem.reload |
@@ -240,7 +237,7 @@ describe Problem do | @@ -240,7 +237,7 @@ describe Problem do | ||
240 | before do | 237 | before do |
241 | @app = Fabricate(:app) | 238 | @app = Fabricate(:app) |
242 | @last_deploy = Time.at(10.days.ago.localtime.to_i) | 239 | @last_deploy = Time.at(10.days.ago.localtime.to_i) |
243 | - deploy = Fabricate(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") | 240 | + Fabricate(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") |
244 | end | 241 | end |
245 | 242 | ||
246 | it "is set when a problem is created" do | 243 | it "is set when a problem is created" do |
@@ -276,7 +273,7 @@ describe Problem do | @@ -276,7 +273,7 @@ describe Problem do | ||
276 | end | 273 | end |
277 | 274 | ||
278 | it "removing a notice removes string from #messages" do | 275 | it "removing a notice removes string from #messages" do |
279 | - notice1 = Fabricate(:notice, :err => @err, :message => 'ERR 1') | 276 | + Fabricate(:notice, :err => @err, :message => 'ERR 1') |
280 | expect { | 277 | expect { |
281 | @err.notices.first.destroy | 278 | @err.notices.first.destroy |
282 | @problem.reload | 279 | @problem.reload |
@@ -284,7 +281,7 @@ describe Problem do | @@ -284,7 +281,7 @@ describe Problem do | ||
284 | end | 281 | end |
285 | 282 | ||
286 | it "removing a notice from the problem with broken counter should not raise an error" do | 283 | it "removing a notice from the problem with broken counter should not raise an error" do |
287 | - notice1 = Fabricate(:notice, :err => @err, :message => 'ERR 1') | 284 | + Fabricate(:notice, :err => @err, :message => 'ERR 1') |
288 | @problem.messages = {} | 285 | @problem.messages = {} |
289 | @problem.save! | 286 | @problem.save! |
290 | expect {@err.notices.first.destroy}.not_to raise_error | 287 | expect {@err.notices.first.destroy}.not_to raise_error |
@@ -309,7 +306,7 @@ describe Problem do | @@ -309,7 +306,7 @@ describe Problem do | ||
309 | end | 306 | end |
310 | 307 | ||
311 | it "removing a notice removes string from #hosts" do | 308 | it "removing a notice removes string from #hosts" do |
312 | - notice1 = Fabricate(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) | 309 | + Fabricate(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) |
313 | expect { | 310 | expect { |
314 | @err.notices.first.destroy | 311 | @err.notices.first.destroy |
315 | @problem.reload | 312 | @problem.reload |
@@ -335,7 +332,7 @@ describe Problem do | @@ -335,7 +332,7 @@ describe Problem do | ||
335 | end | 332 | end |
336 | 333 | ||
337 | it "removing a notice removes string from #user_agents" do | 334 | it "removing a notice removes string from #user_agents" do |
338 | - notice1 = Fabricate(:notice, :err => @err, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) | 335 | + Fabricate(:notice, :err => @err, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) |
339 | expect { | 336 | expect { |
340 | @err.notices.first.destroy | 337 | @err.notices.first.destroy |
341 | @problem.reload | 338 | @problem.reload |
@@ -362,7 +359,7 @@ describe Problem do | @@ -362,7 +359,7 @@ describe Problem do | ||
362 | end | 359 | end |
363 | 360 | ||
364 | it "removing a comment decreases #comments_count by 1" do | 361 | it "removing a comment decreases #comments_count by 1" do |
365 | - comment1 = Fabricate(:comment, :err => @problem) | 362 | + Fabricate(:comment, :err => @problem) |
366 | expect { | 363 | expect { |
367 | @problem.reload.comments.first.destroy | 364 | @problem.reload.comments.first.destroy |
368 | @problem.reload | 365 | @problem.reload |
@@ -418,7 +415,4 @@ describe Problem do | @@ -418,7 +415,4 @@ describe Problem do | ||
418 | end | 415 | end |
419 | end | 416 | end |
420 | end | 417 | end |
421 | - | ||
422 | - | ||
423 | end | 418 | end |
424 | - |
spec/models/user_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | describe User do | 1 | describe User do |
4 | - | ||
5 | context 'validations' do | 2 | context 'validations' do |
6 | it 'require that a name is present' do | 3 | it 'require that a name is present' do |
7 | user = Fabricate.build(:user, :name => nil) | 4 | user = Fabricate.build(:user, :name => nil) |
@@ -41,7 +38,6 @@ describe User do | @@ -41,7 +38,6 @@ describe User do | ||
41 | end | 38 | end |
42 | 39 | ||
43 | context 'Watchers' do | 40 | context 'Watchers' do |
44 | - | ||
45 | it 'has many watchers' do | 41 | it 'has many watchers' do |
46 | user = Fabricate(:user) | 42 | user = Fabricate(:user) |
47 | watcher = Fabricate(:user_watcher, :user => user) | 43 | watcher = Fabricate(:user_watcher, :user => user) |
@@ -53,23 +49,20 @@ describe User do | @@ -53,23 +49,20 @@ describe User do | ||
53 | user = Fabricate(:user) | 49 | user = Fabricate(:user) |
54 | watched_app = Fabricate(:app) | 50 | watched_app = Fabricate(:app) |
55 | unwatched_app = Fabricate(:app) | 51 | unwatched_app = Fabricate(:app) |
56 | - watcher = Fabricate(:user_watcher, :app => watched_app, :user => user) | 52 | + Fabricate(:user_watcher, :app => watched_app, :user => user) |
57 | expect(user.apps.all).to include(watched_app) | 53 | expect(user.apps.all).to include(watched_app) |
58 | expect(user.apps.all).to_not include(unwatched_app) | 54 | expect(user.apps.all).to_not include(unwatched_app) |
59 | end | 55 | end |
60 | - | ||
61 | end | 56 | end |
62 | 57 | ||
63 | context "First user" do | 58 | context "First user" do |
64 | it "should be created this admin access via db:seed" do | 59 | it "should be created this admin access via db:seed" do |
65 | expect { | 60 | expect { |
66 | - $stdout.stub(:puts => true) | 61 | + allow($stdout).to receive(:puts).and_return(true) |
67 | require Rails.root.join('db/seeds.rb') | 62 | require Rails.root.join('db/seeds.rb') |
68 | }.to change { | 63 | }.to change { |
69 | User.where(:admin => true).count | 64 | User.where(:admin => true).count |
70 | }.from(0).to(1) | 65 | }.from(0).to(1) |
71 | end | 66 | end |
72 | end | 67 | end |
73 | - | ||
74 | end | 68 | end |
75 | - |
spec/models/watcher_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe Watcher do | ||
4 | - | 1 | +describe Watcher, type: 'model' do |
5 | context 'validations' do | 2 | context 'validations' do |
6 | it 'requires an email address or an associated user' do | 3 | it 'requires an email address or an associated user' do |
7 | watcher = Fabricate.build(:watcher, :email => nil, :user => nil) | 4 | watcher = Fabricate.build(:watcher, :email => nil, :user => nil) |
@@ -32,6 +29,4 @@ describe Watcher do | @@ -32,6 +29,4 @@ describe Watcher do | ||
32 | expect(watcher.address).to eq 'widgets@acme.com' | 29 | expect(watcher.address).to eq 'widgets@acme.com' |
33 | end | 30 | end |
34 | end | 31 | end |
35 | - | ||
36 | end | 32 | end |
37 | - |
@@ -0,0 +1,38 @@ | @@ -0,0 +1,38 @@ | ||
1 | +# This file is copied to spec/ when you run 'rails generate rspec:install' | ||
2 | +ENV["RAILS_ENV"] ||= 'test' | ||
3 | +require 'spec_helper' | ||
4 | +require File.expand_path("../../config/environment", __FILE__) | ||
5 | +require 'rspec/rails' | ||
6 | +# Add additional requires below this line. Rails is not loaded until this point! | ||
7 | + | ||
8 | +# Requires supporting ruby files with custom matchers and macros, etc, in | ||
9 | +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are | ||
10 | +# run as spec files by default. This means that files in spec/support that end | ||
11 | +# in _spec.rb will both be required and run as specs, causing the specs to be | ||
12 | +# run twice. It is recommended that you do not name files matching this glob to | ||
13 | +# end with _spec.rb. You can configure this pattern with the --pattern | ||
14 | +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. | ||
15 | +# | ||
16 | +# The following line is provided for convenience purposes. It has the downside | ||
17 | +# of increasing the boot-up time by auto-requiring all files in the support | ||
18 | +# directory. Alternatively, in the individual `*_spec.rb` files, manually | ||
19 | +# require only the support files necessary. | ||
20 | +# | ||
21 | +# Dir[Rails.root.join("spec/support/**/*.rb")].each { |f| require f } | ||
22 | + | ||
23 | +RSpec.configure do |config| | ||
24 | + # RSpec Rails can automatically mix in different behaviours to your tests | ||
25 | + # based on their file location, for example enabling you to call `get` and | ||
26 | + # `post` in specs under `spec/controllers`. | ||
27 | + # | ||
28 | + # You can disable this behaviour by removing the line below, and instead | ||
29 | + # explicitly tag your specs with their type, e.g.: | ||
30 | + # | ||
31 | + # RSpec.describe UsersController, :type => :controller do | ||
32 | + # # ... | ||
33 | + # end | ||
34 | + # | ||
35 | + # The different available types are documented in the features, such as in | ||
36 | + # https://relishapp.com/rspec/rspec-rails/docs | ||
37 | + config.infer_spec_type_from_file_location! | ||
38 | +end |
spec/requests/notices_controller_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "Notices management" do | ||
4 | - | ||
5 | - let(:errbit_app) { Fabricate(:app, | ||
6 | - :api_key => 'APIKEY') } | 1 | +describe "Notices management", type: 'request' do |
2 | + let(:errbit_app) { Fabricate(:app, :api_key => 'APIKEY') } | ||
7 | 3 | ||
8 | describe "create a new notice" do | 4 | describe "create a new notice" do |
9 | context "with valide notice" do | 5 | context "with valide notice" do |
@@ -38,11 +34,8 @@ describe "Notices management" do | @@ -38,11 +34,8 @@ describe "Notices management" do | ||
38 | post '/notifier_api/v2/notices', :data => xml | 34 | post '/notifier_api/v2/notices', :data => xml |
39 | expect(response.status).to eq 422 | 35 | expect(response.status).to eq 422 |
40 | expect(response.body).to eq "Your API key is unknown" | 36 | expect(response.body).to eq "Your API key is unknown" |
41 | - }.to_not change { | ||
42 | - errbit_app.problems.count | ||
43 | - }.by(1) | 37 | + }.to_not change(errbit_app.problems, :count) |
44 | end | 38 | end |
45 | - | ||
46 | end | 39 | end |
47 | 40 | ||
48 | context "with GET request" do | 41 | context "with GET request" do |
spec/spec_helper.rb
@@ -19,11 +19,13 @@ end | @@ -19,11 +19,13 @@ end | ||
19 | 19 | ||
20 | require File.expand_path("../../config/environment", __FILE__) | 20 | require File.expand_path("../../config/environment", __FILE__) |
21 | require 'rspec/rails' | 21 | require 'rspec/rails' |
22 | +require 'rspec/its' | ||
22 | require 'email_spec' | 23 | require 'email_spec' |
23 | require 'database_cleaner' | 24 | require 'database_cleaner' |
24 | require 'xmpp4r' | 25 | require 'xmpp4r' |
25 | require 'xmpp4r/muc' | 26 | require 'xmpp4r/muc' |
26 | require 'mongoid-rspec' | 27 | require 'mongoid-rspec' |
28 | +require 'fabrication' | ||
27 | require 'errbit_plugin/mock_issue_tracker' | 29 | require 'errbit_plugin/mock_issue_tracker' |
28 | 30 | ||
29 | # Requires supporting files with custom matchers and macros, etc, | 31 | # Requires supporting files with custom matchers and macros, etc, |
@@ -31,11 +33,8 @@ require 'errbit_plugin/mock_issue_tracker' | @@ -31,11 +33,8 @@ require 'errbit_plugin/mock_issue_tracker' | ||
31 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} | 33 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} |
32 | 34 | ||
33 | RSpec.configure do |config| | 35 | RSpec.configure do |config| |
34 | - config.mock_with :rspec | ||
35 | config.include Devise::TestHelpers, :type => :controller | 36 | config.include Devise::TestHelpers, :type => :controller |
36 | config.include Mongoid::Matchers, :type => :model | 37 | config.include Mongoid::Matchers, :type => :model |
37 | - config.filter_run :focused => true | ||
38 | - config.run_all_when_everything_filtered = true | ||
39 | config.alias_example_to :fit, :focused => true | 38 | config.alias_example_to :fit, :focused => true |
40 | 39 | ||
41 | config.before(:each) do | 40 | config.before(:each) do |
spec/support/macros.rb
@@ -21,13 +21,13 @@ def it_requires_authentication(options = {}) | @@ -21,13 +21,13 @@ def it_requires_authentication(options = {}) | ||
21 | options[:for].each do |action, method| | 21 | options[:for].each do |action, method| |
22 | it "#{method.to_s.upcase} #{action} redirects to the sign in page" do | 22 | it "#{method.to_s.upcase} #{action} redirects to the sign in page" do |
23 | send(method, action, options[:params]) | 23 | send(method, action, options[:params]) |
24 | - response.should redirect_to(new_user_session_path) | 24 | + expect(response).to redirect_to(new_user_session_path) |
25 | end | 25 | end |
26 | end | 26 | end |
27 | end | 27 | end |
28 | end | 28 | end |
29 | 29 | ||
30 | -def it_requires_admin_privileges(options = {}) | 30 | +def it_requires_admin_privileges(options = {}) |
31 | default_options = { | 31 | default_options = { |
32 | :for => { | 32 | :for => { |
33 | :index => :get, | 33 | :index => :get, |
@@ -51,7 +51,7 @@ def it_requires_admin_privileges(options = {}) | @@ -51,7 +51,7 @@ def it_requires_admin_privileges(options = {}) | ||
51 | options[:for].each do |action, method| | 51 | options[:for].each do |action, method| |
52 | it "#{method.to_s.upcase} #{action} redirects to the root path" do | 52 | it "#{method.to_s.upcase} #{action} redirects to the root path" do |
53 | send(method, action, options[:params]) | 53 | send(method, action, options[:params]) |
54 | - response.should redirect_to(root_path) | 54 | + expect(response).to redirect_to(root_path) |
55 | end | 55 | end |
56 | end | 56 | end |
57 | end | 57 | end |
spec/views/apps/edit.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "apps/edit.html.haml" do | 1 | +describe "apps/edit.html.haml", type: 'view' do |
4 | let(:app) { stub_model(App) } | 2 | let(:app) { stub_model(App) } |
5 | let(:app_decorate) { AppDecorator.new(app) } | 3 | let(:app_decorate) { AppDecorator.new(app) } |
4 | + | ||
6 | before do | 5 | before do |
7 | - view.stub(:app).and_return(app) | ||
8 | - view.stub(:app_decorate).and_return(app_decorate) | ||
9 | - controller.stub(:current_user) { stub_model(User) } | 6 | + allow(view).to receive(:app).and_return(app) |
7 | + allow(view).to receive(:app_decorate).and_return(app_decorate) | ||
8 | + allow(controller).to receive(:current_user).and_return(stub_model(User)) | ||
10 | end | 9 | end |
11 | 10 | ||
12 | describe "content_for :action_bar" do | 11 | describe "content_for :action_bar" do |
@@ -23,7 +22,6 @@ describe "apps/edit.html.haml" do | @@ -23,7 +22,6 @@ describe "apps/edit.html.haml" do | ||
23 | render | 22 | render |
24 | expect(action_bar).to have_selector('a.button[data-confirm="%s"]' % I18n.t('apps.confirm_delete')) | 23 | expect(action_bar).to have_selector('a.button[data-confirm="%s"]' % I18n.t('apps.confirm_delete')) |
25 | end | 24 | end |
26 | - | ||
27 | end | 25 | end |
28 | 26 | ||
29 | context "with unvalid app" do | 27 | context "with unvalid app" do |
@@ -38,6 +36,4 @@ describe "apps/edit.html.haml" do | @@ -38,6 +36,4 @@ describe "apps/edit.html.haml" do | ||
38 | expect(rendered).to match(/You must specify your/) | 36 | expect(rendered).to match(/You must specify your/) |
39 | end | 37 | end |
40 | end | 38 | end |
41 | - | ||
42 | end | 39 | end |
43 | - |
spec/views/apps/index.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "apps/index.html.haml" do | 1 | +describe "apps/index.html.haml", type: 'view' do |
4 | before do | 2 | before do |
5 | app = stub_model(App, :deploys => [stub_model(Deploy, :created_at => Time.now, :revision => "123456789abcdef")]) | 3 | app = stub_model(App, :deploys => [stub_model(Deploy, :created_at => Time.now, :revision => "123456789abcdef")]) |
6 | - view.stub(:apps).and_return([app]) | ||
7 | - controller.stub(:current_user) { stub_model(User) } | 4 | + allow(view).to receive(:apps).and_return([app]) |
5 | + allow(controller).to receive(:current_user).and_return(stub_model(User)) | ||
8 | end | 6 | end |
9 | 7 | ||
10 | describe "deploy column" do | 8 | describe "deploy column" do |
@@ -14,4 +12,3 @@ describe "apps/index.html.haml" do | @@ -14,4 +12,3 @@ describe "apps/index.html.haml" do | ||
14 | end | 12 | end |
15 | end | 13 | end |
16 | end | 14 | end |
17 | - |
spec/views/apps/new.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "apps/new.html.haml" do | 1 | +describe "apps/new.html.haml", type: 'view' do |
4 | let(:app) { stub_model(App) } | 2 | let(:app) { stub_model(App) } |
5 | let(:app_decorate) { AppDecorator.new(app) } | 3 | let(:app_decorate) { AppDecorator.new(app) } |
4 | + | ||
6 | before do | 5 | before do |
7 | - view.stub(:app).and_return(app) | ||
8 | - view.stub(:app_decorate).and_return(app_decorate) | ||
9 | - controller.stub(:current_user) { stub_model(User) } | 6 | + allow(view).to receive(:app).and_return(app) |
7 | + allow(view).to receive(:app_decorate).and_return(app_decorate) | ||
8 | + allow(controller).to receive(:current_user).and_return(stub_model(User)) | ||
10 | end | 9 | end |
11 | 10 | ||
12 | describe "content_for :action_bar" do | 11 | describe "content_for :action_bar" do |
@@ -34,6 +33,4 @@ describe "apps/new.html.haml" do | @@ -34,6 +33,4 @@ describe "apps/new.html.haml" do | ||
34 | expect(rendered).to match(/You must specify your/) | 33 | expect(rendered).to match(/You must specify your/) |
35 | end | 34 | end |
36 | end | 35 | end |
37 | - | ||
38 | end | 36 | end |
39 | - |
spec/views/apps/show.atom.builder_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "apps/show.atom.builder" do | 1 | +describe "apps/show.atom.builder", type: 'view' do |
4 | let(:app) { stub_model(App) } | 2 | let(:app) { stub_model(App) } |
5 | let(:problems) { [ | 3 | let(:problems) { [ |
6 | stub_model(Problem, :message => 'foo', :app => app) | 4 | stub_model(Problem, :message => 'foo', :app => app) |
7 | ]} | 5 | ]} |
8 | 6 | ||
9 | before do | 7 | before do |
10 | - view.stub(:app).and_return(app) | ||
11 | - view.stub(:problems).and_return(problems) | 8 | + allow(view).to receive(:app).and_return(app) |
9 | + allow(view).to receive(:problems).and_return(problems) | ||
12 | end | 10 | end |
13 | 11 | ||
14 | context "with errs" do | 12 | context "with errs" do |
@@ -17,5 +15,4 @@ describe "apps/show.atom.builder" do | @@ -17,5 +15,4 @@ describe "apps/show.atom.builder" do | ||
17 | expect(rendered).to match(problems.first.message) | 15 | expect(rendered).to match(problems.first.message) |
18 | end | 16 | end |
19 | end | 17 | end |
20 | - | ||
21 | end | 18 | end |
spec/views/apps/show.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "apps/show.html.haml" do | 1 | +describe "apps/show.html.haml", type: 'view' do |
4 | let(:app) { stub_model(App) } | 2 | let(:app) { stub_model(App) } |
5 | let(:user) { stub_model(User) } | 3 | let(:user) { stub_model(User) } |
6 | 4 | ||
@@ -9,20 +7,18 @@ describe "apps/show.html.haml" do | @@ -9,20 +7,18 @@ describe "apps/show.html.haml" do | ||
9 | end | 7 | end |
10 | 8 | ||
11 | before do | 9 | before do |
12 | - view.stub(:app).and_return(app) | ||
13 | - view.stub(:all_errs).and_return(false) | ||
14 | - view.stub(:deploys).and_return([]) | ||
15 | - controller.stub(:current_user) { user } | 10 | + allow(view).to receive(:app).and_return(app) |
11 | + allow(view).to receive(:all_errs).and_return(false) | ||
12 | + allow(view).to receive(:deploys).and_return([]) | ||
13 | + allow(controller).to receive(:current_user).and_return(user) | ||
16 | end | 14 | end |
17 | 15 | ||
18 | describe "content_for :action_bar" do | 16 | describe "content_for :action_bar" do |
19 | - | ||
20 | it "should confirm the 'cancel' link" do | 17 | it "should confirm the 'cancel' link" do |
21 | render | 18 | render |
22 | 19 | ||
23 | expect(action_bar).to have_selector('a.button', :text => 'all errs') | 20 | expect(action_bar).to have_selector('a.button', :text => 'all errs') |
24 | end | 21 | end |
25 | - | ||
26 | end | 22 | end |
27 | 23 | ||
28 | context "without errs" do | 24 | context "without errs" do |
@@ -34,7 +30,7 @@ describe "apps/show.html.haml" do | @@ -34,7 +30,7 @@ describe "apps/show.html.haml" do | ||
34 | 30 | ||
35 | context "with user watch application" do | 31 | context "with user watch application" do |
36 | before do | 32 | before do |
37 | - user.stub(:watching?).with(app).and_return(true) | 33 | + allow(user).to receive(:watching?).with(app).and_return(true) |
38 | end | 34 | end |
39 | it 'see the unwatch button' do | 35 | it 'see the unwatch button' do |
40 | render | 36 | render |
@@ -44,13 +40,11 @@ describe "apps/show.html.haml" do | @@ -44,13 +40,11 @@ describe "apps/show.html.haml" do | ||
44 | 40 | ||
45 | context "with user not watch application" do | 41 | context "with user not watch application" do |
46 | before do | 42 | before do |
47 | - user.stub(:watching?).with(app).and_return(false) | 43 | + allow(user).to receive(:watching?).with(app).and_return(false) |
48 | end | 44 | end |
49 | it 'not see the unwatch button' do | 45 | it 'not see the unwatch button' do |
50 | render | 46 | render |
51 | expect(action_bar).to_not include(I18n.t('apps.show.unwatch')) | 47 | expect(action_bar).to_not include(I18n.t('apps.show.unwatch')) |
52 | end | 48 | end |
53 | end | 49 | end |
54 | - | ||
55 | end | 50 | end |
56 | - |
spec/views/notices/_summary.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "notices/_summary.html.haml" do | 1 | +describe "notices/_summary.html.haml", type: 'view' do |
4 | let(:notice) { Fabricate(:notice, :framework => 'Rails 3.2.11') } | 2 | let(:notice) { Fabricate(:notice, :framework => 'Rails 3.2.11') } |
5 | 3 | ||
6 | it "renders application framework" do | 4 | it "renders application framework" do |
@@ -9,4 +7,3 @@ describe "notices/_summary.html.haml" do | @@ -9,4 +7,3 @@ describe "notices/_summary.html.haml" do | ||
9 | expect(rendered).to have_content('Rails 3.2.11') | 7 | expect(rendered).to have_content('Rails 3.2.11') |
10 | end | 8 | end |
11 | end | 9 | end |
12 | - |
spec/views/notices/_user_attributes.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "notices/_user_attributes.html.haml" do | 1 | +describe "notices/_user_attributes.html.haml", type: 'view' do |
4 | describe 'autolink' do | 2 | describe 'autolink' do |
5 | let(:notice) do | 3 | let(:notice) do |
6 | user_attributes = { 'foo' => {'bar' => 'http://example.com'} } | 4 | user_attributes = { 'foo' => {'bar' => 'http://example.com'} } |
@@ -15,4 +13,3 @@ describe "notices/_user_attributes.html.haml" do | @@ -15,4 +13,3 @@ describe "notices/_user_attributes.html.haml" do | ||
15 | end | 13 | end |
16 | end | 14 | end |
17 | end | 15 | end |
18 | - |
spec/views/problems/index.atom.builder_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "problems/index.atom.builder" do | ||
4 | - | 1 | +describe "problems/index.atom.builder", type: 'view' do |
5 | it 'display problem message' do | 2 | it 'display problem message' do |
6 | app = App.new(:new_record => false) | 3 | app = App.new(:new_record => false) |
7 | - view.stub(:problems).and_return([Problem.new( | 4 | + allow(view).to receive(:problems).and_return([Problem.new( |
8 | :message => 'foo', | 5 | :message => 'foo', |
9 | :new_record => false, :app => app), Problem.new(:new_record => false, :app => app)]) | 6 | :new_record => false, :app => app), Problem.new(:new_record => false, :app => app)]) |
10 | render | 7 | render |
11 | expect(rendered).to match('foo') | 8 | expect(rendered).to match('foo') |
12 | end | 9 | end |
13 | - | ||
14 | end | 10 | end |
spec/views/problems/index.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "problems/index.html.haml" do | 1 | +describe "problems/index.html.haml", type: 'view' do |
4 | let(:problem_1) { Fabricate(:problem) } | 2 | let(:problem_1) { Fabricate(:problem) } |
5 | let(:problem_2) { Fabricate(:problem, :app => problem_1.app) } | 3 | let(:problem_2) { Fabricate(:problem, :app => problem_1.app) } |
6 | 4 | ||
7 | before do | 5 | before do |
8 | - # view.stub(:app).and_return(problem.app) | ||
9 | - view.stub(:selected_problems).and_return([]) | ||
10 | - view.stub(:problems).and_return(Kaminari.paginate_array([problem_1, problem_2]).page(1).per(10)) | ||
11 | - view.stub(:params_sort).and_return('asc') | ||
12 | - controller.stub(:current_user) { Fabricate(:user) } | 6 | + allow(view).to receive(:selected_problems).and_return([]) |
7 | + allow(view).to receive(:problems).and_return( | ||
8 | + Kaminari.paginate_array([problem_1, problem_2]).page(1).per(10) | ||
9 | + ) | ||
10 | + allow(view).to receive(:params_sort).and_return('asc') | ||
11 | + allow(controller).to receive(:current_user).and_return(Fabricate(:user)) | ||
13 | end | 12 | end |
14 | 13 | ||
15 | describe "with problem" do | 14 | describe "with problem" do |
@@ -20,6 +19,4 @@ describe "problems/index.html.haml" do | @@ -20,6 +19,4 @@ describe "problems/index.html.haml" do | ||
20 | expect(rendered).to have_selector('div#problem_table.problem_table') | 19 | expect(rendered).to have_selector('div#problem_table.problem_table') |
21 | end | 20 | end |
22 | end | 21 | end |
23 | - | ||
24 | end | 22 | end |
25 | - |
spec/views/problems/show.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "problems/show.html.haml" do | 1 | +describe "problems/show.html.haml", type: 'view' do |
4 | let(:problem) { Fabricate(:problem) } | 2 | let(:problem) { Fabricate(:problem) } |
5 | let(:comment) { Fabricate(:comment) } | 3 | let(:comment) { Fabricate(:comment) } |
6 | let(:pivotal_tracker) { | 4 | let(:pivotal_tracker) { |
@@ -23,22 +21,19 @@ describe "problems/show.html.haml" do | @@ -23,22 +21,19 @@ describe "problems/show.html.haml" do | ||
23 | } | 21 | } |
24 | 22 | ||
25 | before do | 23 | before do |
26 | - view.stub(:app).and_return(problem.app) | ||
27 | - view.stub(:problem).and_return(problem) | 24 | + allow(view).to receive(:app).and_return(problem.app) |
25 | + allow(view).to receive(:problem).and_return(problem) | ||
28 | 26 | ||
29 | assign :comment, comment | 27 | assign :comment, comment |
30 | assign :notices, problem.notices.page(1).per(1) | 28 | assign :notices, problem.notices.page(1).per(1) |
31 | assign :notice, problem.notices.first | 29 | assign :notice, problem.notices.first |
32 | 30 | ||
33 | - controller.stub(:current_user) { Fabricate(:user) } | 31 | + allow(controller).to receive(:current_user).and_return(Fabricate(:user)) |
34 | end | 32 | end |
35 | 33 | ||
36 | def with_issue_tracker(tracker, problem) | 34 | def with_issue_tracker(tracker, problem) |
37 | - ErrbitPlugin::Registry.stub(:issue_trackers).and_return(trackers) | 35 | + allow(ErrbitPlugin::Registry).to receive(:issue_trackers).and_return(trackers) |
38 | problem.app.issue_tracker = IssueTracker.new :type_tracker => tracker, :options => {:api_token => "token token token", :project_id => "1234"} | 36 | problem.app.issue_tracker = IssueTracker.new :type_tracker => tracker, :options => {:api_token => "token token token", :project_id => "1234"} |
39 | - | ||
40 | - view.stub(:problem).and_return(problem) | ||
41 | - view.stub(:app).and_return(problem.app) | ||
42 | end | 37 | end |
43 | 38 | ||
44 | describe "content_for :action_bar" do | 39 | describe "content_for :action_bar" do |
@@ -52,13 +47,13 @@ describe "problems/show.html.haml" do | @@ -52,13 +47,13 @@ describe "problems/show.html.haml" do | ||
52 | end | 47 | end |
53 | 48 | ||
54 | it "should confirm the 'resolve' link if configuration is unset" do | 49 | it "should confirm the 'resolve' link if configuration is unset" do |
55 | - Errbit::Config.stub(:confirm_err_actions).and_return(nil) | 50 | + allow(Errbit::Config).to receive(:confirm_err_actions).and_return(nil) |
56 | render | 51 | render |
57 | expect(action_bar).to have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) | 52 | expect(action_bar).to have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) |
58 | end | 53 | end |
59 | 54 | ||
60 | it "should not confirm the 'resolve' link if configured not to" do | 55 | it "should not confirm the 'resolve' link if configured not to" do |
61 | - Errbit::Config.stub(:confirm_err_actions).and_return(false) | 56 | + allow(Errbit::Config).to receive(:confirm_err_actions).and_return(false) |
62 | render | 57 | render |
63 | expect(action_bar).to have_selector('a.resolve[data-confirm="null"]') | 58 | expect(action_bar).to have_selector('a.resolve[data-confirm="null"]') |
64 | end | 59 | end |
@@ -73,8 +68,9 @@ describe "problems/show.html.haml" do | @@ -73,8 +68,9 @@ describe "problems/show.html.haml" do | ||
73 | it "should link 'up' to app_problems_path if HTTP_REFERER isn't set'" do | 68 | it "should link 'up' to app_problems_path if HTTP_REFERER isn't set'" do |
74 | controller.request.env['HTTP_REFERER'] = nil | 69 | controller.request.env['HTTP_REFERER'] = nil |
75 | problem = Fabricate(:problem_with_comments) | 70 | problem = Fabricate(:problem_with_comments) |
76 | - view.stub(:problem).and_return(problem) | ||
77 | - view.stub(:app).and_return(problem.app) | 71 | + |
72 | + allow(view).to receive(:problem).and_return(problem) | ||
73 | + allow(view).to receive(:app).and_return(problem.app) | ||
78 | render | 74 | render |
79 | 75 | ||
80 | expect(action_bar).to have_selector("span a.up[href='#{app_problems_path(problem.app)}']", :text => 'up') | 76 | expect(action_bar).to have_selector("span a.up[href='#{app_problems_path(problem.app)}']", :text => 'up') |
@@ -86,8 +82,8 @@ describe "problems/show.html.haml" do | @@ -86,8 +82,8 @@ describe "problems/show.html.haml" do | ||
86 | it 'should allow creating issue for github if application has a github tracker' do | 82 | it 'should allow creating issue for github if application has a github tracker' do |
87 | problem = Fabricate(:problem_with_comments, app: app) | 83 | problem = Fabricate(:problem_with_comments, app: app) |
88 | with_issue_tracker("github", problem) | 84 | with_issue_tracker("github", problem) |
89 | - view.stub(:problem).and_return(problem) | ||
90 | - view.stub(:app).and_return(problem.app) | 85 | + allow(view).to receive(:problem).and_return(problem) |
86 | + allow(view).to receive(:app).and_return(problem.app) | ||
91 | render | 87 | render |
92 | 88 | ||
93 | expect(action_bar).to have_selector("span a.github_create.create-issue", text: 'create issue') | 89 | expect(action_bar).to have_selector("span a.github_create.create-issue", text: 'create issue') |
@@ -98,8 +94,6 @@ describe "problems/show.html.haml" do | @@ -98,8 +94,6 @@ describe "problems/show.html.haml" do | ||
98 | let(:app) { App.new(:new_record => false) } | 94 | let(:app) { App.new(:new_record => false) } |
99 | 95 | ||
100 | it 'not see link to create issue' do | 96 | it 'not see link to create issue' do |
101 | - view.stub(:problem).and_return(problem) | ||
102 | - view.stub(:app).and_return(problem.app) | ||
103 | render | 97 | render |
104 | expect(view.content_for(:action_bar)).to_not match(/create issue/) | 98 | expect(view.content_for(:action_bar)).to_not match(/create issue/) |
105 | end | 99 | end |
@@ -118,7 +112,8 @@ describe "problems/show.html.haml" do | @@ -118,7 +112,8 @@ describe "problems/show.html.haml" do | ||
118 | before do | 112 | before do |
119 | problem.issue_link = nil | 113 | problem.issue_link = nil |
120 | user = Fabricate(:user, :github_login => 'test_user', :github_oauth_token => 'abcdef') | 114 | user = Fabricate(:user, :github_login => 'test_user', :github_oauth_token => 'abcdef') |
121 | - controller.stub(:current_user) { user } | 115 | + |
116 | + allow(controller).to receive(:current_user).and_return(user) | ||
122 | end | 117 | end |
123 | 118 | ||
124 | it 'links to the associated tracker' do | 119 | it 'links to the associated tracker' do |
@@ -161,13 +156,13 @@ describe "problems/show.html.haml" do | @@ -161,13 +156,13 @@ describe "problems/show.html.haml" do | ||
161 | 156 | ||
162 | describe "content_for :comments" do | 157 | describe "content_for :comments" do |
163 | before do | 158 | before do |
164 | - Errbit::Config.stub(:use_gravatar).and_return(true) | 159 | + problem = Fabricate(:problem_with_comments) |
160 | + allow(view).to receive(:problem).and_return(problem) | ||
161 | + allow(view).to receive(:app).and_return(problem.app) | ||
162 | + allow(Errbit::Config).to receive(:use_gravatar).and_return(true) | ||
165 | end | 163 | end |
166 | 164 | ||
167 | it 'should display comments and new comment form' do | 165 | it 'should display comments and new comment form' do |
168 | - problem = Fabricate(:problem_with_comments) | ||
169 | - view.stub(:problem).and_return(problem) | ||
170 | - view.stub(:app).and_return(problem.app) | ||
171 | render | 166 | render |
172 | 167 | ||
173 | expect(view.content_for(:comments)).to include('Test comment') | 168 | expect(view.content_for(:comments)).to include('Test comment') |
@@ -175,9 +170,7 @@ describe "problems/show.html.haml" do | @@ -175,9 +170,7 @@ describe "problems/show.html.haml" do | ||
175 | expect(view.content_for(:comments)).to include('Add a comment') | 170 | expect(view.content_for(:comments)).to include('Add a comment') |
176 | end | 171 | end |
177 | 172 | ||
178 | - it 'should display existing comments' do | ||
179 | - problem = Fabricate(:problem_with_comments) | ||
180 | - problem.reload | 173 | + it 'should display existing comments with configured tracker' do |
181 | with_issue_tracker("pivotal", problem) | 174 | with_issue_tracker("pivotal", problem) |
182 | render | 175 | render |
183 | 176 |
spec/views/problems/show.ics.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe "problems/show.html.ics" do | 1 | +describe "problems/show.html.ics", type: 'view' do |
4 | let(:problem) { Fabricate(:problem) } | 2 | let(:problem) { Fabricate(:problem) } |
3 | + | ||
5 | before do | 4 | before do |
6 | - view.stub(:problem).and_return(problem) | 5 | + allow(view).to receive(:problem).and_return(problem) |
7 | end | 6 | end |
8 | 7 | ||
9 | it 'should work' do | 8 | it 'should work' do |
10 | render :template => 'problems/show', :formats => [:ics], :handlers => [:haml] | 9 | render :template => 'problems/show', :formats => [:ics], :handlers => [:haml] |
11 | end | 10 | end |
12 | - | ||
13 | - | ||
14 | end | 11 | end |
spec/views/users/edit.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe 'users/edit.html.haml' do | 1 | +describe 'users/edit.html.haml', type: 'view' do |
4 | let(:user) { stub_model(User, :name => 'shingara') } | 2 | let(:user) { stub_model(User, :name => 'shingara') } |
5 | before { | 3 | before { |
6 | - view.stub(:current_user).and_return(user) | ||
7 | - view.stub(:user).and_return(user) | 4 | + allow(view).to receive(:current_user).and_return(user) |
5 | + allow(view).to receive(:user).and_return(user) | ||
8 | } | 6 | } |
9 | it 'should have per_page option' do | 7 | it 'should have per_page option' do |
10 | render | 8 | render |
spec/views/users/index.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe 'users/index.html.haml' do | 1 | +describe 'users/index.html.haml', type: 'view' do |
4 | let(:user) { stub_model(User) } | 2 | let(:user) { stub_model(User) } |
5 | before { | 3 | before { |
6 | - view.stub(:current_user).and_return(user) | ||
7 | - view.stub(:users).and_return( | 4 | + allow(view).to receive(:current_user).and_return(user) |
5 | + allow(view).to receive(:users).and_return( | ||
8 | Kaminari.paginate_array([user], :total_count => 1).page(1) | 6 | Kaminari.paginate_array([user], :total_count => 1).page(1) |
9 | ) | 7 | ) |
10 | } | 8 | } |
@@ -12,5 +10,4 @@ describe 'users/index.html.haml' do | @@ -12,5 +10,4 @@ describe 'users/index.html.haml' do | ||
12 | render | 10 | render |
13 | expect(rendered).to match(/class='user_list'/) | 11 | expect(rendered).to match(/class='user_list'/) |
14 | end | 12 | end |
15 | - | ||
16 | end | 13 | end |
spec/views/users/new.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe 'users/new.html.haml' do | 1 | +describe 'users/new.html.haml', type: 'view' do |
4 | let(:user) { stub_model(User) } | 2 | let(:user) { stub_model(User) } |
5 | before { | 3 | before { |
6 | - view.stub(:current_user).and_return(user) | ||
7 | - view.stub(:user).and_return(user) | 4 | + allow(view).to receive(:current_user).and_return(user) |
5 | + allow(view).to receive(:user).and_return(user) | ||
8 | } | 6 | } |
9 | it 'should have per_page option' do | 7 | it 'should have per_page option' do |
10 | render | 8 | render |
spec/views/users/show.html.haml_spec.rb
1 | -require 'spec_helper' | ||
2 | - | ||
3 | -describe 'users/show.html.haml' do | ||
4 | - | 1 | +describe 'users/show.html.haml', type: 'view' do |
5 | let(:user) do | 2 | let(:user) do |
6 | stub_model(User, :created_at => Time.now, :email => "test@example.com") | 3 | stub_model(User, :created_at => Time.now, :email => "test@example.com") |
7 | end | 4 | end |
8 | 5 | ||
9 | before do | 6 | before do |
10 | - Errbit::Config.stub(:github_authentication) { true } | ||
11 | - controller.stub(:current_user) { stub_model(User) } | ||
12 | - view.stub(:user) { user } | 7 | + allow(Errbit::Config).to receive(:github_authentication).and_return(true) |
8 | + allow(controller).to receive(:current_user).and_return(stub_model(User)) | ||
9 | + allow(view).to receive(:user).and_return(user) | ||
13 | end | 10 | end |
14 | 11 | ||
15 | context 'with GitHub authentication' do | 12 | context 'with GitHub authentication' do |
@@ -38,7 +35,7 @@ describe 'users/show.html.haml' do | @@ -38,7 +35,7 @@ describe 'users/show.html.haml' do | ||
38 | 35 | ||
39 | context 'viewing own user page' do | 36 | context 'viewing own user page' do |
40 | before do | 37 | before do |
41 | - controller.stub(:current_user) { user } | 38 | + allow(controller).to receive(:current_user).and_return(user) |
42 | end | 39 | end |
43 | 40 | ||
44 | it 'shows link github button when no login or token' do | 41 | it 'shows link github button when no login or token' do |