Commit efed11e8b48b39b62947f54634628283b59dc12b
1 parent
bf93f2fa
Exists in
master
and in
1 other branch
Update rspec to use expect consistently and to use eq over == and {} over lambda
Showing
62 changed files
with
547 additions
and
544 deletions
Show diff stats
spec/acceptance/sign_in_with_github_spec.rb
@@ -12,7 +12,7 @@ feature 'Sign in with GitHub' do | @@ -12,7 +12,7 @@ feature 'Sign in with GitHub' do | ||
12 | 12 | ||
13 | visit '/' | 13 | visit '/' |
14 | click_link 'Sign in with GitHub' | 14 | click_link 'Sign in with GitHub' |
15 | - page.should have_content I18n.t("devise.omniauth_callbacks.success", :kind => 'GitHub') | 15 | + expect(page).to have_content I18n.t("devise.omniauth_callbacks.success", :kind => 'GitHub') |
16 | end | 16 | end |
17 | 17 | ||
18 | scenario 'reject unrecognized user if authenticating via GitHub' do | 18 | scenario 'reject unrecognized user if authenticating via GitHub' do |
@@ -20,6 +20,6 @@ feature 'Sign in with GitHub' do | @@ -20,6 +20,6 @@ feature 'Sign in with GitHub' do | ||
20 | 20 | ||
21 | visit '/' | 21 | visit '/' |
22 | click_link 'Sign in with GitHub' | 22 | click_link 'Sign in with GitHub' |
23 | - page.should have_content 'There are no authorized users with GitHub login' | 23 | + expect(page).to have_content 'There are no authorized users with GitHub login' |
24 | end | 24 | end |
25 | end | 25 | end |
spec/controllers/api/v1/notices_controller_spec.rb
@@ -22,7 +22,7 @@ describe Api::V1::NoticesController do | @@ -22,7 +22,7 @@ describe Api::V1::NoticesController do | ||
22 | 22 | ||
23 | it "should return XML if XML is requested" do | 23 | it "should return XML if XML is requested" do |
24 | get :index, :auth_token => @user.authentication_token, :format => "xml" | 24 | get :index, :auth_token => @user.authentication_token, :format => "xml" |
25 | - Nokogiri::XML(response.body).errors.should be_empty | 25 | + expect(Nokogiri::XML(response.body).errors).to be_empty |
26 | end | 26 | end |
27 | 27 | ||
28 | it "should return JSON by default" do | 28 | it "should return JSON by default" do |
@@ -34,18 +34,18 @@ describe Api::V1::NoticesController do | @@ -34,18 +34,18 @@ describe Api::V1::NoticesController do | ||
34 | 34 | ||
35 | it "should return only the notices created during the date range" do | 35 | it "should return only the notices created during the date range" do |
36 | get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-01", :end_date => "2012-08-27"} | 36 | get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-01", :end_date => "2012-08-27"} |
37 | - response.should be_success | 37 | + expect(response).to be_success |
38 | notices = JSON.load response.body | 38 | notices = JSON.load response.body |
39 | - notices.length.should == 3 | 39 | + expect(notices.length).to eq 3 |
40 | end | 40 | end |
41 | 41 | ||
42 | end | 42 | end |
43 | 43 | ||
44 | it "should return all notices" do | 44 | it "should return all notices" do |
45 | get :index, {:auth_token => @user.authentication_token} | 45 | get :index, {:auth_token => @user.authentication_token} |
46 | - response.should be_success | 46 | + expect(response).to be_success |
47 | notices = JSON.load response.body | 47 | notices = JSON.load response.body |
48 | - notices.length.should == 4 | 48 | + expect(notices.length).to eq 4 |
49 | end | 49 | end |
50 | 50 | ||
51 | end | 51 | end |
spec/controllers/api/v1/problems_controller_spec.rb
@@ -24,7 +24,7 @@ describe Api::V1::ProblemsController do | @@ -24,7 +24,7 @@ describe Api::V1::ProblemsController do | ||
24 | 24 | ||
25 | it "should return XML if XML is requested" do | 25 | it "should return XML if XML is requested" do |
26 | get :index, :auth_token => @user.authentication_token, :format => "xml" | 26 | get :index, :auth_token => @user.authentication_token, :format => "xml" |
27 | - Nokogiri::XML(response.body).errors.should be_empty | 27 | + expect(Nokogiri::XML(response.body).errors).to be_empty |
28 | end | 28 | end |
29 | 29 | ||
30 | it "should return JSON by default" do | 30 | it "should return JSON by default" do |
@@ -38,18 +38,18 @@ describe Api::V1::ProblemsController do | @@ -38,18 +38,18 @@ describe Api::V1::ProblemsController do | ||
38 | 38 | ||
39 | it "should return only the problems open during the date range" do | 39 | it "should return only the problems open during the date range" do |
40 | get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27"} | 40 | get :index, {:auth_token => @user.authentication_token, :start_date => "2012-08-20", :end_date => "2012-08-27"} |
41 | - response.should be_success | 41 | + expect(response).to be_success |
42 | problems = JSON.load response.body | 42 | problems = JSON.load response.body |
43 | - problems.length.should == 2 | 43 | + expect(problems.length).to eq 2 |
44 | end | 44 | end |
45 | 45 | ||
46 | end | 46 | end |
47 | 47 | ||
48 | it "should return all problems" do | 48 | it "should return all problems" do |
49 | get :index, {:auth_token => @user.authentication_token} | 49 | get :index, {:auth_token => @user.authentication_token} |
50 | - response.should be_success | 50 | + expect(response).to be_success |
51 | problems = JSON.load response.body | 51 | problems = JSON.load response.body |
52 | - problems.length.should == 4 | 52 | + expect(problems.length).to eq 4 |
53 | end | 53 | end |
54 | 54 | ||
55 | end | 55 | end |
spec/controllers/apps_controller_spec.rb
@@ -37,7 +37,7 @@ describe AppsController do | @@ -37,7 +37,7 @@ describe AppsController do | ||
37 | sign_in admin | 37 | sign_in admin |
38 | unwatched_app && watched_app1 && watched_app2 | 38 | unwatched_app && watched_app1 && watched_app2 |
39 | get :index | 39 | get :index |
40 | - controller.apps.entries.should == App.all.sort.entries | 40 | + expect(controller.apps.entries).to eq App.all.sort.entries |
41 | end | 41 | end |
42 | end | 42 | end |
43 | 43 | ||
@@ -46,8 +46,8 @@ describe AppsController do | @@ -46,8 +46,8 @@ describe AppsController do | ||
46 | sign_in(user) | 46 | sign_in(user) |
47 | watched_app1 && watched_app2 && unwatched_app | 47 | watched_app1 && watched_app2 && unwatched_app |
48 | get :index | 48 | get :index |
49 | - controller.apps.should include(watched_app1, watched_app2) | ||
50 | - controller.apps.should_not include(unwatched_app) | 49 | + expect(controller.apps).to include(watched_app1, watched_app2) |
50 | + expect(controller.apps).to_not include(unwatched_app) | ||
51 | end | 51 | end |
52 | end | 52 | end |
53 | end | 53 | end |
@@ -60,17 +60,17 @@ describe AppsController do | @@ -60,17 +60,17 @@ describe AppsController do | ||
60 | 60 | ||
61 | it 'finds the app' do | 61 | it 'finds the app' do |
62 | get :show, :id => app.id | 62 | get :show, :id => app.id |
63 | - controller.app.should == app | 63 | + expect(controller.app).to eq app |
64 | end | 64 | end |
65 | 65 | ||
66 | it "should not raise errors for app with err without notices" do | 66 | it "should not raise errors for app with err without notices" do |
67 | err | 67 | err |
68 | - lambda { get :show, :id => app.id }.should_not raise_error | 68 | + expect{ get :show, :id => app.id }.to_not raise_error |
69 | end | 69 | end |
70 | 70 | ||
71 | it "should list atom feed successfully" do | 71 | it "should list atom feed successfully" do |
72 | get :show, :id => app.id, :format => "atom" | 72 | get :show, :id => app.id, :format => "atom" |
73 | - response.should be_success | 73 | + expect(response).to be_success |
74 | end | 74 | end |
75 | 75 | ||
76 | context "pagination" do | 76 | context "pagination" do |
@@ -80,13 +80,13 @@ describe AppsController do | @@ -80,13 +80,13 @@ describe AppsController do | ||
80 | 80 | ||
81 | it "should have default per_page value for user" do | 81 | it "should have default per_page value for user" do |
82 | get :show, :id => app.id | 82 | get :show, :id => app.id |
83 | - controller.problems.to_a.size.should == User::PER_PAGE | 83 | + expect(controller.problems.to_a.size).to eq User::PER_PAGE |
84 | end | 84 | end |
85 | 85 | ||
86 | it "should be able to override default per_page value" do | 86 | it "should be able to override default per_page value" do |
87 | admin.update_attribute :per_page, 10 | 87 | admin.update_attribute :per_page, 10 |
88 | get :show, :id => app.id | 88 | get :show, :id => app.id |
89 | - controller.problems.to_a.size.should == 10 | 89 | + expect(controller.problems.to_a.size).to eq 10 |
90 | end | 90 | end |
91 | end | 91 | end |
92 | 92 | ||
@@ -98,14 +98,14 @@ describe AppsController do | @@ -98,14 +98,14 @@ describe AppsController do | ||
98 | context 'and no params' do | 98 | context 'and no params' do |
99 | it 'shows only unresolved problems' do | 99 | it 'shows only unresolved problems' do |
100 | get :show, :id => app.id | 100 | get :show, :id => app.id |
101 | - controller.problems.size.should == 1 | 101 | + expect(controller.problems.size).to eq 1 |
102 | end | 102 | end |
103 | end | 103 | end |
104 | 104 | ||
105 | context 'and all_problems=true params' do | 105 | context 'and all_problems=true params' do |
106 | it 'shows all errors' do | 106 | it 'shows all errors' do |
107 | get :show, :id => app.id, :all_errs => true | 107 | get :show, :id => app.id, :all_errs => true |
108 | - controller.problems.size.should == 2 | 108 | + expect(controller.problems.size).to eq 2 |
109 | end | 109 | end |
110 | end | 110 | end |
111 | end | 111 | end |
@@ -121,35 +121,35 @@ describe AppsController do | @@ -121,35 +121,35 @@ describe AppsController do | ||
121 | context 'no params' do | 121 | context 'no params' do |
122 | it 'shows errs for all environments' do | 122 | it 'shows errs for all environments' do |
123 | get :show, :id => app.id | 123 | get :show, :id => app.id |
124 | - controller.problems.size.should == 20 | 124 | + expect(controller.problems.size).to eq 20 |
125 | end | 125 | end |
126 | end | 126 | end |
127 | 127 | ||
128 | context 'environment production' do | 128 | context 'environment production' do |
129 | it 'shows errs for just production' do | 129 | it 'shows errs for just production' do |
130 | get :show, :id => app.id, :environment => 'production' | 130 | get :show, :id => app.id, :environment => 'production' |
131 | - controller.problems.size.should == 5 | 131 | + expect(controller.problems.size).to eq 5 |
132 | end | 132 | end |
133 | end | 133 | end |
134 | 134 | ||
135 | context 'environment staging' do | 135 | context 'environment staging' do |
136 | it 'shows errs for just staging' do | 136 | it 'shows errs for just staging' do |
137 | get :show, :id => app.id, :environment => 'staging' | 137 | get :show, :id => app.id, :environment => 'staging' |
138 | - controller.problems.size.should == 5 | 138 | + expect(controller.problems.size).to eq 5 |
139 | end | 139 | end |
140 | end | 140 | end |
141 | 141 | ||
142 | context 'environment development' do | 142 | context 'environment development' do |
143 | it 'shows errs for just development' do | 143 | it 'shows errs for just development' do |
144 | get :show, :id => app.id, :environment => 'development' | 144 | get :show, :id => app.id, :environment => 'development' |
145 | - controller.problems.size.should == 5 | 145 | + expect(controller.problems.size).to eq 5 |
146 | end | 146 | end |
147 | end | 147 | end |
148 | 148 | ||
149 | context 'environment test' do | 149 | context 'environment test' do |
150 | it 'shows errs for just test' do | 150 | it 'shows errs for just test' do |
151 | get :show, :id => app.id, :environment => 'test' | 151 | get :show, :id => app.id, :environment => 'test' |
152 | - controller.problems.size.should == 5 | 152 | + expect(controller.problems.size).to eq 5 |
153 | end | 153 | end |
154 | end | 154 | end |
155 | end | 155 | end |
@@ -160,15 +160,15 @@ describe AppsController do | @@ -160,15 +160,15 @@ describe AppsController do | ||
160 | watcher | 160 | watcher |
161 | sign_in user | 161 | sign_in user |
162 | get :show, :id => app.id | 162 | get :show, :id => app.id |
163 | - controller.app.should == app | 163 | + expect(controller.app).to eq app |
164 | end | 164 | end |
165 | 165 | ||
166 | it 'does not find the app if the user is not watching it' do | 166 | it 'does not find the app if the user is not watching it' do |
167 | sign_in Fabricate(:user) | 167 | sign_in Fabricate(:user) |
168 | app = Fabricate(:app) | 168 | app = Fabricate(:app) |
169 | - lambda { | 169 | + expect{ |
170 | get :show, :id => app.id | 170 | get :show, :id => app.id |
171 | - }.should raise_error(Mongoid::Errors::DocumentNotFound) | 171 | + }.to raise_error(Mongoid::Errors::DocumentNotFound) |
172 | end | 172 | end |
173 | end | 173 | end |
174 | end | 174 | end |
@@ -181,19 +181,19 @@ describe AppsController do | @@ -181,19 +181,19 @@ describe AppsController do | ||
181 | describe "GET /apps/new" do | 181 | describe "GET /apps/new" do |
182 | it 'instantiates a new app with a prebuilt watcher' do | 182 | it 'instantiates a new app with a prebuilt watcher' do |
183 | get :new | 183 | get :new |
184 | - controller.app.should be_a(App) | ||
185 | - controller.app.should be_new_record | ||
186 | - controller.app.watchers.should_not be_empty | 184 | + expect(controller.app).to be_a(App) |
185 | + expect(controller.app).to be_new_record | ||
186 | + expect(controller.app.watchers).to_not be_empty | ||
187 | end | 187 | end |
188 | 188 | ||
189 | it "should copy attributes from an existing app" do | 189 | it "should copy attributes from an existing app" do |
190 | @app = Fabricate(:app, :name => "do not copy", | 190 | @app = Fabricate(:app, :name => "do not copy", |
191 | :github_repo => "test/example") | 191 | :github_repo => "test/example") |
192 | get :new, :copy_attributes_from => @app.id | 192 | get :new, :copy_attributes_from => @app.id |
193 | - controller.app.should be_a(App) | ||
194 | - controller.app.should be_new_record | ||
195 | - controller.app.name.should be_blank | ||
196 | - controller.app.github_repo.should == "test/example" | 193 | + expect(controller.app).to be_a(App) |
194 | + expect(controller.app).to be_new_record | ||
195 | + expect(controller.app.name).to be_blank | ||
196 | + expect(controller.app.github_repo).to eq "test/example" | ||
197 | end | 197 | end |
198 | end | 198 | end |
199 | 199 | ||
@@ -201,7 +201,7 @@ describe AppsController do | @@ -201,7 +201,7 @@ describe AppsController do | ||
201 | it 'finds the correct app' do | 201 | it 'finds the correct app' do |
202 | app = Fabricate(:app) | 202 | app = Fabricate(:app) |
203 | get :edit, :id => app.id | 203 | get :edit, :id => app.id |
204 | - controller.app.should == app | 204 | + expect(controller.app).to eq app |
205 | end | 205 | end |
206 | end | 206 | end |
207 | 207 | ||
@@ -213,17 +213,17 @@ describe AppsController do | @@ -213,17 +213,17 @@ describe AppsController do | ||
213 | 213 | ||
214 | context "when the create is successful" do | 214 | context "when the create is successful" do |
215 | before do | 215 | before do |
216 | - @app.should_receive(:save).and_return(true) | 216 | + expect(@app).to receive(:save).and_return(true) |
217 | end | 217 | end |
218 | 218 | ||
219 | it "should redirect to the app page" do | 219 | it "should redirect to the app page" do |
220 | post :create, :app => {} | 220 | post :create, :app => {} |
221 | - response.should redirect_to(app_path(@app)) | 221 | + expect(response).to redirect_to(app_path(@app)) |
222 | end | 222 | end |
223 | 223 | ||
224 | it "should display a message" do | 224 | it "should display a message" do |
225 | post :create, :app => {} | 225 | post :create, :app => {} |
226 | - request.flash[:success].should match(/success/) | 226 | + expect(request.flash[:success]).to match(/success/) |
227 | end | 227 | end |
228 | end | 228 | end |
229 | end | 229 | end |
@@ -236,12 +236,12 @@ describe AppsController do | @@ -236,12 +236,12 @@ describe AppsController do | ||
236 | context "when the update is successful" do | 236 | context "when the update is successful" do |
237 | it "should redirect to the app page" do | 237 | it "should redirect to the app page" do |
238 | put :update, :id => @app.id, :app => {} | 238 | put :update, :id => @app.id, :app => {} |
239 | - response.should redirect_to(app_path(@app)) | 239 | + expect(response).to redirect_to(app_path(@app)) |
240 | end | 240 | end |
241 | 241 | ||
242 | it "should display a message" do | 242 | it "should display a message" do |
243 | put :update, :id => @app.id, :app => {} | 243 | put :update, :id => @app.id, :app => {} |
244 | - request.flash[:success].should match(/success/) | 244 | + expect(request.flash[:success]).to match(/success/) |
245 | end | 245 | end |
246 | end | 246 | end |
247 | 247 | ||
@@ -249,14 +249,14 @@ describe AppsController do | @@ -249,14 +249,14 @@ describe AppsController do | ||
249 | it "should redirect to app page" do | 249 | it "should redirect to app page" do |
250 | id = @app.id | 250 | id = @app.id |
251 | put :update, :id => id, :app => {:name => "new name"} | 251 | put :update, :id => id, :app => {:name => "new name"} |
252 | - response.should redirect_to(app_path(id)) | 252 | + expect(response).to redirect_to(app_path(id)) |
253 | end | 253 | end |
254 | end | 254 | end |
255 | 255 | ||
256 | context "when the update is unsuccessful" do | 256 | context "when the update is unsuccessful" do |
257 | it "should render the edit page" do | 257 | it "should render the edit page" do |
258 | put :update, :id => @app.id, :app => { :name => '' } | 258 | put :update, :id => @app.id, :app => { :name => '' } |
259 | - response.should render_template(:edit) | 259 | + expect(response).to render_template(:edit) |
260 | end | 260 | end |
261 | end | 261 | end |
262 | 262 | ||
@@ -268,19 +268,19 @@ describe AppsController do | @@ -268,19 +268,19 @@ describe AppsController do | ||
268 | it "should parse legal csv values" do | 268 | it "should parse legal csv values" do |
269 | put :update, :id => @app.id, :app => { :email_at_notices => '1, 4, 7,8, 10' } | 269 | put :update, :id => @app.id, :app => { :email_at_notices => '1, 4, 7,8, 10' } |
270 | @app.reload | 270 | @app.reload |
271 | - @app.email_at_notices.should == [1, 4, 7, 8, 10] | 271 | + expect(@app.email_at_notices).to eq [1, 4, 7, 8, 10] |
272 | end | 272 | end |
273 | context "failed parsing of CSV" do | 273 | context "failed parsing of CSV" do |
274 | it "should set the default value" do | 274 | it "should set the default value" do |
275 | @app = Fabricate(:app, :email_at_notices => [1, 2, 3, 4]) | 275 | @app = Fabricate(:app, :email_at_notices => [1, 2, 3, 4]) |
276 | put :update, :id => @app.id, :app => { :email_at_notices => 'asdf, -1,0,foobar,gd00,0,abc' } | 276 | put :update, :id => @app.id, :app => { :email_at_notices => 'asdf, -1,0,foobar,gd00,0,abc' } |
277 | @app.reload | 277 | @app.reload |
278 | - @app.email_at_notices.should == Errbit::Config.email_at_notices | 278 | + expect(@app.email_at_notices).to eq Errbit::Config.email_at_notices |
279 | end | 279 | end |
280 | 280 | ||
281 | it "should display a message" do | 281 | it "should display a message" do |
282 | put :update, :id => @app.id, :app => { :email_at_notices => 'qwertyuiop' } | 282 | put :update, :id => @app.id, :app => { :email_at_notices => 'qwertyuiop' } |
283 | - request.flash[:error].should match(/Couldn't parse/) | 283 | + expect(request.flash[:error]).to match(/Couldn't parse/) |
284 | end | 284 | end |
285 | end | 285 | end |
286 | end | 286 | end |
@@ -295,7 +295,7 @@ describe AppsController do | @@ -295,7 +295,7 @@ describe AppsController do | ||
295 | end | 295 | end |
296 | 296 | ||
297 | it "should not create issue tracker" do | 297 | it "should not create issue tracker" do |
298 | - @app.issue_tracker_configured?.should == false | 298 | + expect(@app.issue_tracker_configured?).to eq false |
299 | end | 299 | end |
300 | end | 300 | end |
301 | 301 | ||
@@ -310,11 +310,13 @@ describe AppsController do | @@ -310,11 +310,13 @@ describe AppsController do | ||
310 | @app.reload | 310 | @app.reload |
311 | 311 | ||
312 | tracker = @app.issue_tracker | 312 | tracker = @app.issue_tracker |
313 | - tracker.should be_a(tracker_klass) | 313 | + expect(tracker).to be_a(tracker_klass) |
314 | tracker_klass::Fields.each do |field, field_info| | 314 | tracker_klass::Fields.each do |field, field_info| |
315 | case field | 315 | case field |
316 | - when :ticket_properties; tracker.send(field.to_sym).should == 'card_type = defect' | ||
317 | - else tracker.send(field.to_sym).should == 'test_value' | 316 | + when :ticket_properties |
317 | + expect(tracker.send(field.to_sym)).to eq 'card_type = defect' | ||
318 | + else | ||
319 | + expect(tracker.send(field.to_sym)).to eq 'test_value' | ||
318 | end | 320 | end |
319 | end | 321 | end |
320 | end | 322 | end |
@@ -326,7 +328,7 @@ describe AppsController do | @@ -326,7 +328,7 @@ describe AppsController do | ||
326 | put :update, :id => @app.id, :app => {:issue_tracker_attributes => params} | 328 | put :update, :id => @app.id, :app => {:issue_tracker_attributes => params} |
327 | 329 | ||
328 | @app.reload | 330 | @app.reload |
329 | - @app.issue_tracker_configured?.should == false | 331 | + expect(@app.issue_tracker_configured?).to eq false |
330 | end | 332 | end |
331 | end | 333 | end |
332 | end | 334 | end |
@@ -340,22 +342,22 @@ describe AppsController do | @@ -340,22 +342,22 @@ describe AppsController do | ||
340 | 342 | ||
341 | it "should find the app" do | 343 | it "should find the app" do |
342 | delete :destroy, :id => @app.id | 344 | delete :destroy, :id => @app.id |
343 | - controller.app.should == @app | 345 | + expect(controller.app).to eq @app |
344 | end | 346 | end |
345 | 347 | ||
346 | it "should destroy the app" do | 348 | it "should destroy the app" do |
347 | - @app.should_receive(:destroy) | 349 | + expect(@app).to receive(:destroy) |
348 | delete :destroy, :id => @app.id | 350 | delete :destroy, :id => @app.id |
349 | end | 351 | end |
350 | 352 | ||
351 | it "should display a message" do | 353 | it "should display a message" do |
352 | delete :destroy, :id => @app.id | 354 | delete :destroy, :id => @app.id |
353 | - request.flash[:success].should match(/success/) | 355 | + expect(request.flash[:success]).to match(/success/) |
354 | end | 356 | end |
355 | 357 | ||
356 | it "should redirect to the apps page" do | 358 | it "should redirect to the apps page" do |
357 | delete :destroy, :id => @app.id | 359 | delete :destroy, :id => @app.id |
358 | - response.should redirect_to(apps_path) | 360 | + expect(response).to redirect_to(apps_path) |
359 | end | 361 | end |
360 | end | 362 | end |
361 | end | 363 | end |
spec/controllers/comments_controller_spec.rb
@@ -22,11 +22,11 @@ describe CommentsController do | @@ -22,11 +22,11 @@ describe CommentsController do | ||
22 | end | 22 | end |
23 | 23 | ||
24 | it "should create the comment" do | 24 | it "should create the comment" do |
25 | - problem.comments.size.should == 1 | 25 | + expect(problem.comments.size).to eq 1 |
26 | end | 26 | end |
27 | 27 | ||
28 | it "should redirect to problem page" do | 28 | it "should redirect to problem page" do |
29 | - response.should redirect_to( app_problem_path(problem.app, problem) ) | 29 | + expect(response).to redirect_to( app_problem_path(problem.app, problem) ) |
30 | end | 30 | end |
31 | end | 31 | end |
32 | end | 32 | end |
@@ -48,11 +48,11 @@ describe CommentsController do | @@ -48,11 +48,11 @@ describe CommentsController do | ||
48 | end | 48 | end |
49 | 49 | ||
50 | it "should delete the comment" do | 50 | it "should delete the comment" do |
51 | - problem.comments.detect{|c| c.id.to_s == comment.id }.should == nil | 51 | + expect(problem.comments.detect{|c| c.id.to_s == comment.id }).to be nil |
52 | end | 52 | end |
53 | 53 | ||
54 | it "should redirect to problem page" do | 54 | it "should redirect to problem page" do |
55 | - response.should redirect_to( app_problem_path(problem.app, problem) ) | 55 | + expect(response).to redirect_to( app_problem_path(problem.app, problem) ) |
56 | end | 56 | end |
57 | end | 57 | end |
58 | end | 58 | end |
spec/controllers/deploys_controller_spec.rb
@@ -16,13 +16,13 @@ describe DeploysController do | @@ -16,13 +16,13 @@ describe DeploysController do | ||
16 | end | 16 | end |
17 | 17 | ||
18 | it 'finds the app via the api key' do | 18 | it 'finds the app via the api key' do |
19 | - App.should_receive(:find_by_api_key!).with('APIKEY').and_return(@app) | 19 | + expect(App).to receive(:find_by_api_key!).with('APIKEY').and_return(@app) |
20 | post :create, :deploy => @params, :api_key => 'APIKEY' | 20 | post :create, :deploy => @params, :api_key => 'APIKEY' |
21 | end | 21 | end |
22 | 22 | ||
23 | it 'creates a deploy' do | 23 | it 'creates a deploy' do |
24 | App.stub(:find_by_api_key!).and_return(@app) | 24 | App.stub(:find_by_api_key!).and_return(@app) |
25 | - @app.deploys.should_receive(:create!). | 25 | + expect(@app.deploys).to receive(:create!). |
26 | with({ | 26 | with({ |
27 | :username => 'john.doe', | 27 | :username => 'john.doe', |
28 | :environment => 'production', | 28 | :environment => 'production', |
@@ -37,8 +37,8 @@ describe DeploysController do | @@ -37,8 +37,8 @@ describe DeploysController do | ||
37 | it 'sends an email notification when configured to do so' do | 37 | it 'sends an email notification when configured to do so' do |
38 | post :create, :deploy => @params, :api_key => 'APIKEY' | 38 | post :create, :deploy => @params, :api_key => 'APIKEY' |
39 | email = ActionMailer::Base.deliveries.last | 39 | email = ActionMailer::Base.deliveries.last |
40 | - email.to.should include(@app.watchers.first.email) | ||
41 | - email.subject.should == "[#{@app.name}] Deployed to production by john.doe" | 40 | + expect(email.to).to include(@app.watchers.first.email) |
41 | + expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe" | ||
42 | end | 42 | end |
43 | 43 | ||
44 | end | 44 | end |
@@ -51,12 +51,12 @@ describe DeploysController do | @@ -51,12 +51,12 @@ describe DeploysController do | ||
51 | end | 51 | end |
52 | 52 | ||
53 | it "should render successfully" do | 53 | it "should render successfully" do |
54 | - response.should be_success | 54 | + expect(response).to be_success |
55 | end | 55 | end |
56 | 56 | ||
57 | it "should contain info about existing deploy" do | 57 | it "should contain info about existing deploy" do |
58 | - response.body.should match(@deploy.short_revision) | ||
59 | - response.body.should match(@deploy.app.name) | 58 | + expect(response.body).to match(@deploy.short_revision) |
59 | + expect(response.body).to match(@deploy.app.name) | ||
60 | end | 60 | end |
61 | end | 61 | end |
62 | 62 |
spec/controllers/devise_sessions_controller_spec.rb
@@ -13,13 +13,13 @@ describe Devise::SessionsController do | @@ -13,13 +13,13 @@ describe Devise::SessionsController do | ||
13 | 13 | ||
14 | it 'redirects to app index page if there are no apps for the user' do | 14 | it 'redirects to app index page if there are no apps for the user' do |
15 | post :create, { :user => { 'email' => user.email, 'password' => user.password } } | 15 | post :create, { :user => { 'email' => user.email, 'password' => user.password } } |
16 | - response.should redirect_to(root_path) | 16 | + expect(response).to redirect_to(root_path) |
17 | end | 17 | end |
18 | 18 | ||
19 | it 'redirects to app page if there is app for the user' do | 19 | it 'redirects to app page if there is app for the user' do |
20 | Fabricate(:user_watcher, :app => app, :user => user) | 20 | Fabricate(:user_watcher, :app => app, :user => user) |
21 | post :create, { :user => { 'email' => user.email, 'password' => user.password } } | 21 | post :create, { :user => { 'email' => user.email, 'password' => user.password } } |
22 | - response.should redirect_to(app_path(app)) | 22 | + expect(response).to redirect_to(app_path(app)) |
23 | end | 23 | end |
24 | end | 24 | end |
25 | end | 25 | end |
spec/controllers/notices_controller_spec.rb
@@ -11,39 +11,39 @@ describe NoticesController do | @@ -11,39 +11,39 @@ describe NoticesController do | ||
11 | context 'notices API' do | 11 | context 'notices API' do |
12 | context "with all params" do | 12 | context "with all params" do |
13 | before do | 13 | before do |
14 | - ErrorReport.should_receive(:new).with(xml).and_return(error_report) | 14 | + expect(ErrorReport).to receive(:new).with(xml).and_return(error_report) |
15 | end | 15 | end |
16 | 16 | ||
17 | context "with xml pass in raw_port" do | 17 | context "with xml pass in raw_port" do |
18 | before do | 18 | before do |
19 | - request.should_receive(:raw_post).and_return(xml) | 19 | + expect(request).to receive(:raw_post).and_return(xml) |
20 | post :create, :format => :xml | 20 | post :create, :format => :xml |
21 | end | 21 | end |
22 | 22 | ||
23 | it "generates a notice from raw xml [POST]" do | 23 | it "generates a notice from raw xml [POST]" do |
24 | - response.should be_success | 24 | + expect(response).to be_success |
25 | # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53) | 25 | # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53) |
26 | # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb | 26 | # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb |
27 | - response.body.should match(%r{<id[^>]*>#{notice.id}</id>}) | ||
28 | - response.body.should match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) | 27 | + expect(response.body).to match(%r{<id[^>]*>#{notice.id}</id>}) |
28 | + expect(response.body).to match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) | ||
29 | end | 29 | end |
30 | 30 | ||
31 | end | 31 | end |
32 | 32 | ||
33 | it "generates a notice from xml in a data param [POST]" do | 33 | it "generates a notice from xml in a data param [POST]" do |
34 | post :create, :data => xml, :format => :xml | 34 | post :create, :data => xml, :format => :xml |
35 | - response.should be_success | 35 | + expect(response).to be_success |
36 | # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53) | 36 | # Same RegExp from Airbrake::Sender#send_to_airbrake (https://github.com/airbrake/airbrake/blob/master/lib/airbrake/sender.rb#L53) |
37 | # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb | 37 | # Inspired by https://github.com/airbrake/airbrake/blob/master/test/sender_test.rb |
38 | - response.body.should match(%r{<id[^>]*>#{notice.id}</id>}) | ||
39 | - response.body.should match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) | 38 | + expect(response.body).to match(%r{<id[^>]*>#{notice.id}</id>}) |
39 | + expect(response.body).to match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) | ||
40 | end | 40 | end |
41 | 41 | ||
42 | it "generates a notice from xml [GET]" do | 42 | it "generates a notice from xml [GET]" do |
43 | get :create, :data => xml, :format => :xml | 43 | get :create, :data => xml, :format => :xml |
44 | - response.should be_success | ||
45 | - response.body.should match(%r{<id[^>]*>#{notice.id}</id>}) | ||
46 | - response.body.should match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) | 44 | + expect(response).to be_success |
45 | + expect(response.body).to match(%r{<id[^>]*>#{notice.id}</id>}) | ||
46 | + expect(response.body).to match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) | ||
47 | end | 47 | end |
48 | context "with an invalid API_KEY" do | 48 | context "with an invalid API_KEY" do |
49 | let(:error_report) { double(:valid? => false) } | 49 | let(:error_report) { double(:valid? => false) } |
@@ -74,7 +74,7 @@ describe NoticesController do | @@ -74,7 +74,7 @@ describe NoticesController do | ||
74 | problem = Fabricate(:problem, :app => app, :environment => "production") | 74 | problem = Fabricate(:problem, :app => app, :environment => "production") |
75 | notice = Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) | 75 | notice = Fabricate(:notice, :err => Fabricate(:err, :problem => problem)) |
76 | get :locate, :id => notice.id | 76 | get :locate, :id => notice.id |
77 | - response.should redirect_to(app_problem_path(problem.app, problem)) | 77 | + expect(response).to redirect_to(app_problem_path(problem.app, problem)) |
78 | end | 78 | end |
79 | end | 79 | end |
80 | end | 80 | end |
spec/controllers/problems_controller_spec.rb
@@ -27,13 +27,13 @@ describe ProblemsController do | @@ -27,13 +27,13 @@ describe ProblemsController do | ||
27 | 27 | ||
28 | it "should have default per_page value for user" do | 28 | it "should have default per_page value for user" do |
29 | get :index | 29 | get :index |
30 | - controller.problems.to_a.size.should == User::PER_PAGE | 30 | + expect(controller.problems.to_a.size).to eq User::PER_PAGE |
31 | end | 31 | end |
32 | 32 | ||
33 | it "should be able to override default per_page value" do | 33 | it "should be able to override default per_page value" do |
34 | @user.update_attribute :per_page, 10 | 34 | @user.update_attribute :per_page, 10 |
35 | get :index | 35 | get :index |
36 | - controller.problems.to_a.size.should == 10 | 36 | + expect(controller.problems.to_a.size).to eq 10 |
37 | end | 37 | end |
38 | end | 38 | end |
39 | 39 | ||
@@ -48,35 +48,35 @@ describe ProblemsController do | @@ -48,35 +48,35 @@ describe ProblemsController do | ||
48 | context 'no params' do | 48 | context 'no params' do |
49 | it 'shows problems for all environments' do | 49 | it 'shows problems for all environments' do |
50 | get :index | 50 | get :index |
51 | - controller.problems.size.should == 21 | 51 | + expect(controller.problems.size).to eq 21 |
52 | end | 52 | end |
53 | end | 53 | end |
54 | 54 | ||
55 | context 'environment production' do | 55 | context 'environment production' do |
56 | it 'shows problems for just production' do | 56 | it 'shows problems for just production' do |
57 | get :index, :environment => 'production' | 57 | get :index, :environment => 'production' |
58 | - controller.problems.size.should == 6 | 58 | + expect(controller.problems.size).to eq 6 |
59 | end | 59 | end |
60 | end | 60 | end |
61 | 61 | ||
62 | context 'environment staging' do | 62 | context 'environment staging' do |
63 | it 'shows problems for just staging' do | 63 | it 'shows problems for just staging' do |
64 | get :index, :environment => 'staging' | 64 | get :index, :environment => 'staging' |
65 | - controller.problems.size.should == 5 | 65 | + expect(controller.problems.size).to eq 5 |
66 | end | 66 | end |
67 | end | 67 | end |
68 | 68 | ||
69 | context 'environment development' do | 69 | context 'environment development' do |
70 | it 'shows problems for just development' do | 70 | it 'shows problems for just development' do |
71 | get :index, :environment => 'development' | 71 | get :index, :environment => 'development' |
72 | - controller.problems.size.should == 5 | 72 | + expect(controller.problems.size).to eq 5 |
73 | end | 73 | end |
74 | end | 74 | end |
75 | 75 | ||
76 | context 'environment test' do | 76 | context 'environment test' do |
77 | it 'shows problems for just test' do | 77 | it 'shows problems for just test' do |
78 | get :index, :environment => 'test' | 78 | get :index, :environment => 'test' |
79 | - controller.problems.size.should == 5 | 79 | + expect(controller.problems.size).to eq 5 |
80 | end | 80 | end |
81 | end | 81 | end |
82 | end | 82 | end |
@@ -89,8 +89,8 @@ describe ProblemsController do | @@ -89,8 +89,8 @@ describe ProblemsController do | ||
89 | watched_unresolved_err = Fabricate(:err, :problem => Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => false)) | 89 | watched_unresolved_err = Fabricate(:err, :problem => Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => false)) |
90 | watched_resolved_err = Fabricate(:err, :problem => Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => true)) | 90 | watched_resolved_err = Fabricate(:err, :problem => Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => true)) |
91 | get :index | 91 | get :index |
92 | - controller.problems.should include(watched_unresolved_err.problem) | ||
93 | - controller.problems.should_not include(unwatched_err.problem, watched_resolved_err.problem) | 92 | + expect(controller.problems).to include(watched_unresolved_err.problem) |
93 | + expect(controller.problems).to_not include(unwatched_err.problem, watched_resolved_err.problem) | ||
94 | end | 94 | end |
95 | end | 95 | end |
96 | end | 96 | end |
@@ -102,11 +102,11 @@ describe ProblemsController do | @@ -102,11 +102,11 @@ describe ProblemsController do | ||
102 | problems = Kaminari.paginate_array((1..30).to_a) | 102 | problems = Kaminari.paginate_array((1..30).to_a) |
103 | 3.times { problems << Fabricate(:err).problem } | 103 | 3.times { problems << Fabricate(:err).problem } |
104 | 3.times { problems << Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem } | 104 | 3.times { problems << Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem } |
105 | - Problem.should_receive(:ordered_by).and_return( | 105 | + expect(Problem).to receive(:ordered_by).and_return( |
106 | double('proxy', :page => double('other_proxy', :per => problems)) | 106 | double('proxy', :page => double('other_proxy', :per => problems)) |
107 | ) | 107 | ) |
108 | get :index, :all_errs => true | 108 | get :index, :all_errs => true |
109 | - controller.problems.should == problems | 109 | + expect(controller.problems).to eq problems |
110 | end | 110 | end |
111 | end | 111 | end |
112 | 112 | ||
@@ -117,8 +117,8 @@ describe ProblemsController do | @@ -117,8 +117,8 @@ describe ProblemsController do | ||
117 | watched_unresolved_problem = Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => false) | 117 | watched_unresolved_problem = Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => false) |
118 | watched_resolved_problem = Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => true) | 118 | watched_resolved_problem = Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => true) |
119 | get :index, :all_errs => true | 119 | get :index, :all_errs => true |
120 | - controller.problems.should include(watched_resolved_problem, watched_unresolved_problem) | ||
121 | - controller.problems.should_not include(unwatched_problem) | 120 | + expect(controller.problems).to include(watched_resolved_problem, watched_unresolved_problem) |
121 | + expect(controller.problems).to_not include(unwatched_problem) | ||
122 | end | 122 | end |
123 | end | 123 | end |
124 | end | 124 | end |
@@ -133,17 +133,17 @@ describe ProblemsController do | @@ -133,17 +133,17 @@ describe ProblemsController do | ||
133 | 133 | ||
134 | it "finds the app" do | 134 | it "finds the app" do |
135 | get :show, :app_id => app.id, :id => err.problem.id | 135 | get :show, :app_id => app.id, :id => err.problem.id |
136 | - controller.app.should == app | 136 | + expect(controller.app).to eq app |
137 | end | 137 | end |
138 | 138 | ||
139 | it "finds the problem" do | 139 | it "finds the problem" do |
140 | get :show, :app_id => app.id, :id => err.problem.id | 140 | get :show, :app_id => app.id, :id => err.problem.id |
141 | - controller.problem.should == err.problem | 141 | + expect(controller.problem).to eq err.problem |
142 | end | 142 | end |
143 | 143 | ||
144 | it "successfully render page" do | 144 | it "successfully render page" do |
145 | get :show, :app_id => app.id, :id => err.problem.id | 145 | get :show, :app_id => app.id, :id => err.problem.id |
146 | - response.should be_success | 146 | + expect(response).to be_success |
147 | end | 147 | end |
148 | 148 | ||
149 | context 'pagination' do | 149 | context 'pagination' do |
@@ -155,14 +155,14 @@ describe ProblemsController do | @@ -155,14 +155,14 @@ describe ProblemsController do | ||
155 | 155 | ||
156 | it "paginates the notices 1 at a time, starting with the most recent" do | 156 | it "paginates the notices 1 at a time, starting with the most recent" do |
157 | get :show, :app_id => app.id, :id => err.problem.id | 157 | get :show, :app_id => app.id, :id => err.problem.id |
158 | - assigns(:notices).entries.count.should == 1 | ||
159 | - assigns(:notices).should include(notices.last) | 158 | + expect(assigns(:notices).entries.count).to eq 1 |
159 | + expect(assigns(:notices)).to include(notices.last) | ||
160 | end | 160 | end |
161 | 161 | ||
162 | it "paginates the notices 1 at a time, based on then notice param" do | 162 | it "paginates the notices 1 at a time, based on then notice param" do |
163 | get :show, :app_id => app.id, :id => err.problem.id, :notice => 3 | 163 | get :show, :app_id => app.id, :id => err.problem.id, :notice => 3 |
164 | - assigns(:notices).entries.count.should == 1 | ||
165 | - assigns(:notices).should include(notices.first) | 164 | + expect(assigns(:notices).entries.count).to eq 1 |
165 | + expect(assigns(:notices)).to include(notices.first) | ||
166 | end | 166 | end |
167 | end | 167 | end |
168 | 168 | ||
@@ -179,13 +179,13 @@ describe ProblemsController do | @@ -179,13 +179,13 @@ describe ProblemsController do | ||
179 | 179 | ||
180 | it 'finds the problem if the user is watching the app' do | 180 | it 'finds the problem if the user is watching the app' do |
181 | get :show, :app_id => @watched_app.to_param, :id => @watched_err.problem.id | 181 | get :show, :app_id => @watched_app.to_param, :id => @watched_err.problem.id |
182 | - controller.problem.should == @watched_err.problem | 182 | + expect(controller.problem).to eq @watched_err.problem |
183 | end | 183 | end |
184 | 184 | ||
185 | it 'raises a DocumentNotFound error if the user is not watching the app' do | 185 | it 'raises a DocumentNotFound error if the user is not watching the app' do |
186 | - lambda { | 186 | + expect { |
187 | get :show, :app_id => @unwatched_err.problem.app_id, :id => @unwatched_err.problem.id | 187 | get :show, :app_id => @unwatched_err.problem.app_id, :id => @unwatched_err.problem.id |
188 | - }.should raise_error(Mongoid::Errors::DocumentNotFound) | 188 | + }.to raise_error(Mongoid::Errors::DocumentNotFound) |
189 | end | 189 | end |
190 | end | 190 | end |
191 | end | 191 | end |
@@ -201,32 +201,32 @@ describe ProblemsController do | @@ -201,32 +201,32 @@ describe ProblemsController do | ||
201 | end | 201 | end |
202 | 202 | ||
203 | it 'finds the app and the problem' do | 203 | it 'finds the app and the problem' do |
204 | - App.should_receive(:find).with(@problem.app.id.to_s).and_return(@problem.app) | ||
205 | - @problem.app.problems.should_receive(:find).and_return(@problem.problem) | 204 | + expect(App).to receive(:find).with(@problem.app.id.to_s).and_return(@problem.app) |
205 | + expect(@problem.app.problems).to receive(:find).and_return(@problem.problem) | ||
206 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | 206 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id |
207 | - controller.app.should == @problem.app | ||
208 | - controller.problem.should == @problem.problem | 207 | + expect(controller.app).to eq @problem.app |
208 | + expect(controller.problem).to eq @problem.problem | ||
209 | end | 209 | end |
210 | 210 | ||
211 | it "should resolve the issue" do | 211 | it "should resolve the issue" do |
212 | - @problem.problem.should_receive(:resolve!).and_return(true) | 212 | + expect(@problem.problem).to receive(:resolve!).and_return(true) |
213 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | 213 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id |
214 | end | 214 | end |
215 | 215 | ||
216 | it "should display a message" do | 216 | it "should display a message" do |
217 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | 217 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id |
218 | - request.flash[:success].should match(/Great news/) | 218 | + expect(request.flash[:success]).to match(/Great news/) |
219 | end | 219 | end |
220 | 220 | ||
221 | it "should redirect to the app page" do | 221 | it "should redirect to the app page" do |
222 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | 222 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id |
223 | - response.should redirect_to(app_path(@problem.app)) | 223 | + expect(response).to redirect_to(app_path(@problem.app)) |
224 | end | 224 | end |
225 | 225 | ||
226 | it "should redirect back to problems page" do | 226 | it "should redirect back to problems page" do |
227 | request.env["Referer"] = problems_path | 227 | request.env["Referer"] = problems_path |
228 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id | 228 | put :resolve, :app_id => @problem.app.id, :id => @problem.problem.id |
229 | - response.should redirect_to(problems_path) | 229 | + expect(response).to redirect_to(problems_path) |
230 | end | 230 | end |
231 | end | 231 | end |
232 | 232 | ||
@@ -255,7 +255,7 @@ describe ProblemsController do | @@ -255,7 +255,7 @@ describe ProblemsController do | ||
255 | end | 255 | end |
256 | 256 | ||
257 | it "should redirect to problem page" do | 257 | it "should redirect to problem page" do |
258 | - response.should redirect_to( app_problem_path(problem.app, problem) ) | 258 | + expect(response).to redirect_to( app_problem_path(problem.app, problem) ) |
259 | end | 259 | end |
260 | end | 260 | end |
261 | end | 261 | end |
@@ -268,11 +268,11 @@ describe ProblemsController do | @@ -268,11 +268,11 @@ describe ProblemsController do | ||
268 | end | 268 | end |
269 | 269 | ||
270 | it "should redirect to problem page" do | 270 | it "should redirect to problem page" do |
271 | - response.should redirect_to( app_problem_path(problem.app, problem) ) | 271 | + expect(response).to redirect_to( app_problem_path(problem.app, problem) ) |
272 | end | 272 | end |
273 | 273 | ||
274 | it "should set flash error message telling issue tracker of the app doesn't exist" do | 274 | it "should set flash error message telling issue tracker of the app doesn't exist" do |
275 | - flash[:error].should == "This app has no issue tracker setup." | 275 | + expect(flash[:error]).to eq "This app has no issue tracker setup." |
276 | end | 276 | end |
277 | end | 277 | end |
278 | 278 | ||
@@ -288,11 +288,11 @@ describe ProblemsController do | @@ -288,11 +288,11 @@ describe ProblemsController do | ||
288 | end | 288 | end |
289 | 289 | ||
290 | it "should redirect to problem page" do | 290 | it "should redirect to problem page" do |
291 | - response.should redirect_to( app_problem_path(err.app, err.problem) ) | 291 | + expect(response).to redirect_to( app_problem_path(err.app, err.problem) ) |
292 | end | 292 | end |
293 | 293 | ||
294 | it "should notify of connection error" do | 294 | it "should notify of connection error" do |
295 | - flash[:error].should include("There was an error during issue creation:") | 295 | + expect(flash[:error]).to include("There was an error during issue creation:") |
296 | end | 296 | end |
297 | end | 297 | end |
298 | end | 298 | end |
@@ -312,11 +312,11 @@ describe ProblemsController do | @@ -312,11 +312,11 @@ describe ProblemsController do | ||
312 | end | 312 | end |
313 | 313 | ||
314 | it "should redirect to problem page" do | 314 | it "should redirect to problem page" do |
315 | - response.should redirect_to( app_problem_path(err.app, err.problem) ) | 315 | + expect(response).to redirect_to( app_problem_path(err.app, err.problem) ) |
316 | end | 316 | end |
317 | 317 | ||
318 | it "should clear issue link" do | 318 | it "should clear issue link" do |
319 | - err.problem.issue_link.should be_nil | 319 | + expect(err.problem.issue_link).to be_nil |
320 | end | 320 | end |
321 | end | 321 | end |
322 | 322 | ||
@@ -329,7 +329,7 @@ describe ProblemsController do | @@ -329,7 +329,7 @@ describe ProblemsController do | ||
329 | end | 329 | end |
330 | 330 | ||
331 | it "should redirect to problem page" do | 331 | it "should redirect to problem page" do |
332 | - response.should redirect_to( app_problem_path(err.app, err.problem) ) | 332 | + expect(response).to redirect_to( app_problem_path(err.app, err.problem) ) |
333 | end | 333 | end |
334 | end | 334 | end |
335 | end | 335 | end |
@@ -344,11 +344,11 @@ describe ProblemsController do | @@ -344,11 +344,11 @@ describe ProblemsController do | ||
344 | context "POST /problems/merge_several" do | 344 | context "POST /problems/merge_several" do |
345 | it "should require at least two problems" do | 345 | it "should require at least two problems" do |
346 | post :merge_several, :problems => [@problem1.id.to_s] | 346 | post :merge_several, :problems => [@problem1.id.to_s] |
347 | - request.flash[:notice].should eql I18n.t('controllers.problems.flash.need_two_errors_merge') | 347 | + expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.need_two_errors_merge') |
348 | end | 348 | end |
349 | 349 | ||
350 | it "should merge the problems" do | 350 | it "should merge the problems" do |
351 | - ProblemMerge.should_receive(:new).and_return(double(:merge => true)) | 351 | + expect(ProblemMerge).to receive(:new).and_return(double(:merge => true)) |
352 | post :merge_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] | 352 | post :merge_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] |
353 | end | 353 | end |
354 | end | 354 | end |
@@ -357,16 +357,16 @@ describe ProblemsController do | @@ -357,16 +357,16 @@ describe ProblemsController do | ||
357 | 357 | ||
358 | it "should require at least one problem" do | 358 | it "should require at least one problem" do |
359 | post :unmerge_several, :problems => [] | 359 | post :unmerge_several, :problems => [] |
360 | - request.flash[:notice].should eql I18n.t('controllers.problems.flash.no_select_problem') | 360 | + expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') |
361 | end | 361 | end |
362 | 362 | ||
363 | it "should unmerge a merged problem" do | 363 | it "should unmerge a merged problem" do |
364 | merged_problem = Problem.merge!(@problem1, @problem2) | 364 | merged_problem = Problem.merge!(@problem1, @problem2) |
365 | - merged_problem.errs.length.should == 2 | ||
366 | - lambda { | 365 | + expect(merged_problem.errs.length).to eq 2 |
366 | + expect{ | ||
367 | post :unmerge_several, :problems => [merged_problem.id.to_s] | 367 | post :unmerge_several, :problems => [merged_problem.id.to_s] |
368 | - merged_problem.reload.errs.length.should == 1 | ||
369 | - }.should change(Problem, :count).by(1) | 368 | + expect(merged_problem.reload.errs.length).to eq 1 |
369 | + }.to change(Problem, :count).by(1) | ||
370 | end | 370 | end |
371 | 371 | ||
372 | end | 372 | end |
@@ -375,23 +375,23 @@ describe ProblemsController do | @@ -375,23 +375,23 @@ describe ProblemsController do | ||
375 | 375 | ||
376 | it "should require at least one problem" do | 376 | it "should require at least one problem" do |
377 | post :resolve_several, :problems => [] | 377 | post :resolve_several, :problems => [] |
378 | - request.flash[:notice].should eql I18n.t('controllers.problems.flash.no_select_problem') | 378 | + expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') |
379 | end | 379 | end |
380 | 380 | ||
381 | it "should resolve the issue" do | 381 | it "should resolve the issue" do |
382 | post :resolve_several, :problems => [@problem2.id.to_s] | 382 | post :resolve_several, :problems => [@problem2.id.to_s] |
383 | - @problem2.reload.resolved?.should == true | 383 | + expect(@problem2.reload.resolved?).to eq true |
384 | end | 384 | end |
385 | 385 | ||
386 | it "should display a message about 1 err" do | 386 | it "should display a message about 1 err" do |
387 | post :resolve_several, :problems => [@problem2.id.to_s] | 387 | post :resolve_several, :problems => [@problem2.id.to_s] |
388 | - flash[:success].should match(/1 err has been resolved/) | 388 | + expect(flash[:success]).to match(/1 err has been resolved/) |
389 | end | 389 | end |
390 | 390 | ||
391 | it "should display a message about 2 errs" do | 391 | it "should display a message about 2 errs" do |
392 | post :resolve_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] | 392 | post :resolve_several, :problems => [@problem1.id.to_s, @problem2.id.to_s] |
393 | - flash[:success].should match(/2 errs have been resolved/) | ||
394 | - controller.selected_problems.should == [@problem1, @problem2] | 393 | + expect(flash[:success]).to match(/2 errs have been resolved/) |
394 | + expect(controller.selected_problems).to eq [@problem1, @problem2] | ||
395 | end | 395 | end |
396 | end | 396 | end |
397 | 397 | ||
@@ -399,20 +399,20 @@ describe ProblemsController do | @@ -399,20 +399,20 @@ describe ProblemsController do | ||
399 | 399 | ||
400 | it "should require at least one problem" do | 400 | it "should require at least one problem" do |
401 | post :unresolve_several, :problems => [] | 401 | post :unresolve_several, :problems => [] |
402 | - request.flash[:notice].should eql I18n.t('controllers.problems.flash.no_select_problem') | 402 | + expect(request.flash[:notice]).to eql I18n.t('controllers.problems.flash.no_select_problem') |
403 | end | 403 | end |
404 | 404 | ||
405 | it "should unresolve the issue" do | 405 | it "should unresolve the issue" do |
406 | post :unresolve_several, :problems => [@problem1.id.to_s] | 406 | post :unresolve_several, :problems => [@problem1.id.to_s] |
407 | - @problem1.reload.resolved?.should == false | 407 | + expect(@problem1.reload.resolved?).to eq false |
408 | end | 408 | end |
409 | end | 409 | end |
410 | 410 | ||
411 | context "POST /problems/destroy_several" do | 411 | context "POST /problems/destroy_several" do |
412 | it "should delete the problems" do | 412 | it "should delete the problems" do |
413 | - lambda { | 413 | + expect{ |
414 | post :destroy_several, :problems => [@problem1.id.to_s] | 414 | post :destroy_several, :problems => [@problem1.id.to_s] |
415 | - }.should change(Problem, :count).by(-1) | 415 | + }.to change(Problem, :count).by(-1) |
416 | end | 416 | end |
417 | end | 417 | end |
418 | end | 418 | end |
spec/controllers/users/omniauth_callbacks_controller_spec.rb
@@ -25,16 +25,16 @@ describe Users::OmniauthCallbacksController do | @@ -25,16 +25,16 @@ describe Users::OmniauthCallbacksController do | ||
25 | stub_env_for_github_omniauth("existing_user") | 25 | stub_env_for_github_omniauth("existing_user") |
26 | get :github | 26 | get :github |
27 | 27 | ||
28 | - request.flash[:error].should include('already registered') | ||
29 | - response.should redirect_to(user_path(@user)) | 28 | + expect(request.flash[:error]).to include('already registered') |
29 | + expect(response).to redirect_to(user_path(@user)) | ||
30 | end | 30 | end |
31 | 31 | ||
32 | it "should link an authorized GitHub account" do | 32 | it "should link an authorized GitHub account" do |
33 | stub_env_for_github_omniauth("new_user") | 33 | stub_env_for_github_omniauth("new_user") |
34 | get :github | 34 | get :github |
35 | 35 | ||
36 | - request.flash[:success].should include('Successfully linked') | ||
37 | - response.should redirect_to(user_path(@user)) | 36 | + expect(request.flash[:success]).to include('Successfully linked') |
37 | + expect(response).to redirect_to(user_path(@user)) | ||
38 | end | 38 | end |
39 | end | 39 | end |
40 | 40 |
spec/controllers/users_controller_spec.rb
@@ -22,20 +22,20 @@ describe UsersController do | @@ -22,20 +22,20 @@ describe UsersController do | ||
22 | end | 22 | end |
23 | 23 | ||
24 | it "should set a time zone" do | 24 | it "should set a time zone" do |
25 | - Time.zone.should.to_s == user.time_zone | 25 | + expect(Time.zone.to_s).to match(user.time_zone) |
26 | end | 26 | end |
27 | 27 | ||
28 | context "GET /users/:other_id/edit" do | 28 | context "GET /users/:other_id/edit" do |
29 | it "redirects to the home page" do | 29 | it "redirects to the home page" do |
30 | get :edit, :id => other_user.id | 30 | get :edit, :id => other_user.id |
31 | - response.should redirect_to(root_path) | 31 | + expect(response).to redirect_to(root_path) |
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 | ||
35 | context "GET /users/:my_id/edit" do | 35 | context "GET /users/:my_id/edit" do |
36 | it 'finds the user' do | 36 | it 'finds the user' do |
37 | get :edit, :id => user.id | 37 | get :edit, :id => user.id |
38 | - controller.user.should == user | 38 | + expect(controller.user).to eq user |
39 | expect(response).to render_template 'edit' | 39 | expect(response).to render_template 'edit' |
40 | end | 40 | end |
41 | 41 | ||
@@ -44,7 +44,7 @@ describe UsersController do | @@ -44,7 +44,7 @@ describe UsersController do | ||
44 | context "PUT /users/:other_id" do | 44 | context "PUT /users/:other_id" do |
45 | it "redirects to the home page" do | 45 | it "redirects to the home page" do |
46 | put :update, :id => other_user.id | 46 | put :update, :id => other_user.id |
47 | - response.should redirect_to(root_path) | 47 | + expect(response).to redirect_to(root_path) |
48 | end | 48 | end |
49 | end | 49 | end |
50 | 50 | ||
@@ -52,12 +52,12 @@ describe UsersController do | @@ -52,12 +52,12 @@ describe UsersController do | ||
52 | context "when the update is successful" do | 52 | context "when the update is successful" do |
53 | it "sets a message to display" do | 53 | it "sets a message to display" do |
54 | put :update, :id => user.to_param, :user => {:name => 'Kermit'} | 54 | put :update, :id => user.to_param, :user => {:name => 'Kermit'} |
55 | - request.flash[:success].should include('updated') | 55 | + expect(request.flash[:success]).to include('updated') |
56 | end | 56 | end |
57 | 57 | ||
58 | it "redirects to the user's page" do | 58 | it "redirects to the user's page" do |
59 | put :update, :id => user.to_param, :user => {:name => 'Kermit'} | 59 | put :update, :id => user.to_param, :user => {:name => 'Kermit'} |
60 | - response.should redirect_to(user_path(user)) | 60 | + expect(response).to redirect_to(user_path(user)) |
61 | end | 61 | end |
62 | 62 | ||
63 | it "should not be able to become an admin" do | 63 | it "should not be able to become an admin" do |
@@ -70,29 +70,29 @@ describe UsersController do | @@ -70,29 +70,29 @@ describe UsersController do | ||
70 | 70 | ||
71 | it "should be able to set per_page option" do | 71 | it "should be able to set per_page option" do |
72 | put :update, :id => user.to_param, :user => {:per_page => 555} | 72 | put :update, :id => user.to_param, :user => {:per_page => 555} |
73 | - user.reload.per_page.should == 555 | 73 | + expect(user.reload.per_page).to eq 555 |
74 | end | 74 | end |
75 | 75 | ||
76 | it "should be able to set time_zone option" do | 76 | it "should be able to set time_zone option" do |
77 | put :update, :id => user.to_param, :user => {:time_zone => "Warsaw"} | 77 | put :update, :id => user.to_param, :user => {:time_zone => "Warsaw"} |
78 | - user.reload.time_zone.should == "Warsaw" | 78 | + expect(user.reload.time_zone).to eq "Warsaw" |
79 | end | 79 | end |
80 | 80 | ||
81 | it "should be able to not set github_login option" do | 81 | it "should be able to not set github_login option" do |
82 | put :update, :id => user.to_param, :user => {:github_login => " "} | 82 | put :update, :id => user.to_param, :user => {:github_login => " "} |
83 | - user.reload.github_login.should == nil | 83 | + expect(user.reload.github_login).to eq nil |
84 | end | 84 | end |
85 | 85 | ||
86 | it "should be able to set github_login option" do | 86 | it "should be able to set github_login option" do |
87 | put :update, :id => user.to_param, :user => {:github_login => "awesome_name"} | 87 | put :update, :id => user.to_param, :user => {:github_login => "awesome_name"} |
88 | - user.reload.github_login.should == "awesome_name" | 88 | + expect(user.reload.github_login).to eq "awesome_name" |
89 | end | 89 | end |
90 | end | 90 | end |
91 | 91 | ||
92 | context "when the update is unsuccessful" do | 92 | context "when the update is unsuccessful" do |
93 | it "renders the edit page" do | 93 | it "renders the edit page" do |
94 | put :update, :id => user.to_param, :user => {:name => nil} | 94 | put :update, :id => user.to_param, :user => {:name => nil} |
95 | - response.should render_template(:edit) | 95 | + expect(response).to render_template(:edit) |
96 | end | 96 | end |
97 | end | 97 | end |
98 | end | 98 | end |
@@ -111,7 +111,7 @@ describe UsersController do | @@ -111,7 +111,7 @@ describe UsersController do | ||
111 | Fabricate(:user) | 111 | Fabricate(:user) |
112 | } | 112 | } |
113 | get :index | 113 | get :index |
114 | - controller.users.to_a.size.should == 2 | 114 | + expect(controller.users.to_a.size).to eq 2 |
115 | end | 115 | end |
116 | 116 | ||
117 | end | 117 | end |
@@ -119,22 +119,22 @@ describe UsersController do | @@ -119,22 +119,22 @@ describe UsersController do | ||
119 | context "GET /users/:id" do | 119 | context "GET /users/:id" do |
120 | it 'finds the user' do | 120 | it 'finds the user' do |
121 | get :show, :id => user.id | 121 | get :show, :id => user.id |
122 | - controller.user.should == user | 122 | + expect(controller.user).to eq user |
123 | end | 123 | end |
124 | end | 124 | end |
125 | 125 | ||
126 | context "GET /users/new" do | 126 | context "GET /users/new" do |
127 | it 'assigns a new user' do | 127 | it 'assigns a new user' do |
128 | get :new | 128 | get :new |
129 | - controller.user.should be_a(User) | ||
130 | - controller.user.should be_new_record | 129 | + expect(controller.user).to be_a(User) |
130 | + expect(controller.user).to be_new_record | ||
131 | end | 131 | end |
132 | end | 132 | end |
133 | 133 | ||
134 | context "GET /users/:id/edit" do | 134 | context "GET /users/:id/edit" do |
135 | it 'finds the user' do | 135 | it 'finds the user' do |
136 | get :edit, :id => user.id | 136 | get :edit, :id => user.id |
137 | - controller.user.should == user | 137 | + expect(controller.user).to eq user |
138 | end | 138 | end |
139 | end | 139 | end |
140 | 140 | ||
@@ -144,24 +144,24 @@ describe UsersController do | @@ -144,24 +144,24 @@ describe UsersController do | ||
144 | 144 | ||
145 | it "sets a message to display" do | 145 | it "sets a message to display" do |
146 | post :create, attrs | 146 | post :create, attrs |
147 | - request.flash[:success].should include('part of the team') | 147 | + expect(request.flash[:success]).to include('part of the team') |
148 | end | 148 | end |
149 | 149 | ||
150 | it "redirects to the user's page" do | 150 | it "redirects to the user's page" do |
151 | post :create, attrs | 151 | post :create, attrs |
152 | - response.should redirect_to(user_path(controller.user)) | 152 | + expect(response).to redirect_to(user_path(controller.user)) |
153 | end | 153 | end |
154 | 154 | ||
155 | it "should be able to create admin" do | 155 | it "should be able to create admin" do |
156 | attrs[:user][:admin] = true | 156 | attrs[:user][:admin] = true |
157 | post :create, attrs | 157 | post :create, attrs |
158 | - response.should be_redirect | ||
159 | - User.find(controller.user.to_param).admin.should be_true | 158 | + expect(response).to be_redirect |
159 | + expect(User.find(controller.user.to_param).admin).to be_true | ||
160 | end | 160 | end |
161 | 161 | ||
162 | it "should has auth token" do | 162 | it "should has auth token" do |
163 | post :create, attrs | 163 | post :create, attrs |
164 | - User.last.authentication_token.should_not be_blank | 164 | + expect(User.last.authentication_token).to_not be_blank |
165 | end | 165 | end |
166 | end | 166 | end |
167 | 167 | ||
@@ -170,13 +170,13 @@ describe UsersController do | @@ -170,13 +170,13 @@ describe UsersController do | ||
170 | Struct.new(:admin, :attributes).new(true, {}) | 170 | Struct.new(:admin, :attributes).new(true, {}) |
171 | } | 171 | } |
172 | before do | 172 | before do |
173 | - User.should_receive(:new).and_return(user) | ||
174 | - user.should_receive(:save).and_return(false) | 173 | + expect(User).to receive(:new).and_return(user) |
174 | + expect(user).to receive(:save).and_return(false) | ||
175 | end | 175 | end |
176 | 176 | ||
177 | it "renders the new page" do | 177 | it "renders the new page" do |
178 | post :create, :user => { :username => 'foo' } | 178 | post :create, :user => { :username => 'foo' } |
179 | - response.should render_template(:new) | 179 | + expect(response).to render_template(:new) |
180 | end | 180 | end |
181 | end | 181 | end |
182 | end | 182 | end |
@@ -199,7 +199,7 @@ describe UsersController do | @@ -199,7 +199,7 @@ describe UsersController do | ||
199 | 199 | ||
200 | it "renders the edit page" do | 200 | it "renders the edit page" do |
201 | put :update, :id => user.to_param, :user => {:name => nil} | 201 | put :update, :id => user.to_param, :user => {:name => nil} |
202 | - response.should render_template(:edit) | 202 | + expect(response).to render_template(:edit) |
203 | end | 203 | end |
204 | end | 204 | end |
205 | end | 205 | end |
@@ -210,24 +210,24 @@ describe UsersController do | @@ -210,24 +210,24 @@ describe UsersController do | ||
210 | let(:user_destroy) { double(:destroy => true) } | 210 | let(:user_destroy) { double(:destroy => true) } |
211 | 211 | ||
212 | before { | 212 | before { |
213 | - UserDestroy.should_receive(:new).with(user).and_return(user_destroy) | 213 | + expect(UserDestroy).to receive(:new).with(user).and_return(user_destroy) |
214 | delete :destroy, :id => user.id | 214 | delete :destroy, :id => user.id |
215 | } | 215 | } |
216 | 216 | ||
217 | it 'should destroy user' do | 217 | it 'should destroy user' do |
218 | expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', :name => user.name) | 218 | expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', :name => user.name) |
219 | - response.should redirect_to(users_path) | 219 | + expect(response).to redirect_to(users_path) |
220 | end | 220 | end |
221 | end | 221 | end |
222 | 222 | ||
223 | context "with trying destroy himself" do | 223 | context "with trying destroy himself" do |
224 | before { | 224 | before { |
225 | - UserDestroy.should_not_receive(:new) | 225 | + expect(UserDestroy).to_not receive(:new) |
226 | delete :destroy, :id => admin.id | 226 | delete :destroy, :id => admin.id |
227 | } | 227 | } |
228 | 228 | ||
229 | it 'should not destroy user' do | 229 | it 'should not destroy user' do |
230 | - response.should redirect_to(users_path) | 230 | + expect(response).to redirect_to(users_path) |
231 | expect(request.flash[:error]).to eq I18n.t('controllers.users.flash.destroy.error') | 231 | expect(request.flash[:error]).to eq I18n.t('controllers.users.flash.destroy.error') |
232 | end | 232 | end |
233 | end | 233 | end |
spec/controllers/watchers_controller_spec.rb
@@ -24,11 +24,11 @@ describe WatchersController do | @@ -24,11 +24,11 @@ describe WatchersController do | ||
24 | end | 24 | end |
25 | 25 | ||
26 | it "should delete the watcher" do | 26 | it "should delete the watcher" do |
27 | - app.watchers.detect{|w| w.id.to_s == watcher.id }.should == nil | 27 | + expect(app.watchers.detect{|w| w.id.to_s == watcher.id }).to be nil |
28 | end | 28 | end |
29 | 29 | ||
30 | it "should redirect to index page" do | 30 | it "should redirect to index page" do |
31 | - response.should redirect_to(root_path) | 31 | + expect(response).to redirect_to(root_path) |
32 | end | 32 | end |
33 | end | 33 | end |
34 | end | 34 | end |
spec/helpers/navigation_helper_spec.rb
@@ -3,13 +3,13 @@ require 'spec_helper' | @@ -3,13 +3,13 @@ require 'spec_helper' | ||
3 | describe NavigationHelper do | 3 | describe NavigationHelper do |
4 | describe '#page_count_from_end' do | 4 | describe '#page_count_from_end' do |
5 | it 'returns the page number when counting from the last occurrence of a notice' do | 5 | it 'returns the page number when counting from the last occurrence of a notice' do |
6 | - page_count_from_end(1, 6).should == 6 | ||
7 | - page_count_from_end(6, 6).should == 1 | ||
8 | - page_count_from_end(2, 6).should == 5 | 6 | + expect(page_count_from_end(1, 6)).to eq 6 |
7 | + expect(page_count_from_end(6, 6)).to eq 1 | ||
8 | + expect(page_count_from_end(2, 6)).to eq 5 | ||
9 | end | 9 | end |
10 | 10 | ||
11 | it 'properly handles strings for input' do | 11 | it 'properly handles strings for input' do |
12 | - page_count_from_end('2', '6').should == 5 | 12 | + expect(page_count_from_end('2', '6')).to eq 5 |
13 | end | 13 | end |
14 | end | 14 | end |
15 | end | 15 | end |
spec/helpers/problems_helper_spec.rb
@@ -5,8 +5,8 @@ describe ProblemsHelper do | @@ -5,8 +5,8 @@ describe ProblemsHelper do | ||
5 | it 'is html safe' do | 5 | it 'is html safe' do |
6 | problem = double('problem', :message => '#<NoMethodError: ...>') | 6 | problem = double('problem', :message => '#<NoMethodError: ...>') |
7 | truncated = helper.truncated_problem_message(problem) | 7 | truncated = helper.truncated_problem_message(problem) |
8 | - truncated.should be_html_safe | ||
9 | - truncated.should_not include('<', '>') | 8 | + expect(truncated).to be_html_safe |
9 | + expect(truncated).to_not include('<', '>') | ||
10 | end | 10 | end |
11 | end | 11 | end |
12 | 12 | ||
@@ -23,18 +23,18 @@ describe ProblemsHelper do | @@ -23,18 +23,18 @@ describe ProblemsHelper do | ||
23 | 23 | ||
24 | it "should render image_tag with correct alt and src" do | 24 | it "should render image_tag with correct alt and src" do |
25 | expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=identicon&s=48\" />" | 25 | expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=identicon&s=48\" />" |
26 | - helper.gravatar_tag(email, :s => 48).should eq(expected) | 26 | + expect(helper.gravatar_tag(email, :s => 48)).to eq(expected) |
27 | end | 27 | end |
28 | 28 | ||
29 | it "should override :d" do | 29 | it "should override :d" do |
30 | expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=retro&s=48\" />" | 30 | expected = "<img alt=\"#{email}\" class=\"gravatar\" src=\"#{base_url}?d=retro&s=48\" />" |
31 | - helper.gravatar_tag(email, :d => 'retro', :s => 48).should eq(expected) | 31 | + expect(helper.gravatar_tag(email, :d => 'retro', :s => 48)).to eq(expected) |
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 | ||
35 | context "no email" do | 35 | context "no email" do |
36 | it "should not render the tag" do | 36 | it "should not render the tag" do |
37 | - helper.gravatar_tag(nil).should be_nil | 37 | + expect(helper.gravatar_tag(nil)).to be_nil |
38 | end | 38 | end |
39 | end | 39 | end |
40 | end | 40 | end |
@@ -44,7 +44,7 @@ describe ProblemsHelper do | @@ -44,7 +44,7 @@ describe ProblemsHelper do | ||
44 | let(:email) { nil } | 44 | let(:email) { nil } |
45 | 45 | ||
46 | it "should return nil" do | 46 | it "should return nil" do |
47 | - helper.gravatar_url(email).should be_nil | 47 | + expect(helper.gravatar_url(email)).to be_nil |
48 | end | 48 | end |
49 | end | 49 | end |
50 | 50 | ||
@@ -53,7 +53,7 @@ describe ProblemsHelper do | @@ -53,7 +53,7 @@ describe ProblemsHelper do | ||
53 | let(:email_hash) { Digest::MD5.hexdigest email } | 53 | let(:email_hash) { Digest::MD5.hexdigest email } |
54 | 54 | ||
55 | it "should return the http url" do | 55 | it "should return the http url" do |
56 | - helper.gravatar_url(email).should eq("http://www.gravatar.com/avatar/#{email_hash}?d=identicon") | 56 | + expect(helper.gravatar_url(email)).to eq("http://www.gravatar.com/avatar/#{email_hash}?d=identicon") |
57 | end | 57 | end |
58 | end | 58 | end |
59 | 59 | ||
@@ -63,7 +63,7 @@ describe ProblemsHelper do | @@ -63,7 +63,7 @@ describe ProblemsHelper do | ||
63 | 63 | ||
64 | it "should return the http url" do | 64 | it "should return the http url" do |
65 | ActionController::TestRequest.any_instance.stub :ssl? => true | 65 | ActionController::TestRequest.any_instance.stub :ssl? => true |
66 | - helper.gravatar_url(email).should eq("https://secure.gravatar.com/avatar/#{email_hash}?d=identicon") | 66 | + expect(helper.gravatar_url(email)).to eq("https://secure.gravatar.com/avatar/#{email_hash}?d=identicon") |
67 | end | 67 | end |
68 | end | 68 | end |
69 | end | 69 | end |
spec/interactors/issue_creation_spec.rb
@@ -16,7 +16,7 @@ describe IssueCreation do | @@ -16,7 +16,7 @@ describe IssueCreation do | ||
16 | 16 | ||
17 | it 'creates an issue if issue tracker is configured' do | 17 | it 'creates an issue if issue tracker is configured' do |
18 | tracker = Fabricate(:lighthouse_tracker, :app => notice.app) | 18 | tracker = Fabricate(:lighthouse_tracker, :app => notice.app) |
19 | - tracker.should_receive(:create_issue) | 19 | + expect(tracker).to receive(:create_issue) |
20 | issue_creation.execute | 20 | issue_creation.execute |
21 | expect(errors).to be_empty | 21 | expect(errors).to be_empty |
22 | end | 22 | end |
spec/interactors/problem_destroy_spec.rb
@@ -21,28 +21,28 @@ describe ProblemDestroy do | @@ -21,28 +21,28 @@ describe ProblemDestroy do | ||
21 | 21 | ||
22 | describe "#initialize" do | 22 | describe "#initialize" do |
23 | it 'take a problem like args' do | 23 | it 'take a problem like args' do |
24 | - problem_destroy.problem.should == problem | 24 | + expect(problem_destroy.problem).to eq problem |
25 | end | 25 | end |
26 | end | 26 | end |
27 | 27 | ||
28 | describe "#execute" do | 28 | describe "#execute" do |
29 | it 'destroy the problem himself' do | 29 | it 'destroy the problem himself' do |
30 | - problem.should_receive(:delete).and_return(true) | 30 | + expect(problem).to receive(:delete).and_return(true) |
31 | problem_destroy.execute | 31 | problem_destroy.execute |
32 | end | 32 | end |
33 | 33 | ||
34 | it 'delete all errs associate' do | 34 | it 'delete all errs associate' do |
35 | - Err.should_receive(:delete_all).with(:_id => { '$in' => [err_1.id, err_2.id] }) | 35 | + expect(Err).to receive(:delete_all).with(:_id => { '$in' => [err_1.id, err_2.id] }) |
36 | problem_destroy.execute | 36 | problem_destroy.execute |
37 | end | 37 | end |
38 | 38 | ||
39 | it 'delete all comments associate' do | 39 | it 'delete all comments associate' do |
40 | - Comment.should_receive(:delete_all).with(:_id => { '$in' => [comment_1.id, comment_2.id] }) | 40 | + expect(Comment).to receive(:delete_all).with(:_id => { '$in' => [comment_1.id, comment_2.id] }) |
41 | problem_destroy.execute | 41 | problem_destroy.execute |
42 | end | 42 | end |
43 | 43 | ||
44 | it 'delete all notice of associate to this errs' do | 44 | it 'delete all notice of associate to this errs' do |
45 | - Notice.should_receive(:delete_all).with({:err_id => { '$in' => [err_1.id, err_2.id] }}) | 45 | + expect(Notice).to receive(:delete_all).with({:err_id => { '$in' => [err_1.id, err_2.id] }}) |
46 | problem_destroy.execute | 46 | problem_destroy.execute |
47 | end | 47 | end |
48 | end | 48 | end |
@@ -62,15 +62,15 @@ describe ProblemDestroy do | @@ -62,15 +62,15 @@ describe ProblemDestroy do | ||
62 | 62 | ||
63 | it 'should all destroy' do | 63 | it 'should all destroy' do |
64 | problem_destroy.execute | 64 | problem_destroy.execute |
65 | - Problem.where(:_id => problem.id).entries.should be_empty | ||
66 | - Err.where(:_id => err_1.id).entries.should be_empty | ||
67 | - Err.where(:_id => err_2.id).entries.should be_empty | ||
68 | - Comment.where(:_id => comment_1.id).entries.should be_empty | ||
69 | - Comment.where(:_id => comment_2.id).entries.should be_empty | ||
70 | - Notice.where(:_id => notice_1_1.id).entries.should be_empty | ||
71 | - Notice.where(:_id => notice_1_2.id).entries.should be_empty | ||
72 | - Notice.where(:_id => notice_2_1.id).entries.should be_empty | ||
73 | - Notice.where(:_id => notice_2_2.id).entries.should be_empty | 65 | + expect(Problem.where(:_id => problem.id).entries).to be_empty |
66 | + expect(Err.where(:_id => err_1.id).entries).to be_empty | ||
67 | + expect(Err.where(:_id => err_2.id).entries).to be_empty | ||
68 | + expect(Comment.where(:_id => comment_1.id).entries).to be_empty | ||
69 | + expect(Comment.where(:_id => comment_2.id).entries).to be_empty | ||
70 | + expect(Notice.where(:_id => notice_1_1.id).entries).to be_empty | ||
71 | + expect(Notice.where(:_id => notice_1_2.id).entries).to be_empty | ||
72 | + expect(Notice.where(:_id => notice_2_1.id).entries).to be_empty | ||
73 | + expect(Notice.where(:_id => notice_2_2.id).entries).to be_empty | ||
74 | end | 74 | end |
75 | end | 75 | end |
76 | 76 |
spec/interactors/problem_merge_spec.rb
@@ -42,7 +42,7 @@ describe ProblemMerge do | @@ -42,7 +42,7 @@ describe ProblemMerge do | ||
42 | end | 42 | end |
43 | 43 | ||
44 | it 'update problem cache' do | 44 | it 'update problem cache' do |
45 | - ProblemUpdaterCache.should_receive(:new).with(problem).and_return(double(:update => true)) | 45 | + expect(ProblemUpdaterCache).to receive(:new).with(problem).and_return(double(:update => true)) |
46 | problem_merge.merge | 46 | problem_merge.merge |
47 | end | 47 | end |
48 | 48 |
spec/interactors/resolved_problem_clearer_spec.rb
@@ -22,7 +22,7 @@ describe ResolvedProblemClearer do | @@ -22,7 +22,7 @@ describe ResolvedProblemClearer do | ||
22 | end | 22 | end |
23 | it 'not repair database' do | 23 | it 'not repair database' do |
24 | Mongoid.default_session.stub(:command).and_call_original | 24 | Mongoid.default_session.stub(:command).and_call_original |
25 | - Mongoid.default_session.should_not_receive(:command).with({:repairDatabase => 1}) | 25 | + expect(Mongoid.default_session).to_not receive(:command).with({:repairDatabase => 1}) |
26 | resolved_problem_clearer.execute | 26 | resolved_problem_clearer.execute |
27 | end | 27 | end |
28 | end | 28 | end |
@@ -47,7 +47,7 @@ describe ResolvedProblemClearer do | @@ -47,7 +47,7 @@ describe ResolvedProblemClearer do | ||
47 | 47 | ||
48 | it 'repair database' do | 48 | it 'repair database' do |
49 | Mongoid.default_session.stub(:command).and_call_original | 49 | Mongoid.default_session.stub(:command).and_call_original |
50 | - Mongoid.default_session.should_receive(:command).with({:repairDatabase => 1}) | 50 | + expect(Mongoid.default_session).to receive(:command).with({:repairDatabase => 1}) |
51 | resolved_problem_clearer.execute | 51 | resolved_problem_clearer.execute |
52 | end | 52 | end |
53 | end | 53 | end |
spec/mailers/mailer_spec.rb
@@ -20,29 +20,29 @@ describe Mailer do | @@ -20,29 +20,29 @@ describe Mailer do | ||
20 | end | 20 | end |
21 | 21 | ||
22 | it "should send the email" do | 22 | it "should send the email" do |
23 | - ActionMailer::Base.deliveries.size.should == 1 | 23 | + expect(ActionMailer::Base.deliveries.size).to eq 1 |
24 | end | 24 | end |
25 | 25 | ||
26 | it "should html-escape the notice's message for the html part" do | 26 | it "should html-escape the notice's message for the html part" do |
27 | - @email.should have_body_text("class < ActionController::Base") | 27 | + expect(@email).to have_body_text("class < ActionController::Base") |
28 | end | 28 | end |
29 | 29 | ||
30 | it "should have inline css" do | 30 | it "should have inline css" do |
31 | - @email.should have_body_text('<p class="backtrace" style="') | 31 | + expect(@email).to have_body_text('<p class="backtrace" style="') |
32 | end | 32 | end |
33 | 33 | ||
34 | it "should have links to source files" do | 34 | it "should have links to source files" do |
35 | - @email.should have_body_text('<a href="http://example.com/path/to/file.js" target="_blank">path/to/file.js') | 35 | + expect(@email).to have_body_text('<a href="http://example.com/path/to/file.js" target="_blank">path/to/file.js') |
36 | end | 36 | end |
37 | 37 | ||
38 | it "should have the error count in the subject" do | 38 | it "should have the error count in the subject" do |
39 | - @email.subject.should =~ /^\(3\) / | 39 | + expect(@email.subject).to match( /^\(3\) / ) |
40 | end | 40 | end |
41 | 41 | ||
42 | context 'with a very long message' do | 42 | context 'with a very long message' do |
43 | let(:notice) { Fabricate(:notice, :message => 6.times.collect{|a| "0123456789" }.join('')) } | 43 | let(:notice) { Fabricate(:notice, :message => 6.times.collect{|a| "0123456789" }.join('')) } |
44 | it "should truncate the long message" do | 44 | it "should truncate the long message" do |
45 | - @email.subject.should =~ / \d{47}\.{3}$/ | 45 | + expect(@email.subject).to match( / \d{47}\.{3}$/ ) |
46 | end | 46 | end |
47 | end | 47 | end |
48 | end | 48 | end |
@@ -63,19 +63,19 @@ describe Mailer do | @@ -63,19 +63,19 @@ describe Mailer do | ||
63 | end | 63 | end |
64 | 64 | ||
65 | it "should send the email" do | 65 | it "should send the email" do |
66 | - ActionMailer::Base.deliveries.size.should == 1 | 66 | + expect(ActionMailer::Base.deliveries.size).to eq 1 |
67 | end | 67 | end |
68 | 68 | ||
69 | it "should be sent to comment notification recipients" do | 69 | it "should be sent to comment notification recipients" do |
70 | - @email.to.should == recipients | 70 | + expect(@email.to).to eq recipients |
71 | end | 71 | end |
72 | 72 | ||
73 | it "should have the notices count in the body" do | 73 | it "should have the notices count in the body" do |
74 | - @email.should have_body_text("This err has occurred 2 times") | 74 | + expect(@email).to have_body_text("This err has occurred 2 times") |
75 | end | 75 | end |
76 | 76 | ||
77 | it "should have the comment body" do | 77 | it "should have the comment body" do |
78 | - @email.should have_body_text(comment.body) | 78 | + expect(@email).to have_body_text(comment.body) |
79 | end | 79 | end |
80 | end | 80 | end |
81 | end | 81 | end |
spec/models/app_spec.rb
@@ -12,22 +12,22 @@ describe App do | @@ -12,22 +12,22 @@ describe App do | ||
12 | context 'validations' do | 12 | context 'validations' do |
13 | it 'requires a name' do | 13 | it 'requires a name' do |
14 | app = Fabricate.build(:app, :name => nil) | 14 | app = Fabricate.build(:app, :name => nil) |
15 | - app.should_not be_valid | ||
16 | - app.errors[:name].should include("can't be blank") | 15 | + expect(app).to_not be_valid |
16 | + expect(app.errors[:name]).to include("can't be blank") | ||
17 | end | 17 | end |
18 | 18 | ||
19 | it 'requires unique names' do | 19 | it 'requires unique names' do |
20 | Fabricate(:app, :name => 'Errbit') | 20 | Fabricate(:app, :name => 'Errbit') |
21 | app = Fabricate.build(:app, :name => 'Errbit') | 21 | app = Fabricate.build(:app, :name => 'Errbit') |
22 | - app.should_not be_valid | ||
23 | - app.errors[:name].should include('is already taken') | 22 | + expect(app).to_not be_valid |
23 | + expect(app.errors[:name]).to include('is already taken') | ||
24 | end | 24 | end |
25 | 25 | ||
26 | it 'requires unique api_keys' do | 26 | it 'requires unique api_keys' do |
27 | Fabricate(:app, :api_key => 'APIKEY') | 27 | Fabricate(:app, :api_key => 'APIKEY') |
28 | app = Fabricate.build(:app, :api_key => 'APIKEY') | 28 | app = Fabricate.build(:app, :api_key => 'APIKEY') |
29 | - app.should_not be_valid | ||
30 | - app.errors[:api_key].should include('is already taken') | 29 | + expect(app).to_not be_valid |
30 | + expect(app.errors[:api_key]).to include('is already taken') | ||
31 | end | 31 | end |
32 | end | 32 | end |
33 | 33 | ||
@@ -36,87 +36,87 @@ describe App do | @@ -36,87 +36,87 @@ describe App do | ||
36 | app_0 = stub_model(App, :name => 'app', :unresolved_count => 1, :problem_count => 1) | 36 | app_0 = stub_model(App, :name => 'app', :unresolved_count => 1, :problem_count => 1) |
37 | app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1) | 37 | app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1) |
38 | 38 | ||
39 | - app_0.should < app_1 | ||
40 | - app_1.should > app_0 | 39 | + expect(app_0).to be < app_1 |
40 | + expect(app_1).to be > app_0 | ||
41 | end | 41 | end |
42 | 42 | ||
43 | it 'is compared by problem count' do | 43 | it 'is compared by problem count' do |
44 | app_0 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1) | 44 | app_0 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 1) |
45 | app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 0) | 45 | app_1 = stub_model(App, :name => 'app', :unresolved_count => 0, :problem_count => 0) |
46 | 46 | ||
47 | - app_0.should < app_1 | ||
48 | - app_1.should > app_0 | 47 | + expect(app_0).to be < app_1 |
48 | + expect(app_1).to be > app_0 | ||
49 | end | 49 | end |
50 | 50 | ||
51 | it 'is compared by name' do | 51 | it 'is compared by name' do |
52 | app_0 = stub_model(App, :name => 'app_0', :unresolved_count => 0, :problem_count => 0) | 52 | app_0 = stub_model(App, :name => 'app_0', :unresolved_count => 0, :problem_count => 0) |
53 | app_1 = stub_model(App, :name => 'app_1', :unresolved_count => 0, :problem_count => 0) | 53 | app_1 = stub_model(App, :name => 'app_1', :unresolved_count => 0, :problem_count => 0) |
54 | 54 | ||
55 | - app_0.should < app_1 | ||
56 | - app_1.should > app_0 | 55 | + expect(app_0).to be < app_1 |
56 | + expect(app_1).to be > app_0 | ||
57 | end | 57 | end |
58 | end | 58 | end |
59 | 59 | ||
60 | context 'being created' do | 60 | context 'being created' do |
61 | it 'generates a new api-key' do | 61 | it 'generates a new api-key' do |
62 | app = Fabricate.build(:app) | 62 | app = Fabricate.build(:app) |
63 | - app.api_key.should be_nil | 63 | + expect(app.api_key).to be_nil |
64 | app.save | 64 | app.save |
65 | - app.api_key.should_not be_nil | 65 | + expect(app.api_key).to_not be_nil |
66 | end | 66 | end |
67 | 67 | ||
68 | it 'generates a correct api-key' do | 68 | it 'generates a correct api-key' do |
69 | app = Fabricate(:app) | 69 | app = Fabricate(:app) |
70 | - app.api_key.should match(/^[a-f0-9]{32}$/) | 70 | + expect(app.api_key).to match(/^[a-f0-9]{32}$/) |
71 | end | 71 | end |
72 | 72 | ||
73 | it 'is fine with blank github repos' do | 73 | it 'is fine with blank github repos' do |
74 | app = Fabricate.build(:app, :github_repo => "") | 74 | app = Fabricate.build(:app, :github_repo => "") |
75 | app.save | 75 | app.save |
76 | - app.github_repo.should == "" | 76 | + expect(app.github_repo).to eq "" |
77 | end | 77 | end |
78 | 78 | ||
79 | it 'doesnt touch github user/repo' do | 79 | it 'doesnt touch github user/repo' do |
80 | app = Fabricate.build(:app, :github_repo => "errbit/errbit") | 80 | app = Fabricate.build(:app, :github_repo => "errbit/errbit") |
81 | app.save | 81 | app.save |
82 | - app.github_repo.should == "errbit/errbit" | 82 | + expect(app.github_repo).to eq "errbit/errbit" |
83 | end | 83 | end |
84 | 84 | ||
85 | it 'removes domain from https github repos' do | 85 | it 'removes domain from https github repos' do |
86 | app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit") | 86 | app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit") |
87 | app.save | 87 | app.save |
88 | - app.github_repo.should == "errbit/errbit" | 88 | + expect(app.github_repo).to eq "errbit/errbit" |
89 | end | 89 | end |
90 | 90 | ||
91 | it 'normalizes public git repo as a github repo' do | 91 | it 'normalizes public git repo as a github repo' do |
92 | app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit.git") | 92 | app = Fabricate.build(:app, :github_repo => "https://github.com/errbit/errbit.git") |
93 | app.save | 93 | app.save |
94 | - app.github_repo.should == "errbit/errbit" | 94 | + expect(app.github_repo).to eq "errbit/errbit" |
95 | end | 95 | end |
96 | 96 | ||
97 | it 'normalizes private git repo as a github repo' do | 97 | it 'normalizes private git repo as a github repo' do |
98 | app = Fabricate.build(:app, :github_repo => "git@github.com:errbit/errbit.git") | 98 | app = Fabricate.build(:app, :github_repo => "git@github.com:errbit/errbit.git") |
99 | app.save | 99 | app.save |
100 | - app.github_repo.should == "errbit/errbit" | 100 | + expect(app.github_repo).to eq "errbit/errbit" |
101 | end | 101 | end |
102 | end | 102 | end |
103 | 103 | ||
104 | context '#github_url_to_file' do | 104 | context '#github_url_to_file' do |
105 | it 'resolves to full path to file' do | 105 | it 'resolves to full path to file' do |
106 | app = Fabricate(:app, :github_repo => "errbit/errbit") | 106 | app = Fabricate(:app, :github_repo => "errbit/errbit") |
107 | - app.github_url_to_file('path/to/file').should == "https://github.com/errbit/errbit/blob/master/path/to/file" | 107 | + expect(app.github_url_to_file('path/to/file')).to eq "https://github.com/errbit/errbit/blob/master/path/to/file" |
108 | end | 108 | end |
109 | end | 109 | end |
110 | 110 | ||
111 | context '#github_repo?' do | 111 | context '#github_repo?' do |
112 | it 'is true when there is a github_repo' do | 112 | it 'is true when there is a github_repo' do |
113 | app = Fabricate(:app, :github_repo => "errbit/errbit") | 113 | app = Fabricate(:app, :github_repo => "errbit/errbit") |
114 | - app.github_repo?.should be_true | 114 | + expect(app.github_repo?).to be_true |
115 | end | 115 | end |
116 | 116 | ||
117 | it 'is false when no github_repo' do | 117 | it 'is false when no github_repo' do |
118 | app = Fabricate(:app) | 118 | app = Fabricate(:app) |
119 | - app.github_repo?.should be_false | 119 | + expect(app.github_repo?).to be_false |
120 | end | 120 | end |
121 | end | 121 | end |
122 | 122 | ||
@@ -126,9 +126,9 @@ describe App do | @@ -126,9 +126,9 @@ describe App do | ||
126 | 3.times { Fabricate(:user) } | 126 | 3.times { Fabricate(:user) } |
127 | 5.times { Fabricate(:watcher, :app => @app) } | 127 | 5.times { Fabricate(:watcher, :app => @app) } |
128 | @app.notify_all_users = true | 128 | @app.notify_all_users = true |
129 | - @app.notification_recipients.size.should == 8 | 129 | + expect(@app.notification_recipients.size).to eq 8 |
130 | @app.notify_all_users = false | 130 | @app.notify_all_users = false |
131 | - @app.notification_recipients.size.should == 5 | 131 | + expect(@app.notification_recipients.size).to eq 5 |
132 | end | 132 | end |
133 | end | 133 | end |
134 | 134 | ||
@@ -136,19 +136,19 @@ describe App do | @@ -136,19 +136,19 @@ describe App do | ||
136 | it "should be true if notify on errs and there are notification recipients" do | 136 | it "should be true if notify on errs and there are notification recipients" do |
137 | app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) | 137 | app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) |
138 | 2.times { Fabricate(:watcher, :app => app) } | 138 | 2.times { Fabricate(:watcher, :app => app) } |
139 | - app.emailable?.should be_true | 139 | + expect(app.emailable?).to be_true |
140 | end | 140 | end |
141 | 141 | ||
142 | it "should be false if notify on errs is disabled" do | 142 | it "should be false if notify on errs is disabled" do |
143 | app = Fabricate(:app, :notify_on_errs => false, :notify_all_users => false) | 143 | app = Fabricate(:app, :notify_on_errs => false, :notify_all_users => false) |
144 | 2.times { Fabricate(:watcher, :app => app) } | 144 | 2.times { Fabricate(:watcher, :app => app) } |
145 | - app.emailable?.should be_false | 145 | + expect(app.emailable?).to be_false |
146 | end | 146 | end |
147 | 147 | ||
148 | it "should be false if there are no notification recipients" do | 148 | it "should be false if there are no notification recipients" do |
149 | app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) | 149 | app = Fabricate(:app, :notify_on_errs => true, :notify_all_users => false) |
150 | - app.watchers.should be_empty | ||
151 | - app.emailable?.should be_false | 150 | + expect(app.watchers).to be_empty |
151 | + expect(app.emailable?).to be_false | ||
152 | end | 152 | end |
153 | end | 153 | end |
154 | 154 | ||
@@ -158,9 +158,9 @@ describe App do | @@ -158,9 +158,9 @@ describe App do | ||
158 | Fabricate(:app, :name => "copy_app", :github_repo => "copy url") | 158 | Fabricate(:app, :name => "copy_app", :github_repo => "copy url") |
159 | @copy_watcher = Fabricate(:watcher, :email => "copywatcher@example.com", :app => @copy_app) | 159 | @copy_watcher = Fabricate(:watcher, :email => "copywatcher@example.com", :app => @copy_app) |
160 | @app.copy_attributes_from(@copy_app.id) | 160 | @app.copy_attributes_from(@copy_app.id) |
161 | - @app.name.should == "app" | ||
162 | - @app.github_repo.should == "copy url" | ||
163 | - @app.watchers.first.email.should == "copywatcher@example.com" | 161 | + expect(@app.name).to eq "app" |
162 | + expect(@app.github_repo).to eq "copy url" | ||
163 | + expect(@app.watchers.first.email).to eq "copywatcher@example.com" | ||
164 | end | 164 | end |
165 | end | 165 | end |
166 | 166 | ||
@@ -178,19 +178,19 @@ describe App do | @@ -178,19 +178,19 @@ describe App do | ||
178 | :problem => Fabricate(:problem, :app => app), | 178 | :problem => Fabricate(:problem, :app => app), |
179 | :fingerprint => conditions[:fingerprint] | 179 | :fingerprint => conditions[:fingerprint] |
180 | }) | 180 | }) |
181 | - Err.where(:fingerprint => conditions[:fingerprint]).first.should == existing | ||
182 | - app.find_or_create_err!(conditions).should == existing | 181 | + expect(Err.where(:fingerprint => conditions[:fingerprint]).first).to eq existing |
182 | + expect(app.find_or_create_err!(conditions)).to eq existing | ||
183 | end | 183 | end |
184 | 184 | ||
185 | it 'assigns the returned err to the given app' do | 185 | it 'assigns the returned err to the given app' do |
186 | - app.find_or_create_err!(conditions).app.should == app | 186 | + expect(app.find_or_create_err!(conditions).app).to eq app |
187 | end | 187 | end |
188 | 188 | ||
189 | it 'creates a new problem if a matching one does not already exist' do | 189 | it 'creates a new problem if a matching one does not already exist' do |
190 | - Err.where(conditions).first.should be_nil | ||
191 | - lambda { | 190 | + expect(Err.where(conditions).first).to be_nil |
191 | + expect { | ||
192 | app.find_or_create_err!(conditions) | 192 | app.find_or_create_err!(conditions) |
193 | - }.should change(Problem,:count).by(1) | 193 | + }.to change(Problem,:count).by(1) |
194 | end | 194 | end |
195 | 195 | ||
196 | context "without error_class" do | 196 | context "without error_class" do |
@@ -200,10 +200,10 @@ describe App do | @@ -200,10 +200,10 @@ describe App do | ||
200 | } | 200 | } |
201 | } | 201 | } |
202 | it 'save the err' do | 202 | it 'save the err' do |
203 | - Err.where(conditions).first.should be_nil | ||
204 | - lambda { | 203 | + expect(Err.where(conditions).first).to be_nil |
204 | + expect { | ||
205 | app.find_or_create_err!(conditions) | 205 | app.find_or_create_err!(conditions) |
206 | - }.should change(Problem,:count).by(1) | 206 | + }.to change(Problem,:count).by(1) |
207 | end | 207 | end |
208 | end | 208 | end |
209 | end | 209 | end |
spec/models/backtrace_line_normalizer_spec.rb
@@ -8,11 +8,11 @@ describe BacktraceLineNormalizer do | @@ -8,11 +8,11 @@ describe BacktraceLineNormalizer do | ||
8 | let(:raw_line) { { 'number' => rand(999), 'file' => nil, 'method' => nil } } | 8 | let(:raw_line) { { 'number' => rand(999), 'file' => nil, 'method' => nil } } |
9 | 9 | ||
10 | it "should replace nil file with [unknown source]" do | 10 | it "should replace nil file with [unknown source]" do |
11 | - subject['file'].should == "[unknown source]" | 11 | + expect(subject['file']).to eq "[unknown source]" |
12 | end | 12 | end |
13 | 13 | ||
14 | it "should replace nil method with [unknown method]" do | 14 | it "should replace nil method with [unknown method]" do |
15 | - subject['method'].should == "[unknown method]" | 15 | + expect(subject['method']).to eq "[unknown method]" |
16 | end | 16 | end |
17 | end | 17 | end |
18 | 18 | ||
@@ -20,7 +20,7 @@ describe BacktraceLineNormalizer do | @@ -20,7 +20,7 @@ describe BacktraceLineNormalizer do | ||
20 | let(:raw_line) { { 'number' => rand(999), 'file' => "[PROJECT_ROOT]/assets/file.js?body=1", 'method' => nil } } | 20 | let(:raw_line) { { 'number' => rand(999), 'file' => "[PROJECT_ROOT]/assets/file.js?body=1", 'method' => nil } } |
21 | 21 | ||
22 | it "should strip query strings from files" do | 22 | it "should strip query strings from files" do |
23 | - subject['file'].should == "[PROJECT_ROOT]/assets/file.js" | 23 | + expect(subject['file']).to eq "[PROJECT_ROOT]/assets/file.js" |
24 | end | 24 | end |
25 | end | 25 | end |
26 | end | 26 | end |
spec/models/backtrace_line_spec.rb
@@ -6,7 +6,7 @@ describe BacktraceLine do | @@ -6,7 +6,7 @@ describe BacktraceLine do | ||
6 | describe "root at the start of decorated filename" do | 6 | describe "root at the start of decorated filename" do |
7 | let(:raw_line) { { 'number' => rand(999), 'file' => '[PROJECT_ROOT]/app/controllers/pages_controller.rb', 'method' => ActiveSupport.methods.shuffle.first.to_s } } | 7 | let(:raw_line) { { 'number' => rand(999), 'file' => '[PROJECT_ROOT]/app/controllers/pages_controller.rb', 'method' => ActiveSupport.methods.shuffle.first.to_s } } |
8 | it "should leave leading root symbol in filepath" do | 8 | it "should leave leading root symbol in filepath" do |
9 | - subject.decorated_path.should == 'app/controllers/' | 9 | + expect(subject.decorated_path).to eq 'app/controllers/' |
10 | end | 10 | end |
11 | end | 11 | end |
12 | end | 12 | end |
spec/models/backtrace_spec.rb
@@ -35,7 +35,7 @@ describe Backtrace do | @@ -35,7 +35,7 @@ describe Backtrace do | ||
35 | context "no similar backtrace" do | 35 | context "no similar backtrace" do |
36 | before { backtrace.stub(:similar => nil) } | 36 | before { backtrace.stub(:similar => nil) } |
37 | it "create new backtrace" do | 37 | it "create new backtrace" do |
38 | - described_class.should_receive(:create).with(attributes) | 38 | + expect(described_class).to receive(:create).with(attributes) |
39 | 39 | ||
40 | described_class.find_or_create(attributes) | 40 | described_class.find_or_create(attributes) |
41 | end | 41 | end |
spec/models/comment_observer_spec.rb
@@ -8,7 +8,7 @@ describe "Callback on Comment" do | @@ -8,7 +8,7 @@ describe "Callback on Comment" do | ||
8 | before { comment.stub(:emailable?).and_return(true) } | 8 | before { comment.stub(:emailable?).and_return(true) } |
9 | 9 | ||
10 | it 'should send an email notification' do | 10 | it 'should send an email notification' do |
11 | - Mailer.should_receive(:comment_notification). | 11 | + expect(Mailer).to receive(:comment_notification). |
12 | with(comment). | 12 | with(comment). |
13 | and_return(double('email', :deliver => true)) | 13 | and_return(double('email', :deliver => true)) |
14 | comment.save | 14 | comment.save |
@@ -19,7 +19,7 @@ describe "Callback on Comment" do | @@ -19,7 +19,7 @@ describe "Callback on Comment" do | ||
19 | before { comment.stub(:emailable?).and_return(false) } | 19 | before { comment.stub(:emailable?).and_return(false) } |
20 | 20 | ||
21 | it 'should not send an email notification' do | 21 | it 'should not send an email notification' do |
22 | - Mailer.should_not_receive(:comment_notification) | 22 | + expect(Mailer).to_not receive(:comment_notification) |
23 | comment.save | 23 | comment.save |
24 | end | 24 | end |
25 | end | 25 | end |
spec/models/comment_spec.rb
@@ -4,8 +4,8 @@ describe Comment do | @@ -4,8 +4,8 @@ describe Comment do | ||
4 | context 'validations' do | 4 | context 'validations' do |
5 | it 'should require a body' do | 5 | it 'should require a body' do |
6 | comment = Fabricate.build(:comment, :body => nil) | 6 | comment = Fabricate.build(:comment, :body => nil) |
7 | - comment.should_not be_valid | ||
8 | - comment.errors[:body].should include("can't be blank") | 7 | + expect(comment).to_not be_valid |
8 | + expect(comment.errors[:body]).to include("can't be blank") | ||
9 | end | 9 | end |
10 | end | 10 | end |
11 | 11 | ||
@@ -21,7 +21,7 @@ describe Comment do | @@ -21,7 +21,7 @@ describe Comment do | ||
21 | end | 21 | end |
22 | 22 | ||
23 | it 'includes app notification_recipients except user email' do | 23 | it 'includes app notification_recipients except user email' do |
24 | - comment.notification_recipients.should == [watcher.address] | 24 | + expect(comment.notification_recipients).to eq [watcher.address] |
25 | end | 25 | end |
26 | end | 26 | end |
27 | 27 | ||
@@ -37,19 +37,19 @@ describe Comment do | @@ -37,19 +37,19 @@ describe Comment do | ||
37 | end | 37 | end |
38 | 38 | ||
39 | it 'should be true if app is emailable? and there are notification recipients' do | 39 | it 'should be true if app is emailable? and there are notification recipients' do |
40 | - comment.emailable?.should be_true | 40 | + expect(comment.emailable?).to be_true |
41 | end | 41 | end |
42 | 42 | ||
43 | it 'should be false if app is not emailable?' do | 43 | it 'should be false if app is not emailable?' do |
44 | app.update_attribute(:notify_on_errs, false) | 44 | app.update_attribute(:notify_on_errs, false) |
45 | - comment.notification_recipients.should be_any | ||
46 | - comment.emailable?.should be_false | 45 | + expect(comment.notification_recipients).to be_any |
46 | + expect(comment.emailable?).to be_false | ||
47 | end | 47 | end |
48 | 48 | ||
49 | it 'should be false if there are no notification recipients' do | 49 | it 'should be false if there are no notification recipients' do |
50 | watcher.destroy | 50 | watcher.destroy |
51 | - app.emailable?.should be_true | ||
52 | - comment.emailable?.should be_false | 51 | + expect(app.emailable?).to be_true |
52 | + expect(comment.emailable?).to be_false | ||
53 | end | 53 | end |
54 | end | 54 | end |
55 | end | 55 | end |
spec/models/deploy_observer_spec.rb
@@ -4,7 +4,7 @@ describe "Callback on Deploy" do | @@ -4,7 +4,7 @@ describe "Callback on Deploy" do | ||
4 | context 'when a Deploy is saved' do | 4 | context 'when a Deploy is saved' do |
5 | context 'and the app should notify on deploys' do | 5 | context 'and the app should notify on deploys' do |
6 | it 'should send an email notification' do | 6 | it 'should send an email notification' do |
7 | - Mailer.should_receive(:deploy_notification). | 7 | + expect(Mailer).to receive(:deploy_notification). |
8 | and_return(double('email', :deliver => true)) | 8 | and_return(double('email', :deliver => true)) |
9 | Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => true)) | 9 | Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => true)) |
10 | end | 10 | end |
@@ -12,7 +12,7 @@ describe "Callback on Deploy" do | @@ -12,7 +12,7 @@ describe "Callback on Deploy" do | ||
12 | 12 | ||
13 | context 'and the app is not set to notify on deploys' do | 13 | context 'and the app is not set to notify on deploys' do |
14 | it 'should not send an email notification' do | 14 | it 'should not send an email notification' do |
15 | - Mailer.should_not_receive(:deploy_notification) | 15 | + expect(Mailer).to_not receive(:deploy_notification) |
16 | Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => false)) | 16 | Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => false)) |
17 | end | 17 | end |
18 | end | 18 | end |
spec/models/deploy_spec.rb
@@ -5,14 +5,14 @@ describe Deploy do | @@ -5,14 +5,14 @@ describe Deploy do | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'requires a username' do | 6 | it 'requires a username' do |
7 | deploy = Fabricate.build(:deploy, :username => nil) | 7 | deploy = Fabricate.build(:deploy, :username => nil) |
8 | - deploy.should_not be_valid | ||
9 | - deploy.errors[:username].should include("can't be blank") | 8 | + expect(deploy).to_not be_valid |
9 | + expect(deploy.errors[:username]).to include("can't be blank") | ||
10 | end | 10 | end |
11 | 11 | ||
12 | it 'requires an environment' do | 12 | it 'requires an environment' do |
13 | deploy = Fabricate.build(:deploy, :environment => nil) | 13 | deploy = Fabricate.build(:deploy, :environment => nil) |
14 | - deploy.should_not be_valid | ||
15 | - deploy.errors[:environment].should include("can't be blank") | 14 | + expect(deploy).to_not be_valid |
15 | + expect(deploy.errors[:environment]).to include("can't be blank") | ||
16 | end | 16 | end |
17 | end | 17 | end |
18 | 18 | ||
@@ -22,7 +22,7 @@ describe Deploy do | @@ -22,7 +22,7 @@ describe Deploy do | ||
22 | app = Fabricate(:app, :resolve_errs_on_deploy => false) | 22 | app = Fabricate(:app, :resolve_errs_on_deploy => false) |
23 | @problems = 3.times.map{Fabricate(:err, :problem => Fabricate(:problem, :resolved => false, :app => app))} | 23 | @problems = 3.times.map{Fabricate(:err, :problem => Fabricate(:problem, :resolved => false, :app => app))} |
24 | Fabricate(:deploy, :app => app) | 24 | Fabricate(:deploy, :app => app) |
25 | - app.reload.problems.none?{|problem| problem.resolved?}.should == true | 25 | + expect(app.reload.problems.none?{|problem| problem.resolved?}).to eq true |
26 | end | 26 | end |
27 | end | 27 | end |
28 | 28 | ||
@@ -32,15 +32,15 @@ describe Deploy do | @@ -32,15 +32,15 @@ describe Deploy do | ||
32 | @prod_errs = 3.times.map{Fabricate(:problem, :resolved => false, :app => app, :environment => 'production')} | 32 | @prod_errs = 3.times.map{Fabricate(:problem, :resolved => false, :app => app, :environment => 'production')} |
33 | @staging_errs = 3.times.map{Fabricate(:problem, :resolved => false, :app => app, :environment => 'staging')} | 33 | @staging_errs = 3.times.map{Fabricate(:problem, :resolved => false, :app => app, :environment => 'staging')} |
34 | Fabricate(:deploy, :app => app, :environment => 'production') | 34 | Fabricate(:deploy, :app => app, :environment => 'production') |
35 | - @prod_errs.all?{|problem| problem.reload.resolved?}.should == true | ||
36 | - @staging_errs.all?{|problem| problem.reload.resolved?}.should == false | 35 | + expect(@prod_errs.all?{|problem| problem.reload.resolved?}).to eq true |
36 | + expect(@staging_errs.all?{|problem| problem.reload.resolved?}).to eq false | ||
37 | end | 37 | end |
38 | end | 38 | end |
39 | 39 | ||
40 | end | 40 | end |
41 | 41 | ||
42 | it "should produce a shortened revision with 7 characters" do | 42 | it "should produce a shortened revision with 7 characters" do |
43 | - Deploy.new(:revision => "1234567890abcdef").short_revision.should == "1234567" | 43 | + expect(Deploy.new(:revision => "1234567890abcdef").short_revision).to eq "1234567" |
44 | end | 44 | end |
45 | end | 45 | end |
46 | 46 |
spec/models/err_spec.rb
@@ -5,14 +5,14 @@ describe Err do | @@ -5,14 +5,14 @@ describe Err do | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'requires a fingerprint' do | 6 | it 'requires a fingerprint' do |
7 | err = Fabricate.build(:err, :fingerprint => nil) | 7 | err = Fabricate.build(:err, :fingerprint => nil) |
8 | - err.should_not be_valid | ||
9 | - err.errors[:fingerprint].should include("can't be blank") | 8 | + expect(err).to_not be_valid |
9 | + expect(err.errors[:fingerprint]).to include("can't be blank") | ||
10 | end | 10 | end |
11 | 11 | ||
12 | it 'requires a problem' do | 12 | it 'requires a problem' do |
13 | err = Fabricate.build(:err, :problem_id => nil, :problem => nil) | 13 | err = Fabricate.build(:err, :problem_id => nil, :problem => nil) |
14 | - err.should_not be_valid | ||
15 | - err.errors[:problem_id].should include("can't be blank") | 14 | + expect(err).to_not be_valid |
15 | + expect(err.errors[:problem_id]).to include("can't be blank") | ||
16 | end | 16 | end |
17 | end | 17 | end |
18 | 18 |
spec/models/error_report_spec.rb
@@ -43,7 +43,7 @@ describe ErrorReport do | @@ -43,7 +43,7 @@ describe ErrorReport do | ||
43 | describe "#backtrace" do | 43 | describe "#backtrace" do |
44 | 44 | ||
45 | it 'should have valid backtrace' do | 45 | it 'should have valid backtrace' do |
46 | - error_report.backtrace.should be_valid | 46 | + expect(error_report.backtrace).to be_valid |
47 | end | 47 | end |
48 | end | 48 | end |
49 | 49 | ||
@@ -77,32 +77,32 @@ describe ErrorReport do | @@ -77,32 +77,32 @@ describe ErrorReport do | ||
77 | its(:framework) { should == 'Rails: 3.2.11' } | 77 | its(:framework) { should == 'Rails: 3.2.11' } |
78 | 78 | ||
79 | it 'has complete backtrace' do | 79 | it 'has complete backtrace' do |
80 | - subject.backtrace_lines.size.should == 73 | ||
81 | - subject.backtrace_lines.last['file'].should == '[GEM_ROOT]/bin/rake' | 80 | + expect(subject.backtrace_lines.size).to eq 73 |
81 | + expect(subject.backtrace_lines.last['file']).to eq '[GEM_ROOT]/bin/rake' | ||
82 | end | 82 | end |
83 | it 'has server_environement' do | 83 | it 'has server_environement' do |
84 | - subject.server_environment['environment-name'].should == 'development' | 84 | + expect(subject.server_environment['environment-name']).to eq 'development' |
85 | end | 85 | end |
86 | 86 | ||
87 | it 'has request' do | 87 | it 'has request' do |
88 | - subject.request['url'].should == 'http://example.org/verify/cupcake=fistfight&lovebird=doomsayer' | ||
89 | - subject.request['params']['controller'].should == 'application' | 88 | + expect(subject.request['url']).to eq 'http://example.org/verify/cupcake=fistfight&lovebird=doomsayer' |
89 | + expect(subject.request['params']['controller']).to eq 'application' | ||
90 | end | 90 | end |
91 | 91 | ||
92 | it 'has notifier' do | 92 | it 'has notifier' do |
93 | - subject.notifier['name'].should == 'Hoptoad Notifier' | 93 | + expect(subject.notifier['name']).to eq 'Hoptoad Notifier' |
94 | end | 94 | end |
95 | 95 | ||
96 | it 'get user_attributes' do | 96 | it 'get user_attributes' do |
97 | - subject.user_attributes['id'].should == '123' | ||
98 | - subject.user_attributes['name'].should == 'Mr. Bean' | ||
99 | - subject.user_attributes['email'].should == 'mr.bean@example.com' | ||
100 | - subject.user_attributes['username'].should == 'mrbean' | 97 | + expect(subject.user_attributes['id']).to eq '123' |
98 | + expect(subject.user_attributes['name']).to eq 'Mr. Bean' | ||
99 | + expect(subject.user_attributes['email']).to eq 'mr.bean@example.com' | ||
100 | + expect(subject.user_attributes['username']).to eq 'mrbean' | ||
101 | end | 101 | end |
102 | it 'valid env_vars' do | 102 | it 'valid env_vars' do |
103 | # XML: <var key="SCRIPT_NAME"/> | 103 | # XML: <var key="SCRIPT_NAME"/> |
104 | - subject.env_vars.should have_key('SCRIPT_NAME') | ||
105 | - subject.env_vars['SCRIPT_NAME'].should be_nil # blank ends up nil | 104 | + expect(subject.env_vars).to have_key('SCRIPT_NAME') |
105 | + expect(subject.env_vars['SCRIPT_NAME']).to be_nil # blank ends up nil | ||
106 | 106 | ||
107 | # XML representation: | 107 | # XML representation: |
108 | # <var key="rack.session.options"> | 108 | # <var key="rack.session.options"> |
@@ -121,14 +121,14 @@ describe ErrorReport do | @@ -121,14 +121,14 @@ describe ErrorReport do | ||
121 | 'domain' => nil, | 121 | 'domain' => nil, |
122 | 'id' => nil | 122 | 'id' => nil |
123 | } | 123 | } |
124 | - subject.env_vars.should have_key('rack_session_options') | ||
125 | - subject.env_vars['rack_session_options'].should eql(expected) | 124 | + expect(subject.env_vars).to have_key('rack_session_options') |
125 | + expect(subject.env_vars['rack_session_options']).to eql(expected) | ||
126 | end | 126 | end |
127 | end | 127 | end |
128 | 128 | ||
129 | it 'save a notice assignes to err' do | 129 | it 'save a notice assignes to err' do |
130 | error_report.generate_notice! | 130 | error_report.generate_notice! |
131 | - error_report.notice.err.should be_a(Err) | 131 | + expect(error_report.notice.err).to be_a(Err) |
132 | end | 132 | end |
133 | 133 | ||
134 | it 'memoize the notice' do | 134 | it 'memoize the notice' do |
@@ -161,10 +161,10 @@ describe ErrorReport do | @@ -161,10 +161,10 @@ describe ErrorReport do | ||
161 | it 'send email' do | 161 | it 'send email' do |
162 | notice = error_report.generate_notice! | 162 | notice = error_report.generate_notice! |
163 | email = ActionMailer::Base.deliveries.last | 163 | email = ActionMailer::Base.deliveries.last |
164 | - email.to.should include(app.watchers.first.email) | ||
165 | - email.subject.should include(notice.message.truncate(50)) | ||
166 | - email.subject.should include("[#{app.name}]") | ||
167 | - email.subject.should include("[#{notice.environment_name}]") | 164 | + expect(email.to).to include(app.watchers.first.email) |
165 | + expect(email.subject).to include(notice.message.truncate(50)) | ||
166 | + expect(email.subject).to include("[#{app.name}]") | ||
167 | + expect(email.subject).to include("[#{notice.environment_name}]") | ||
168 | end | 168 | end |
169 | end | 169 | end |
170 | 170 |
spec/models/fingerprint_spec.rb
@@ -44,7 +44,7 @@ describe Fingerprint do | @@ -44,7 +44,7 @@ describe Fingerprint do | ||
44 | end | 44 | end |
45 | 45 | ||
46 | its 'fingerprints should be equal' do | 46 | its 'fingerprints should be equal' do |
47 | - Fingerprint.generate(notice1, 'api key').should eq Fingerprint.generate(notice2, 'api key') | 47 | + expect(Fingerprint.generate(notice1, 'api key')).to eq Fingerprint.generate(notice2, 'api key') |
48 | end | 48 | end |
49 | end | 49 | end |
50 | 50 | ||
@@ -57,7 +57,7 @@ describe Fingerprint do | @@ -57,7 +57,7 @@ describe Fingerprint do | ||
57 | end | 57 | end |
58 | 58 | ||
59 | its 'fingerprints should not be equal' do | 59 | its 'fingerprints should not be equal' do |
60 | - Fingerprint.generate(notice1, 'api key').should_not eq Fingerprint.generate(notice2, 'api key') | 60 | + expect(Fingerprint.generate(notice1, 'api key')).to_not eq Fingerprint.generate(notice2, 'api key') |
61 | end | 61 | end |
62 | end | 62 | end |
63 | end | 63 | end |
spec/models/issue_trackers/bitbucket_issues_tracker_spec.rb
@@ -32,9 +32,9 @@ EOF | @@ -32,9 +32,9 @@ EOF | ||
32 | problem.reload | 32 | problem.reload |
33 | 33 | ||
34 | requested = have_requested(:post, "https://#{tracker.api_token}:#{tracker.project_id}@bitbucket.org/api/1.0/repositories/test_user/test_repo/issues/") | 34 | requested = have_requested(:post, "https://#{tracker.api_token}:#{tracker.project_id}@bitbucket.org/api/1.0/repositories/test_user/test_repo/issues/") |
35 | - WebMock.should requested.with(:title => /[production][foo#bar] FooError: Too Much Bar/) | ||
36 | - WebMock.should requested.with(:content => /See this exception on Errbit/) | 35 | + expect(WebMock).to requested.with(:title => /[production][foo#bar] FooError: Too Much Bar/) |
36 | + expect(WebMock).to requested.with(:content => /See this exception on Errbit/) | ||
37 | 37 | ||
38 | - problem.issue_link.should == @issue_link | 38 | + expect(problem.issue_link).to eq @issue_link |
39 | end | 39 | end |
40 | end | 40 | end |
spec/models/issue_trackers/fogbugz_tracker_spec.rb
@@ -10,14 +10,14 @@ describe IssueTrackers::FogbugzTracker do | @@ -10,14 +10,14 @@ describe IssueTrackers::FogbugzTracker do | ||
10 | @issue_link = "https://#{tracker.account}.fogbugz.com/default.asp?#{number}" | 10 | @issue_link = "https://#{tracker.account}.fogbugz.com/default.asp?#{number}" |
11 | response = "<response><token>12345</token><case><ixBug>123</ixBug></case></response>" | 11 | response = "<response><token>12345</token><case><ixBug>123</ixBug></case></response>" |
12 | http_mock = double | 12 | http_mock = double |
13 | - http_mock.should_receive(:new).and_return(http_mock) | ||
14 | - http_mock.should_receive(:request).twice.and_return(response) | 13 | + expect(http_mock).to receive(:new).and_return(http_mock) |
14 | + expect(http_mock).to receive(:request).twice.and_return(response) | ||
15 | Fogbugz.adapter[:http] = http_mock | 15 | Fogbugz.adapter[:http] = http_mock |
16 | 16 | ||
17 | problem.app.issue_tracker.create_issue(problem) | 17 | problem.app.issue_tracker.create_issue(problem) |
18 | problem.reload | 18 | problem.reload |
19 | 19 | ||
20 | - problem.issue_link.should == @issue_link | 20 | + expect(problem.issue_link).to eq @issue_link |
21 | end | 21 | end |
22 | end | 22 | end |
23 | 23 |
spec/models/issue_trackers/github_issues_tracker_spec.rb
@@ -38,10 +38,10 @@ EOF | @@ -38,10 +38,10 @@ EOF | ||
38 | problem.reload | 38 | problem.reload |
39 | 39 | ||
40 | requested = have_requested(:post, "https://#{tracker.username}:#{tracker.password}@api.github.com/repos/#{repo}/issues") | 40 | requested = have_requested(:post, "https://#{tracker.username}:#{tracker.password}@api.github.com/repos/#{repo}/issues") |
41 | - WebMock.should requested.with(:body => /[production][foo#bar] FooError: Too Much Bar/) | ||
42 | - WebMock.should requested.with(:body => /See this exception on Errbit/) | 41 | + expect(WebMock).to requested.with(:body => /[production][foo#bar] FooError: Too Much Bar/) |
42 | + expect(WebMock).to requested.with(:body => /See this exception on Errbit/) | ||
43 | 43 | ||
44 | - problem.issue_link.should == @issue_link | 44 | + expect(problem.issue_link).to eq @issue_link |
45 | end | 45 | end |
46 | end | 46 | end |
47 | 47 |
spec/models/issue_trackers/gitlab_issues_tracker_spec.rb
@@ -24,8 +24,8 @@ describe IssueTrackers::GitlabTracker do | @@ -24,8 +24,8 @@ describe IssueTrackers::GitlabTracker do | ||
24 | 24 | ||
25 | requested_issue = have_requested(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues?private_token=#{tracker.api_token}").with(:body => /.+/, :headers => {'Accept'=>'application/json'}) | 25 | requested_issue = have_requested(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues?private_token=#{tracker.api_token}").with(:body => /.+/, :headers => {'Accept'=>'application/json'}) |
26 | requested_note = have_requested(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/#{issue_id}/notes?private_token=#{tracker.api_token}") | 26 | requested_note = have_requested(:post, "#{tracker.account}/api/v3/projects/#{tracker.project_id}/issues/#{issue_id}/notes?private_token=#{tracker.api_token}") |
27 | - WebMock.should requested_issue.with(:body => /%5Bproduction%5D%5Bfoo%23bar%5D%20FooError%3A%20Too%20Much%20Bar/) | ||
28 | - WebMock.should requested_issue.with(:body => /See%20this%20exception%20on%20Errbit/) | 27 | + expect(WebMock).to requested_issue.with(:body => /%5Bproduction%5D%5Bfoo%23bar%5D%20FooError%3A%20Too%20Much%20Bar/) |
28 | + expect(WebMock).to requested_issue.with(:body => /See%20this%20exception%20on%20Errbit/) | ||
29 | 29 | ||
30 | end | 30 | end |
31 | end | 31 | end |
spec/models/issue_trackers/lighthouse_tracker_spec.rb
@@ -16,12 +16,12 @@ describe IssueTrackers::LighthouseTracker do | @@ -16,12 +16,12 @@ describe IssueTrackers::LighthouseTracker do | ||
16 | problem.reload | 16 | problem.reload |
17 | 17 | ||
18 | requested = have_requested(:post, "http://#{tracker.account}.lighthouseapp.com/projects/#{tracker.project_id}/tickets.xml") | 18 | requested = have_requested(:post, "http://#{tracker.account}.lighthouseapp.com/projects/#{tracker.project_id}/tickets.xml") |
19 | - WebMock.should requested.with(:headers => {'X-Lighthousetoken' => tracker.api_token}) | ||
20 | - WebMock.should requested.with(:body => /<tag>errbit<\/tag>/) | ||
21 | - WebMock.should requested.with(:body => /<title>\[#{ problem.environment }\]\[#{problem.where}\] #{problem.message.to_s.truncate(100)}<\/title>/) | ||
22 | - WebMock.should requested.with(:body => /<body>.+<\/body>/m) | 19 | + expect(WebMock).to requested.with(:headers => {'X-Lighthousetoken' => tracker.api_token}) |
20 | + expect(WebMock).to requested.with(:body => /<tag>errbit<\/tag>/) | ||
21 | + expect(WebMock).to requested.with(:body => /<title>\[#{ problem.environment }\]\[#{problem.where}\] #{problem.message.to_s.truncate(100)}<\/title>/) | ||
22 | + expect(WebMock).to requested.with(:body => /<body>.+<\/body>/m) | ||
23 | 23 | ||
24 | - problem.issue_link.should == @issue_link.sub(/\.xml$/, '') | 24 | + expect(problem.issue_link).to eq @issue_link.sub(/\.xml$/, '') |
25 | end | 25 | end |
26 | end | 26 | end |
27 | 27 |
spec/models/issue_trackers/mingle_tracker_spec.rb
@@ -17,12 +17,12 @@ describe IssueTrackers::MingleTracker do | @@ -17,12 +17,12 @@ describe IssueTrackers::MingleTracker do | ||
17 | problem.reload | 17 | problem.reload |
18 | 18 | ||
19 | requested = have_requested(:post, "#{@basic_auth}/api/v1/projects/#{tracker.project_id}/cards.xml") | 19 | requested = have_requested(:post, "#{@basic_auth}/api/v1/projects/#{tracker.project_id}/cards.xml") |
20 | - WebMock.should requested.with(:headers => {'Content-Type' => 'application/xml'}) | ||
21 | - WebMock.should requested.with(:body => /FooError: Too Much Bar/) | ||
22 | - WebMock.should requested.with(:body => /See this exception on Errbit/) | ||
23 | - WebMock.should requested.with(:body => /<card-type-name>Defect<\/card-type-name>/) | 20 | + expect(WebMock).to requested.with(:headers => {'Content-Type' => 'application/xml'}) |
21 | + expect(WebMock).to requested.with(:body => /FooError: Too Much Bar/) | ||
22 | + expect(WebMock).to requested.with(:body => /See this exception on Errbit/) | ||
23 | + expect(WebMock).to requested.with(:body => /<card-type-name>Defect<\/card-type-name>/) | ||
24 | 24 | ||
25 | - problem.issue_link.should == @issue_link.sub(/\.xml$/, '') | 25 | + expect(problem.issue_link).to eq @issue_link.sub(/\.xml$/, '') |
26 | end | 26 | end |
27 | end | 27 | end |
28 | 28 |
spec/models/issue_trackers/pivotal_labs_tracker_spec.rb
@@ -21,25 +21,26 @@ describe IssueTrackers::PivotalLabsTracker do | @@ -21,25 +21,26 @@ describe IssueTrackers::PivotalLabsTracker do | ||
21 | problem.reload | 21 | problem.reload |
22 | 22 | ||
23 | requested = have_requested(:post, "https://www.pivotaltracker.com/services/v3/projects/#{tracker.project_id}/stories") | 23 | requested = have_requested(:post, "https://www.pivotaltracker.com/services/v3/projects/#{tracker.project_id}/stories") |
24 | - WebMock.should requested.with(:headers => {'X-Trackertoken' => tracker.api_token}) | ||
25 | - WebMock.should requested.with(:body => /See this exception on Errbit/) | ||
26 | - WebMock.should requested.with(:body => /<name>\[#{ problem.environment }\]\[#{problem.where}\] #{problem.message.to_s.truncate(100)}<\/name>/) | ||
27 | - WebMock.should requested.with(:body => /<description>.+<\/description>/m) | 24 | + expect(WebMock).to requested.with(:headers => {'X-Trackertoken' => tracker.api_token}) |
25 | + expect(WebMock).to requested.with(:body => /See this exception on Errbit/) | ||
26 | + expect(WebMock).to requested.with(:body => /<name>\[#{ problem.environment }\]\[#{problem.where}\] #{problem.message.to_s.truncate(100)}<\/name>/) | ||
27 | + expect(WebMock).to requested.with(:body => /<description>.+<\/description>/m) | ||
28 | 28 | ||
29 | - problem.issue_link.should == issue_link | 29 | + expect(problem.issue_link).to eq issue_link |
30 | end | 30 | end |
31 | 31 | ||
32 | it "raises IssueTrackers::IssueTrackerError exception when invalid params and does not set issue link for problem" do | 32 | it "raises IssueTrackers::IssueTrackerError exception when invalid params and does not set issue link for problem" do |
33 | project_body = "<project><id>#{tracker.project_id}</id><name>TestProject</name></project>" | 33 | project_body = "<project><id>#{tracker.project_id}</id><name>TestProject</name></project>" |
34 | stub_request(:get, "https://www.pivotaltracker.com/services/v3/projects/#{tracker.project_id}"). | 34 | stub_request(:get, "https://www.pivotaltracker.com/services/v3/projects/#{tracker.project_id}"). |
35 | - to_return(:status => 200, :body => project_body ) | 35 | + to_return(:status => 200, :body => project_body ) |
36 | story_body = "<errors><error>Requested by can't be blank</error><error>Requested by can't be blank</error></errors>" | 36 | story_body = "<errors><error>Requested by can't be blank</error><error>Requested by can't be blank</error></errors>" |
37 | stub_request(:post, "https://www.pivotaltracker.com/services/v3/projects/#{tracker.project_id}/stories"). | 37 | stub_request(:post, "https://www.pivotaltracker.com/services/v3/projects/#{tracker.project_id}/stories"). |
38 | to_return(:status => 422, :body => story_body ) | 38 | to_return(:status => 422, :body => story_body ) |
39 | 39 | ||
40 | - lambda { problem.app.issue_tracker.create_issue(problem, user) | ||
41 | - }.should raise_exception(IssueTrackers::IssueTrackerError, "Requested by can't be blank") | ||
42 | - problem.issue_link.should be_nil | 40 | + expect{ |
41 | + problem.app.issue_tracker.create_issue(problem, user) | ||
42 | + }.to raise_exception(IssueTrackers::IssueTrackerError, "Requested by can't be blank") | ||
43 | + expect(problem.issue_link).to be_nil | ||
43 | end | 44 | end |
44 | end | 45 | end |
45 | 46 |
spec/models/issue_trackers/redmine_tracker_spec.rb
@@ -19,27 +19,27 @@ describe IssueTrackers::RedmineTracker do | @@ -19,27 +19,27 @@ describe IssueTrackers::RedmineTracker do | ||
19 | problem.reload | 19 | problem.reload |
20 | 20 | ||
21 | requested = have_requested(:post, "#{base_url}/issues.xml") | 21 | requested = have_requested(:post, "#{base_url}/issues.xml") |
22 | - WebMock.should requested.with(:headers => {'X-Redmine-API-Key' => tracker.api_token}) | ||
23 | - WebMock.should requested.with(:body => /<project-id>#{tracker.project_id}<\/project-id>/) | ||
24 | - WebMock.should requested.with(:body => /<subject>\[#{ problem.environment }\]\[#{problem.where}\] #{problem.message.to_s.truncate(100)}<\/subject>/) | ||
25 | - WebMock.should requested.with(:body => /<description>.+<\/description>/m) | 22 | + expect(WebMock).to requested.with(:headers => {'X-Redmine-API-Key' => tracker.api_token}) |
23 | + expect(WebMock).to requested.with(:body => /<project-id>#{tracker.project_id}<\/project-id>/) | ||
24 | + expect(WebMock).to requested.with(:body => /<subject>\[#{ problem.environment }\]\[#{problem.where}\] #{problem.message.to_s.truncate(100)}<\/subject>/) | ||
25 | + expect(WebMock).to requested.with(:body => /<description>.+<\/description>/m) | ||
26 | 26 | ||
27 | - problem.issue_link.should == @issue_link.sub(/\.xml/, '') | 27 | + expect(problem.issue_link).to eq @issue_link.sub(/\.xml/, '') |
28 | end | 28 | end |
29 | 29 | ||
30 | it "should generate a url where a file with line number can be viewed" do | 30 | it "should generate a url where a file with line number can be viewed" do |
31 | t = Fabricate(:redmine_tracker, :account => 'http://redmine.example.com', :project_id => "errbit") | 31 | t = Fabricate(:redmine_tracker, :account => 'http://redmine.example.com', :project_id => "errbit") |
32 | - t.url_to_file("/example/file").should == | ||
33 | - 'http://redmine.example.com/projects/errbit/repository/revisions/master/changes/example/file' | ||
34 | - t.url_to_file("/example/file", 25).should == | ||
35 | - 'http://redmine.example.com/projects/errbit/repository/revisions/master/changes/example/file#L25' | 32 | + expect(t.url_to_file("/example/file")). |
33 | + to eq 'http://redmine.example.com/projects/errbit/repository/revisions/master/changes/example/file' | ||
34 | + expect(t.url_to_file("/example/file", 25)). | ||
35 | + to eq 'http://redmine.example.com/projects/errbit/repository/revisions/master/changes/example/file#L25' | ||
36 | end | 36 | end |
37 | 37 | ||
38 | it "should use the alt_project_id to generate a file/linenumber url, if given" do | 38 | it "should use the alt_project_id to generate a file/linenumber url, if given" do |
39 | t = Fabricate(:redmine_tracker, :account => 'http://redmine.example.com', | 39 | t = Fabricate(:redmine_tracker, :account => 'http://redmine.example.com', |
40 | :project_id => "errbit", | 40 | :project_id => "errbit", |
41 | :alt_project_id => "actual_project") | 41 | :alt_project_id => "actual_project") |
42 | - t.url_to_file("/example/file", 25).should == | ||
43 | - 'http://redmine.example.com/projects/actual_project/repository/revisions/master/changes/example/file#L25' | 42 | + expect(t.url_to_file("/example/file", 25)). |
43 | + to eq 'http://redmine.example.com/projects/actual_project/repository/revisions/master/changes/example/file#L25' | ||
44 | end | 44 | end |
45 | end | 45 | end |
spec/models/issue_trackers/unfuddle_issues_tracker_spec.rb
@@ -83,10 +83,10 @@ EOF | @@ -83,10 +83,10 @@ EOF | ||
83 | problem.reload | 83 | problem.reload |
84 | 84 | ||
85 | requested = have_requested(:post,"https://#{tracker.username}:#{tracker.password}@test.unfuddle.com/api/v1/projects/#{tracker.project_id}/tickets.xml" ) | 85 | requested = have_requested(:post,"https://#{tracker.username}:#{tracker.password}@test.unfuddle.com/api/v1/projects/#{tracker.project_id}/tickets.xml" ) |
86 | - WebMock.should requested.with(:title => /[production][foo#bar] FooError: Too Much Bar/) | ||
87 | - WebMock.should requested.with(:content => /See this exception on Errbit/) | 86 | + expect(WebMock).to requested.with(:title => /[production][foo#bar] FooError: Too Much Bar/) |
87 | + expect(WebMock).to requested.with(:content => /See this exception on Errbit/) | ||
88 | 88 | ||
89 | - problem.issue_link.should == issue_link | ||
90 | - problem.issue_type.should == IssueTrackers::UnfuddleTracker::Label | 89 | + expect(problem.issue_link).to eq issue_link |
90 | + expect(problem.issue_type).to eq IssueTrackers::UnfuddleTracker::Label | ||
91 | end | 91 | end |
92 | end | 92 | end |
spec/models/notice_observer_spec.rb
@@ -17,7 +17,7 @@ describe "Callback on Notice" do | @@ -17,7 +17,7 @@ describe "Callback on Notice" do | ||
17 | custom_thresholds.each do |threshold| | 17 | custom_thresholds.each do |threshold| |
18 | it "sends an email notification after #{threshold} notice(s)" do | 18 | it "sends an email notification after #{threshold} notice(s)" do |
19 | @err.problem.stub(:notices_count).and_return(threshold) | 19 | @err.problem.stub(:notices_count).and_return(threshold) |
20 | - Mailer.should_receive(:err_notification). | 20 | + expect(Mailer).to receive(:err_notification). |
21 | and_return(double('email', :deliver => true)) | 21 | and_return(double('email', :deliver => true)) |
22 | Fabricate(:notice, :err => @err) | 22 | Fabricate(:notice, :err => @err) |
23 | end | 23 | end |
@@ -38,15 +38,15 @@ describe "Callback on Notice" do | @@ -38,15 +38,15 @@ describe "Callback on Notice" do | ||
38 | 38 | ||
39 | it "should send email notification after 1 notice since an error has been resolved" do | 39 | it "should send email notification after 1 notice since an error has been resolved" do |
40 | @err.problem.resolve! | 40 | @err.problem.resolve! |
41 | - Mailer.should_receive(:err_notification). | 41 | + expect(Mailer).to receive(:err_notification). |
42 | and_return(double('email', :deliver => true)) | 42 | and_return(double('email', :deliver => true)) |
43 | Fabricate(:notice, :err => @err) | 43 | Fabricate(:notice, :err => @err) |
44 | end | 44 | end |
45 | it 'self notify if mailer failed' do | 45 | it 'self notify if mailer failed' do |
46 | @err.problem.resolve! | 46 | @err.problem.resolve! |
47 | - Mailer.should_receive(:err_notification). | 47 | + expect(Mailer).to receive(:err_notification). |
48 | and_raise(ArgumentError) | 48 | and_raise(ArgumentError) |
49 | - HoptoadNotifier.should_receive(:notify) | 49 | + expect(HoptoadNotifier).to receive(:notify) |
50 | Fabricate(:notice, :err => @err) | 50 | Fabricate(:notice, :err => @err) |
51 | end | 51 | end |
52 | end | 52 | end |
@@ -65,7 +65,7 @@ describe "Callback on Notice" do | @@ -65,7 +65,7 @@ describe "Callback on Notice" do | ||
65 | end | 65 | end |
66 | 66 | ||
67 | it "should create a campfire notification" do | 67 | it "should create a campfire notification" do |
68 | - app.notification_service.should_receive(:create_notification) | 68 | + expect(app.notification_service).to receive(:create_notification) |
69 | 69 | ||
70 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, | 70 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, |
71 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) | 71 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) |
@@ -88,8 +88,8 @@ describe "Callback on Notice" do | @@ -88,8 +88,8 @@ describe "Callback on Notice" do | ||
88 | end | 88 | end |
89 | 89 | ||
90 | it "send email" do | 90 | it "send email" do |
91 | - app.notification_service.should_receive(:create_notification).and_raise(ArgumentError) | ||
92 | - Mailer.should_receive(:err_notification).and_return(double(:deliver => true)) | 91 | + expect(app.notification_service).to receive(:create_notification).and_raise(ArgumentError) |
92 | + expect(Mailer).to receive(:err_notification).and_return(double(:deliver => true)) | ||
93 | 93 | ||
94 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, | 94 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, |
95 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) | 95 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) |
@@ -110,7 +110,7 @@ describe "Callback on Notice" do | @@ -110,7 +110,7 @@ describe "Callback on Notice" do | ||
110 | end | 110 | end |
111 | 111 | ||
112 | it "should not create a campfire notification" do | 112 | it "should not create a campfire notification" do |
113 | - app.notification_service.should_not_receive(:create_notification) | 113 | + expect(app.notification_service).to_not receive(:create_notification) |
114 | 114 | ||
115 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, | 115 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, |
116 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) | 116 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) |
@@ -130,7 +130,7 @@ describe "Callback on Notice" do | @@ -130,7 +130,7 @@ describe "Callback on Notice" do | ||
130 | end | 130 | end |
131 | 131 | ||
132 | it 'creates a hipchat notification' do | 132 | it 'creates a hipchat notification' do |
133 | - app.notification_service.should_receive(:create_notification) | 133 | + expect(app.notification_service).to receive(:create_notification) |
134 | 134 | ||
135 | Fabricate(:notice, :err => err) | 135 | Fabricate(:notice, :err => err) |
136 | end | 136 | end |
@@ -150,7 +150,7 @@ describe "Callback on Notice" do | @@ -150,7 +150,7 @@ describe "Callback on Notice" do | ||
150 | 150 | ||
151 | it "should create a campfire notification on first notice" do | 151 | it "should create a campfire notification on first notice" do |
152 | err = Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 1)) | 152 | err = Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 1)) |
153 | - app.notification_service.should_receive(:create_notification) | 153 | + expect(app.notification_service).to receive(:create_notification) |
154 | 154 | ||
155 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, | 155 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, |
156 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) | 156 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) |
@@ -158,7 +158,7 @@ describe "Callback on Notice" do | @@ -158,7 +158,7 @@ describe "Callback on Notice" do | ||
158 | 158 | ||
159 | it "should create a campfire notification on second notice" do | 159 | it "should create a campfire notification on second notice" do |
160 | err = Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 1)) | 160 | err = Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 1)) |
161 | - app.notification_service.should_receive(:create_notification) | 161 | + expect(app.notification_service).to receive(:create_notification) |
162 | 162 | ||
163 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, | 163 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, |
164 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) | 164 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) |
@@ -166,7 +166,7 @@ describe "Callback on Notice" do | @@ -166,7 +166,7 @@ describe "Callback on Notice" do | ||
166 | 166 | ||
167 | it "should not create a campfire notification on third notice" do | 167 | it "should not create a campfire notification on third notice" do |
168 | err = Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 1)) | 168 | err = Fabricate(:err, :problem => Fabricate(:problem, :app => app, :notices_count => 1)) |
169 | - app.notification_service.should_receive(:create_notification) | 169 | + expect(app.notification_service).to receive(:create_notification) |
170 | 170 | ||
171 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, | 171 | Notice.create!(:err => err, :message => 'FooError: Too Much Bar', :server_environment => {'environment-name' => 'production'}, |
172 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) | 172 | :backtrace => backtrace, :notifier => { 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }) |
spec/models/notice_spec.rb
@@ -4,20 +4,20 @@ describe Notice do | @@ -4,20 +4,20 @@ describe Notice do | ||
4 | context 'validations' do | 4 | context 'validations' do |
5 | it 'requires a backtrace' do | 5 | it 'requires a backtrace' do |
6 | notice = Fabricate.build(:notice, :backtrace => nil) | 6 | notice = Fabricate.build(:notice, :backtrace => nil) |
7 | - notice.should_not be_valid | ||
8 | - notice.errors[:backtrace].should include("can't be blank") | 7 | + expect(notice).to_not be_valid |
8 | + expect(notice.errors[:backtrace]).to include("can't be blank") | ||
9 | end | 9 | end |
10 | 10 | ||
11 | it 'requires the server_environment' do | 11 | it 'requires the server_environment' do |
12 | notice = Fabricate.build(:notice, :server_environment => nil) | 12 | notice = Fabricate.build(:notice, :server_environment => nil) |
13 | - notice.should_not be_valid | ||
14 | - notice.errors[:server_environment].should include("can't be blank") | 13 | + expect(notice).to_not be_valid |
14 | + expect(notice.errors[:server_environment]).to include("can't be blank") | ||
15 | end | 15 | end |
16 | 16 | ||
17 | it 'requires the notifier' do | 17 | it 'requires the notifier' do |
18 | notice = Fabricate.build(:notice, :notifier => nil) | 18 | notice = Fabricate.build(:notice, :notifier => nil) |
19 | - notice.should_not be_valid | ||
20 | - notice.errors[:notifier].should include("can't be blank") | 19 | + expect(notice).to_not be_valid |
20 | + expect(notice.errors[:notifier]).to include("can't be blank") | ||
21 | end | 21 | end |
22 | end | 22 | end |
23 | 23 | ||
@@ -30,7 +30,7 @@ describe Notice do | @@ -30,7 +30,7 @@ describe Notice do | ||
30 | it "replaces . with . and $ with $ in keys used in #{key}" do | 30 | it "replaces . with . and $ with $ in keys used in #{key}" do |
31 | err = Fabricate(:err) | 31 | err = Fabricate(:err) |
32 | notice = Fabricate(:notice, :err => err, key => @hash) | 32 | notice = Fabricate(:notice, :err => err, key => @hash) |
33 | - notice.send(key).should == @hash_sanitized | 33 | + expect(notice.send(key)).to eq @hash_sanitized |
34 | end | 34 | end |
35 | end | 35 | end |
36 | end | 36 | end |
@@ -40,49 +40,49 @@ describe Notice do | @@ -40,49 +40,49 @@ describe Notice do | ||
40 | notice = Fabricate.build(:notice, :request => {'cgi-data' => { | 40 | notice = Fabricate.build(:notice, :request => {'cgi-data' => { |
41 | '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' | 41 | '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' |
42 | }}) | 42 | }}) |
43 | - notice.user_agent.browser.should == 'Chrome' | ||
44 | - notice.user_agent.version.to_s.should =~ /^10\.0/ | 43 | + expect(notice.user_agent.browser).to eq 'Chrome' |
44 | + expect(notice.user_agent.version.to_s).to match( /^10\.0/ ) | ||
45 | end | 45 | end |
46 | 46 | ||
47 | it "should be nil if HTTP_USER_AGENT is blank" do | 47 | it "should be nil if HTTP_USER_AGENT is blank" do |
48 | notice = Fabricate.build(:notice) | 48 | notice = Fabricate.build(:notice) |
49 | - notice.user_agent.should == nil | 49 | + expect(notice.user_agent).to eq nil |
50 | end | 50 | end |
51 | end | 51 | end |
52 | 52 | ||
53 | describe "user agent string" do | 53 | describe "user agent string" do |
54 | it "should be parsed and human-readable" do | 54 | it "should be parsed and human-readable" do |
55 | notice = Fabricate.build(:notice, :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'}}) | 55 | notice = Fabricate.build(:notice, :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'}}) |
56 | - notice.user_agent_string.should == 'Chrome 10.0.648.204 (OS X 10.6.7)' | 56 | + expect(notice.user_agent_string).to eq 'Chrome 10.0.648.204 (OS X 10.6.7)' |
57 | end | 57 | end |
58 | 58 | ||
59 | it "should be nil if HTTP_USER_AGENT is blank" do | 59 | it "should be nil if HTTP_USER_AGENT is blank" do |
60 | notice = Fabricate.build(:notice) | 60 | notice = Fabricate.build(:notice) |
61 | - notice.user_agent_string.should == "N/A" | 61 | + expect(notice.user_agent_string).to eq "N/A" |
62 | end | 62 | end |
63 | end | 63 | end |
64 | 64 | ||
65 | describe "host" do | 65 | describe "host" do |
66 | it "returns host if url is valid" do | 66 | it "returns host if url is valid" do |
67 | notice = Fabricate.build(:notice, :request => {'url' => "http://example.com/resource/12"}) | 67 | notice = Fabricate.build(:notice, :request => {'url' => "http://example.com/resource/12"}) |
68 | - notice.host.should == 'example.com' | 68 | + expect(notice.host).to eq 'example.com' |
69 | end | 69 | end |
70 | 70 | ||
71 | it "returns 'N/A' when url is not valid" do | 71 | it "returns 'N/A' when url is not valid" do |
72 | notice = Fabricate.build(:notice, :request => {'url' => "some string"}) | 72 | notice = Fabricate.build(:notice, :request => {'url' => "some string"}) |
73 | - notice.host.should == 'N/A' | 73 | + expect(notice.host).to eq 'N/A' |
74 | end | 74 | end |
75 | 75 | ||
76 | it "returns 'N/A' when url is empty" do | 76 | it "returns 'N/A' when url is empty" do |
77 | notice = Fabricate.build(:notice, :request => {}) | 77 | notice = Fabricate.build(:notice, :request => {}) |
78 | - notice.host.should == 'N/A' | 78 | + expect(notice.host).to eq 'N/A' |
79 | end | 79 | end |
80 | end | 80 | end |
81 | 81 | ||
82 | describe "request" do | 82 | describe "request" do |
83 | it "returns empty hash if not set" do | 83 | it "returns empty hash if not set" do |
84 | notice = Notice.new | 84 | notice = Notice.new |
85 | - notice.request.should == {} | 85 | + expect(notice.request).to eq ({}) |
86 | end | 86 | end |
87 | end | 87 | end |
88 | end | 88 | end |
spec/models/notification_service/campfire_service_spec.rb
@@ -13,7 +13,7 @@ describe NotificationService::CampfireService do | @@ -13,7 +13,7 @@ describe NotificationService::CampfireService do | ||
13 | campy.stub(:speak) { true } | 13 | campy.stub(:speak) { true } |
14 | 14 | ||
15 | #assert | 15 | #assert |
16 | - campy.should_receive(:speak) | 16 | + expect(campy).to receive(:speak) |
17 | 17 | ||
18 | notification_service.create_notification(problem) | 18 | notification_service.create_notification(problem) |
19 | end | 19 | end |
spec/models/notification_service/flowdock_service_spec.rb
@@ -7,10 +7,10 @@ describe NotificationServices::FlowdockService do | @@ -7,10 +7,10 @@ describe NotificationServices::FlowdockService do | ||
7 | 7 | ||
8 | it 'sends message in appropriate format' do | 8 | it 'sends message in appropriate format' do |
9 | Flowdock::Flow.any_instance.should_receive(:push_to_team_inbox) do |*args| | 9 | Flowdock::Flow.any_instance.should_receive(:push_to_team_inbox) do |*args| |
10 | - args.first[:content].should_not include('<3') | ||
11 | - args.first[:content].should include('<3') | 10 | + expect(args.first[:content]).to_not include('<3') |
11 | + expect(args.first[:content]).to include('<3') | ||
12 | 12 | ||
13 | - args.first[:project].should eq('App3') | 13 | + expect(args.first[:project]).to eq('App3') |
14 | end | 14 | end |
15 | service.create_notification(problem) | 15 | service.create_notification(problem) |
16 | end | 16 | end |
spec/models/notification_service/gtalk_service_spec.rb
@@ -12,22 +12,22 @@ describe NotificationService::GtalkService do | @@ -12,22 +12,22 @@ describe NotificationService::GtalkService do | ||
12 | gtalk = double('GtalkService') | 12 | gtalk = double('GtalkService') |
13 | jid = double("jid") | 13 | jid = double("jid") |
14 | message = double("message") | 14 | message = double("message") |
15 | - Jabber::JID.should_receive(:new).with(notification_service.subdomain).and_return(jid) | ||
16 | - Jabber::Client.should_receive(:new).with(jid).and_return(gtalk) | ||
17 | - gtalk.should_receive(:connect).with(notification_service.service) | ||
18 | - gtalk.should_receive(:auth).with(notification_service.api_token) | 15 | + expect(Jabber::JID).to receive(:new).with(notification_service.subdomain).and_return(jid) |
16 | + expect(Jabber::Client).to receive(:new).with(jid).and_return(gtalk) | ||
17 | + expect(gtalk).to receive(:connect).with(notification_service.service) | ||
18 | + expect(gtalk).to receive(:auth).with(notification_service.api_token) | ||
19 | message_value = """#{problem.app.name.to_s} | 19 | message_value = """#{problem.app.name.to_s} |
20 | http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} | 20 | http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} |
21 | #{notification_service.notification_description problem}""" | 21 | #{notification_service.notification_description problem}""" |
22 | 22 | ||
23 | - Jabber::Message.should_receive(:new).with(notification_service.user_id, message_value).and_return(message) | ||
24 | - Jabber::Message.should_receive(:new).with(notification_service.room_id, message_value).and_return(message) | 23 | + expect(Jabber::Message).to receive(:new).with(notification_service.user_id, message_value).and_return(message) |
24 | + expect(Jabber::Message).to receive(:new).with(notification_service.room_id, message_value).and_return(message) | ||
25 | 25 | ||
26 | - Jabber::MUC::SimpleMUCClient.should_receive(:new).and_return(gtalk) | ||
27 | - gtalk.should_receive(:join).with(notification_service.room_id + "/errbit") | 26 | + expect(Jabber::MUC::SimpleMUCClient).to receive(:new).and_return(gtalk) |
27 | + expect(gtalk).to receive(:join).with(notification_service.room_id + "/errbit") | ||
28 | 28 | ||
29 | #assert | 29 | #assert |
30 | - gtalk.should_receive(:send).exactly(2).times.with(message) | 30 | + expect(gtalk).to receive(:send).exactly(2).times.with(message) |
31 | 31 | ||
32 | notification_service.create_notification(problem) | 32 | notification_service.create_notification(problem) |
33 | end | 33 | end |
@@ -44,43 +44,43 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} | @@ -44,43 +44,43 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} | ||
44 | 44 | ||
45 | # gtalk stubbing | 45 | # gtalk stubbing |
46 | @gtalk = double('GtalkService') | 46 | @gtalk = double('GtalkService') |
47 | - @gtalk.should_receive(:connect) | ||
48 | - @gtalk.should_receive(:auth) | 47 | + expect(@gtalk).to receive(:connect) |
48 | + expect(@gtalk).to receive(:auth) | ||
49 | jid = double("jid") | 49 | jid = double("jid") |
50 | Jabber::JID.stub(:new).with(@notification_service.subdomain).and_return(jid) | 50 | Jabber::JID.stub(:new).with(@notification_service.subdomain).and_return(jid) |
51 | Jabber::Client.stub(:new).with(jid).and_return(@gtalk) | 51 | Jabber::Client.stub(:new).with(jid).and_return(@gtalk) |
52 | end | 52 | end |
53 | it "should send a notification to all ',' separated users" do | 53 | it "should send a notification to all ',' separated users" do |
54 | - Jabber::Message.should_receive(:new).with("first@domain.org", @error_msg) | ||
55 | - Jabber::Message.should_receive(:new).with("second@domain.org", @error_msg) | ||
56 | - Jabber::Message.should_receive(:new).with("third@domain.org", @error_msg) | ||
57 | - Jabber::Message.should_receive(:new).with("fourth@domain.org", @error_msg) | ||
58 | - Jabber::MUC::SimpleMUCClient.should_not_receive(:new) | ||
59 | - @gtalk.should_receive(:send).exactly(4).times | 54 | + expect(Jabber::Message).to receive(:new).with("first@domain.org", @error_msg) |
55 | + expect(Jabber::Message).to receive(:new).with("second@domain.org", @error_msg) | ||
56 | + expect(Jabber::Message).to receive(:new).with("third@domain.org", @error_msg) | ||
57 | + expect(Jabber::Message).to receive(:new).with("fourth@domain.org", @error_msg) | ||
58 | + expect(Jabber::MUC::SimpleMUCClient).to_not receive(:new) | ||
59 | + expect(@gtalk).to receive(:send).exactly(4).times | ||
60 | 60 | ||
61 | @notification_service.user_id = "first@domain.org,second@domain.org, third@domain.org , fourth@domain.org " | 61 | @notification_service.user_id = "first@domain.org,second@domain.org, third@domain.org , fourth@domain.org " |
62 | @notification_service.room_id = "" | 62 | @notification_service.room_id = "" |
63 | @notification_service.create_notification(@problem) | 63 | @notification_service.create_notification(@problem) |
64 | end | 64 | end |
65 | it "should send a notification to all ';' separated users" do | 65 | it "should send a notification to all ';' separated users" do |
66 | - Jabber::Message.should_receive(:new).with("first@domain.org", @error_msg) | ||
67 | - Jabber::Message.should_receive(:new).with("second@domain.org", @error_msg) | ||
68 | - Jabber::Message.should_receive(:new).with("third@domain.org", @error_msg) | ||
69 | - Jabber::Message.should_receive(:new).with("fourth@domain.org", @error_msg) | ||
70 | - Jabber::MUC::SimpleMUCClient.should_not_receive(:new) | ||
71 | - @gtalk.should_receive(:send).exactly(4).times | 66 | + expect(Jabber::Message).to receive(:new).with("first@domain.org", @error_msg) |
67 | + expect(Jabber::Message).to receive(:new).with("second@domain.org", @error_msg) | ||
68 | + expect(Jabber::Message).to receive(:new).with("third@domain.org", @error_msg) | ||
69 | + expect(Jabber::Message).to receive(:new).with("fourth@domain.org", @error_msg) | ||
70 | + expect(Jabber::MUC::SimpleMUCClient).to_not receive(:new) | ||
71 | + expect(@gtalk).to receive(:send).exactly(4).times | ||
72 | 72 | ||
73 | @notification_service.user_id = "first@domain.org;second@domain.org; third@domain.org ; fourth@domain.org " | 73 | @notification_service.user_id = "first@domain.org;second@domain.org; third@domain.org ; fourth@domain.org " |
74 | @notification_service.room_id = "" | 74 | @notification_service.room_id = "" |
75 | @notification_service.create_notification(@problem) | 75 | @notification_service.create_notification(@problem) |
76 | end | 76 | end |
77 | it "should send a notification to all ' ' separated users" do | 77 | it "should send a notification to all ' ' separated users" do |
78 | - Jabber::Message.should_receive(:new).with("first@domain.org", @error_msg) | ||
79 | - Jabber::Message.should_receive(:new).with("second@domain.org", @error_msg) | ||
80 | - Jabber::Message.should_receive(:new).with("third@domain.org", @error_msg) | ||
81 | - Jabber::Message.should_receive(:new).with("fourth@domain.org", @error_msg) | ||
82 | - Jabber::MUC::SimpleMUCClient.should_not_receive(:new) | ||
83 | - @gtalk.should_receive(:send).exactly(4).times | 78 | + expect(Jabber::Message).to receive(:new).with("first@domain.org", @error_msg) |
79 | + expect(Jabber::Message).to receive(:new).with("second@domain.org", @error_msg) | ||
80 | + expect(Jabber::Message).to receive(:new).with("third@domain.org", @error_msg) | ||
81 | + expect(Jabber::Message).to receive(:new).with("fourth@domain.org", @error_msg) | ||
82 | + expect(Jabber::MUC::SimpleMUCClient).to_not receive(:new) | ||
83 | + expect(@gtalk).to receive(:send).exactly(4).times | ||
84 | 84 | ||
85 | @notification_service.user_id = "first@domain.org second@domain.org third@domain.org fourth@domain.org " | 85 | @notification_service.user_id = "first@domain.org second@domain.org third@domain.org fourth@domain.org " |
86 | @notification_service.room_id = "" | 86 | @notification_service.room_id = "" |
@@ -100,23 +100,23 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} | @@ -100,23 +100,23 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} | ||
100 | gtalk = double('GtalkService') | 100 | gtalk = double('GtalkService') |
101 | jid = double("jid") | 101 | jid = double("jid") |
102 | message = double("message") | 102 | message = double("message") |
103 | - Jabber::JID.should_receive(:new).with(notification_service.subdomain).and_return(jid) | ||
104 | - Jabber::Client.should_receive(:new).with(jid).and_return(gtalk) | ||
105 | - gtalk.should_receive(:connect) | ||
106 | - gtalk.should_receive(:auth).with(notification_service.api_token) | 103 | + expect(Jabber::JID).to receive(:new).with(notification_service.subdomain).and_return(jid) |
104 | + expect(Jabber::Client).to receive(:new).with(jid).and_return(gtalk) | ||
105 | + expect(gtalk).to receive(:connect) | ||
106 | + expect(gtalk).to receive(:auth).with(notification_service.api_token) | ||
107 | message_value = """#{problem.app.name.to_s} | 107 | message_value = """#{problem.app.name.to_s} |
108 | http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} | 108 | http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} |
109 | #{notification_service.notification_description problem}""" | 109 | #{notification_service.notification_description problem}""" |
110 | 110 | ||
111 | - Jabber::Message.should_receive(:new).with(notification_service.room_id, message_value).and_return(message) | 111 | + expect(Jabber::Message).to receive(:new).with(notification_service.room_id, message_value).and_return(message) |
112 | 112 | ||
113 | - Jabber::MUC::SimpleMUCClient.should_receive(:new).and_return(gtalk) | ||
114 | - gtalk.should_receive(:join).with(notification_service.room_id + "/errbit") | 113 | + expect(Jabber::MUC::SimpleMUCClient).to receive(:new).and_return(gtalk) |
114 | + expect(gtalk).to receive(:join).with(notification_service.room_id + "/errbit") | ||
115 | 115 | ||
116 | notification_service.user_id = "" | 116 | notification_service.user_id = "" |
117 | 117 | ||
118 | #assert | 118 | #assert |
119 | - gtalk.should_receive(:send).with(message) | 119 | + expect(gtalk).to receive(:send).with(message) |
120 | 120 | ||
121 | notification_service.create_notification(problem) | 121 | notification_service.create_notification(problem) |
122 | end | 122 | end |
spec/models/notification_service/hipchat_service_spec.rb
@@ -10,15 +10,15 @@ describe NotificationServices::HipchatService do | @@ -10,15 +10,15 @@ describe NotificationServices::HipchatService do | ||
10 | end | 10 | end |
11 | 11 | ||
12 | it 'sends message' do | 12 | it 'sends message' do |
13 | - room.should_receive(:send) | 13 | + expect(room).to receive(:send) |
14 | service.create_notification(problem) | 14 | service.create_notification(problem) |
15 | end | 15 | end |
16 | 16 | ||
17 | it 'escapes html in message' do | 17 | it 'escapes html in message' do |
18 | problem.stub(:message => '<3') | 18 | problem.stub(:message => '<3') |
19 | - room.should_receive(:send) do |_, message| | ||
20 | - message.should_not include('<3') | ||
21 | - message.should include('<3') | 19 | + expect(room).to receive(:send) do |_, message| |
20 | + expect(message).to_not include('<3') | ||
21 | + expect(message).to include('<3') | ||
22 | end | 22 | end |
23 | service.create_notification(problem) | 23 | service.create_notification(problem) |
24 | end | 24 | end |
spec/models/notification_service/hoiio_service_spec.rb
@@ -13,7 +13,7 @@ describe NotificationService::HoiioService do | @@ -13,7 +13,7 @@ describe NotificationService::HoiioService do | ||
13 | sms.stub(:send) { true } | 13 | sms.stub(:send) { true } |
14 | 14 | ||
15 | #assert | 15 | #assert |
16 | - sms.should_receive(:send) | 16 | + expect(sms).to receive(:send) |
17 | 17 | ||
18 | notification_service.create_notification(problem) | 18 | notification_service.create_notification(problem) |
19 | end | 19 | end |
spec/models/notification_service/hubot_service_spec.rb
@@ -8,7 +8,7 @@ describe NotificationService::HubotService do | @@ -8,7 +8,7 @@ describe NotificationService::HubotService do | ||
8 | problem = notice.problem | 8 | problem = notice.problem |
9 | 9 | ||
10 | # faraday stubbing | 10 | # faraday stubbing |
11 | - HTTParty.should_receive(:post).with(notification_service.api_token, :body => {:message => an_instance_of(String), :room => notification_service.room_id}).and_return(true) | 11 | + expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => {:message => an_instance_of(String), :room => notification_service.room_id}).and_return(true) |
12 | 12 | ||
13 | notification_service.create_notification(problem) | 13 | notification_service.create_notification(problem) |
14 | end | 14 | end |
spec/models/notification_service/pushover_service_spec.rb
@@ -13,7 +13,7 @@ describe NotificationService::PushoverService do | @@ -13,7 +13,7 @@ describe NotificationService::PushoverService do | ||
13 | notification.stub(:notify) { true } | 13 | notification.stub(:notify) { true } |
14 | 14 | ||
15 | #assert | 15 | #assert |
16 | - notification.should_receive(:notify) | 16 | + expect(notification).to receive(:notify) |
17 | 17 | ||
18 | notification_service.create_notification(problem) | 18 | notification_service.create_notification(problem) |
19 | end | 19 | end |
spec/models/notification_service/webhook_service_spec.rb
@@ -6,7 +6,7 @@ describe NotificationService::WebhookService do | @@ -6,7 +6,7 @@ describe NotificationService::WebhookService do | ||
6 | notification_service = Fabricate :webhook_notification_service, :app => notice.app | 6 | notification_service = Fabricate :webhook_notification_service, :app => notice.app |
7 | problem = notice.problem | 7 | problem = notice.problem |
8 | 8 | ||
9 | - HTTParty.should_receive(:post).with(notification_service.api_token, :body => {:problem => problem.to_json}).and_return(true) | 9 | + expect(HTTParty).to receive(:post).with(notification_service.api_token, :body => {:problem => problem.to_json}).and_return(true) |
10 | 10 | ||
11 | notification_service.create_notification(problem) | 11 | notification_service.create_notification(problem) |
12 | end | 12 | end |
spec/models/problem_spec.rb
@@ -5,33 +5,33 @@ describe Problem do | @@ -5,33 +5,33 @@ describe Problem do | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'requires an environment' do | 6 | it 'requires an environment' do |
7 | err = Fabricate.build(:problem, :environment => nil) | 7 | err = Fabricate.build(:problem, :environment => nil) |
8 | - err.should_not be_valid | ||
9 | - err.errors[:environment].should include("can't be blank") | 8 | + expect(err).to_not be_valid |
9 | + expect(err.errors[:environment]).to include("can't be blank") | ||
10 | end | 10 | end |
11 | end | 11 | end |
12 | 12 | ||
13 | describe "Fabrication" do | 13 | describe "Fabrication" do |
14 | context "Fabricate(:problem)" do | 14 | context "Fabricate(:problem)" do |
15 | it 'should have no comment' do | 15 | it 'should have no comment' do |
16 | - lambda do | 16 | + expect{ |
17 | Fabricate(:problem) | 17 | Fabricate(:problem) |
18 | - end.should_not change(Comment, :count) | 18 | + }.to_not change(Comment, :count) |
19 | end | 19 | end |
20 | end | 20 | end |
21 | 21 | ||
22 | context "Fabricate(:problem_with_comments)" do | 22 | context "Fabricate(:problem_with_comments)" do |
23 | it 'should have 3 comments' do | 23 | it 'should have 3 comments' do |
24 | - lambda do | 24 | + expect{ |
25 | Fabricate(:problem_with_comments) | 25 | Fabricate(:problem_with_comments) |
26 | - end.should change(Comment, :count).by(3) | 26 | + }.to change(Comment, :count).by(3) |
27 | end | 27 | end |
28 | end | 28 | end |
29 | 29 | ||
30 | context "Fabricate(:problem_with_errs)" do | 30 | context "Fabricate(:problem_with_errs)" do |
31 | it 'should have 3 errs' do | 31 | it 'should have 3 errs' do |
32 | - lambda do | 32 | + expect{ |
33 | Fabricate(:problem_with_errs) | 33 | Fabricate(:problem_with_errs) |
34 | - end.should change(Err, :count).by(3) | 34 | + }.to change(Err, :count).by(3) |
35 | end | 35 | end |
36 | end | 36 | end |
37 | end | 37 | end |
@@ -40,13 +40,13 @@ describe Problem do | @@ -40,13 +40,13 @@ describe Problem do | ||
40 | it "returns the created_at timestamp of the latest notice" do | 40 | it "returns the created_at timestamp of the latest notice" do |
41 | err = Fabricate(:err) | 41 | err = Fabricate(:err) |
42 | problem = err.problem | 42 | problem = err.problem |
43 | - problem.should_not be_nil | 43 | + expect(problem).to_not be_nil |
44 | 44 | ||
45 | notice1 = Fabricate(:notice, :err => err) | 45 | notice1 = Fabricate(:notice, :err => err) |
46 | - problem.last_notice_at.should == notice1.created_at | 46 | + expect(problem.last_notice_at).to eq notice1.created_at |
47 | 47 | ||
48 | notice2 = Fabricate(:notice, :err => err) | 48 | notice2 = Fabricate(:notice, :err => err) |
49 | - problem.last_notice_at.should == notice2.created_at | 49 | + expect(problem.last_notice_at).to eq notice2.created_at |
50 | end | 50 | end |
51 | end | 51 | end |
52 | 52 | ||
@@ -54,7 +54,7 @@ describe Problem do | @@ -54,7 +54,7 @@ describe Problem do | ||
54 | it "returns the created_at timestamp of the first notice" do | 54 | it "returns the created_at timestamp of the first notice" do |
55 | err = Fabricate(:err) | 55 | err = Fabricate(:err) |
56 | problem = err.problem | 56 | problem = err.problem |
57 | - problem.should_not be_nil | 57 | + expect(problem).to_not be_nil |
58 | 58 | ||
59 | notice1 = Fabricate(:notice, :err => err) | 59 | notice1 = Fabricate(:notice, :err => err) |
60 | 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) |
@@ -68,9 +68,9 @@ describe Problem do | @@ -68,9 +68,9 @@ describe Problem do | ||
68 | it "adding a notice caches its message" do | 68 | it "adding a notice caches its message" do |
69 | err = Fabricate(:err) | 69 | err = Fabricate(:err) |
70 | problem = err.problem | 70 | problem = err.problem |
71 | - lambda { | 71 | + expect { |
72 | Fabricate(:notice, :err => err, :message => 'ERR 1') | 72 | Fabricate(:notice, :err => err, :message => 'ERR 1') |
73 | - }.should change(problem, :message).from(nil).to('ERR 1') | 73 | + }.to change(problem, :message).from(nil).to('ERR 1') |
74 | end | 74 | end |
75 | end | 75 | end |
76 | 76 | ||
@@ -78,7 +78,7 @@ describe Problem do | @@ -78,7 +78,7 @@ describe Problem do | ||
78 | context 'when the app has err notifications set to false' do | 78 | context 'when the app has err notifications set to false' do |
79 | it 'should not send an email notification' do | 79 | it 'should not send an email notification' do |
80 | app = Fabricate(:app_with_watcher, :notify_on_errs => false) | 80 | app = Fabricate(:app_with_watcher, :notify_on_errs => false) |
81 | - Mailer.should_not_receive(:err_notification) | 81 | + expect(Mailer).to_not receive(:err_notification) |
82 | Fabricate(:problem, :app => app) | 82 | Fabricate(:problem, :app => app) |
83 | end | 83 | end |
84 | end | 84 | end |
@@ -87,24 +87,24 @@ describe Problem do | @@ -87,24 +87,24 @@ describe Problem do | ||
87 | context "#resolved?" do | 87 | context "#resolved?" do |
88 | it "should start out as unresolved" do | 88 | it "should start out as unresolved" do |
89 | problem = Problem.new | 89 | problem = Problem.new |
90 | - problem.should_not be_resolved | ||
91 | - problem.should be_unresolved | 90 | + expect(problem).to_not be_resolved |
91 | + expect(problem).to be_unresolved | ||
92 | end | 92 | end |
93 | 93 | ||
94 | it "should be able to be resolved" do | 94 | it "should be able to be resolved" do |
95 | problem = Fabricate(:problem) | 95 | problem = Fabricate(:problem) |
96 | - problem.should_not be_resolved | 96 | + expect(problem).to_not be_resolved |
97 | problem.resolve! | 97 | problem.resolve! |
98 | - problem.reload.should be_resolved | 98 | + expect(problem.reload).to be_resolved |
99 | end | 99 | end |
100 | end | 100 | end |
101 | 101 | ||
102 | context "resolve!" do | 102 | context "resolve!" do |
103 | it "marks the problem as resolved" do | 103 | it "marks the problem as resolved" do |
104 | problem = Fabricate(:problem) | 104 | problem = Fabricate(:problem) |
105 | - problem.should_not be_resolved | 105 | + expect(problem).to_not be_resolved |
106 | problem.resolve! | 106 | problem.resolve! |
107 | - problem.should be_resolved | 107 | + expect(problem).to be_resolved |
108 | end | 108 | end |
109 | 109 | ||
110 | it "should record the time when it was resolved" do | 110 | it "should record the time when it was resolved" do |
@@ -113,31 +113,31 @@ describe Problem do | @@ -113,31 +113,31 @@ describe Problem do | ||
113 | Timecop.freeze(expected_resolved_at) do | 113 | Timecop.freeze(expected_resolved_at) do |
114 | problem.resolve! | 114 | problem.resolve! |
115 | end | 115 | end |
116 | - problem.resolved_at.to_s.should == expected_resolved_at.to_s | 116 | + expect(problem.resolved_at.to_s).to eq expected_resolved_at.to_s |
117 | end | 117 | end |
118 | 118 | ||
119 | it "should not reset notice count" do | 119 | it "should not reset notice count" do |
120 | problem = Fabricate(:problem, :notices_count => 1) | 120 | problem = Fabricate(:problem, :notices_count => 1) |
121 | original_notices_count = problem.notices_count | 121 | original_notices_count = problem.notices_count |
122 | - original_notices_count.should > 0 | 122 | + expect(original_notices_count).to be > 0 |
123 | 123 | ||
124 | problem.resolve! | 124 | problem.resolve! |
125 | - problem.notices_count.should == original_notices_count | 125 | + expect(problem.notices_count).to eq original_notices_count |
126 | end | 126 | end |
127 | 127 | ||
128 | it "should throw an err if it's not successful" do | 128 | it "should throw an err if it's not successful" do |
129 | problem = Fabricate(:problem) | 129 | problem = Fabricate(:problem) |
130 | - problem.should_not be_resolved | 130 | + expect(problem).to_not be_resolved |
131 | problem.stub(:valid?).and_return(false) | 131 | problem.stub(:valid?).and_return(false) |
132 | ## update_attributes not test #valid? but #errors.any? | 132 | ## update_attributes not test #valid? but #errors.any? |
133 | # https://github.com/mongoid/mongoid/blob/master/lib/mongoid/persistence.rb#L137 | 133 | # https://github.com/mongoid/mongoid/blob/master/lib/mongoid/persistence.rb#L137 |
134 | er = ActiveModel::Errors.new(problem) | 134 | er = ActiveModel::Errors.new(problem) |
135 | er.add_on_blank(:resolved) | 135 | er.add_on_blank(:resolved) |
136 | problem.stub(:errors).and_return(er) | 136 | problem.stub(:errors).and_return(er) |
137 | - problem.should_not be_valid | ||
138 | - lambda { | 137 | + expect(problem).to_not be_valid |
138 | + expect { | ||
139 | problem.resolve! | 139 | problem.resolve! |
140 | - }.should raise_error(Mongoid::Errors::Validations) | 140 | + }.to raise_error(Mongoid::Errors::Validations) |
141 | end | 141 | end |
142 | end | 142 | end |
143 | 143 | ||
@@ -146,10 +146,10 @@ describe Problem do | @@ -146,10 +146,10 @@ describe Problem do | ||
146 | problem1 = Fabricate(:notice).problem | 146 | problem1 = Fabricate(:notice).problem |
147 | problem2 = Fabricate(:notice).problem | 147 | problem2 = Fabricate(:notice).problem |
148 | merged_problem = Problem.merge!(problem1, problem2) | 148 | merged_problem = Problem.merge!(problem1, problem2) |
149 | - merged_problem.errs.length.should == 2 | 149 | + expect(merged_problem.errs.length).to eq 2 |
150 | 150 | ||
151 | expect { merged_problem.unmerge! }.to change(Problem, :count).by(1) | 151 | expect { merged_problem.unmerge! }.to change(Problem, :count).by(1) |
152 | - merged_problem.errs(true).length.should == 1 | 152 | + expect(merged_problem.errs(true).length).to eq 1 |
153 | end | 153 | end |
154 | 154 | ||
155 | it "runs smoothly for problem without errs" do | 155 | it "runs smoothly for problem without errs" do |
@@ -162,8 +162,8 @@ describe Problem do | @@ -162,8 +162,8 @@ describe Problem do | ||
162 | it 'only finds resolved Problems' do | 162 | it 'only finds resolved Problems' do |
163 | resolved = Fabricate(:problem, :resolved => true) | 163 | resolved = Fabricate(:problem, :resolved => true) |
164 | unresolved = Fabricate(:problem, :resolved => false) | 164 | unresolved = Fabricate(:problem, :resolved => false) |
165 | - Problem.resolved.all.should include(resolved) | ||
166 | - Problem.resolved.all.should_not include(unresolved) | 165 | + expect(Problem.resolved.all).to include(resolved) |
166 | + expect(Problem.resolved.all).to_not include(unresolved) | ||
167 | end | 167 | end |
168 | end | 168 | end |
169 | 169 | ||
@@ -171,8 +171,8 @@ describe Problem do | @@ -171,8 +171,8 @@ describe Problem do | ||
171 | it 'only finds unresolved Problems' do | 171 | it 'only finds unresolved Problems' do |
172 | resolved = Fabricate(:problem, :resolved => true) | 172 | resolved = Fabricate(:problem, :resolved => true) |
173 | unresolved = Fabricate(:problem, :resolved => false) | 173 | unresolved = Fabricate(:problem, :resolved => false) |
174 | - Problem.unresolved.all.should_not include(resolved) | ||
175 | - Problem.unresolved.all.should include(unresolved) | 174 | + expect(Problem.unresolved.all).to_not include(resolved) |
175 | + expect(Problem.unresolved.all).to include(unresolved) | ||
176 | end | 176 | end |
177 | end | 177 | end |
178 | 178 | ||
@@ -182,12 +182,12 @@ describe Problem do | @@ -182,12 +182,12 @@ describe Problem do | ||
182 | :message => "other", :where => 'errorclass', :environment => 'development', :app_name => 'other') | 182 | :message => "other", :where => 'errorclass', :environment => 'development', :app_name => 'other') |
183 | dont_find = Fabricate(:problem, :resolved => false, :error_class => "Batman", | 183 | dont_find = Fabricate(:problem, :resolved => false, :error_class => "Batman", |
184 | :message => 'todo', :where => 'classerror', :environment => 'development', :app_name => 'other') | 184 | :message => 'todo', :where => 'classerror', :environment => 'development', :app_name => 'other') |
185 | - Problem.search("theErrorClass").unresolved.should include(find) | ||
186 | - Problem.search("theErrorClass").unresolved.should_not include(dont_find) | 185 | + expect(Problem.search("theErrorClass").unresolved).to include(find) |
186 | + expect(Problem.search("theErrorClass").unresolved).to_not include(dont_find) | ||
187 | end | 187 | end |
188 | it 'find on where message' do | 188 | it 'find on where message' do |
189 | problem = Fabricate(:problem, :where => 'cyril') | 189 | problem = Fabricate(:problem, :where => 'cyril') |
190 | - Problem.search('cyril').entries.should eq [problem] | 190 | + expect(Problem.search('cyril').entries).to eq [problem] |
191 | end | 191 | end |
192 | end | 192 | end |
193 | end | 193 | end |
@@ -200,13 +200,13 @@ describe Problem do | @@ -200,13 +200,13 @@ describe Problem do | ||
200 | end | 200 | end |
201 | 201 | ||
202 | it "#notices_count returns 0 by default" do | 202 | it "#notices_count returns 0 by default" do |
203 | - @problem.notices_count.should == 0 | 203 | + expect(@problem.notices_count).to eq 0 |
204 | end | 204 | end |
205 | 205 | ||
206 | it "adding a notice increases #notices_count by 1" do | 206 | it "adding a notice increases #notices_count by 1" do |
207 | - lambda { | 207 | + expect { |
208 | Fabricate(:notice, :err => @err, :message => 'ERR 1') | 208 | Fabricate(:notice, :err => @err, :message => 'ERR 1') |
209 | - }.should change(@problem.reload, :notices_count).from(0).to(1) | 209 | + }.to change(@problem.reload, :notices_count).from(0).to(1) |
210 | end | 210 | end |
211 | 211 | ||
212 | it "removing a notice decreases #notices_count by 1" do | 212 | it "removing a notice decreases #notices_count by 1" do |
@@ -229,10 +229,10 @@ describe Problem do | @@ -229,10 +229,10 @@ describe Problem do | ||
229 | end | 229 | end |
230 | 230 | ||
231 | it "is updated when an app is updated" do | 231 | it "is updated when an app is updated" do |
232 | - lambda { | 232 | + expect { |
233 | app.update_attributes!(:name => "Bar App") | 233 | app.update_attributes!(:name => "Bar App") |
234 | problem.reload | 234 | problem.reload |
235 | - }.should change(problem, :app_name).to("Bar App") | 235 | + }.to change(problem, :app_name).to("Bar App") |
236 | end | 236 | end |
237 | end | 237 | end |
238 | 238 | ||
@@ -251,10 +251,10 @@ describe Problem do | @@ -251,10 +251,10 @@ describe Problem do | ||
251 | it "is updated when a deploy is created" do | 251 | it "is updated when a deploy is created" do |
252 | problem = Fabricate(:problem, :app => @app, :environment => "production") | 252 | problem = Fabricate(:problem, :app => @app, :environment => "production") |
253 | next_deploy = Time.at(5.minutes.ago.localtime.to_i) | 253 | next_deploy = Time.at(5.minutes.ago.localtime.to_i) |
254 | - lambda { | 254 | + expect { |
255 | @deploy = Fabricate(:deploy, :app => @app, :created_at => next_deploy) | 255 | @deploy = Fabricate(:deploy, :app => @app, :created_at => next_deploy) |
256 | problem.reload | 256 | problem.reload |
257 | - }.should change(problem, :last_deploy_at).from(@last_deploy).to(next_deploy) | 257 | + }.to change(problem, :last_deploy_at).from(@last_deploy).to(next_deploy) |
258 | end | 258 | end |
259 | end | 259 | end |
260 | 260 | ||
@@ -266,21 +266,21 @@ describe Problem do | @@ -266,21 +266,21 @@ describe Problem do | ||
266 | end | 266 | end |
267 | 267 | ||
268 | it "#messages should be empty by default" do | 268 | it "#messages should be empty by default" do |
269 | - @problem.messages.should == {} | 269 | + expect(@problem.messages).to eq ({}) |
270 | end | 270 | end |
271 | 271 | ||
272 | it "adding a notice adds a string to #messages" do | 272 | it "adding a notice adds a string to #messages" do |
273 | - lambda { | 273 | + expect { |
274 | Fabricate(:notice, :err => @err, :message => 'ERR 1') | 274 | Fabricate(:notice, :err => @err, :message => 'ERR 1') |
275 | - }.should change(@problem, :messages).from({}).to({Digest::MD5.hexdigest('ERR 1') => {'value' => 'ERR 1', 'count' => 1}}) | 275 | + }.to change(@problem, :messages).from({}).to({Digest::MD5.hexdigest('ERR 1') => {'value' => 'ERR 1', 'count' => 1}}) |
276 | end | 276 | end |
277 | 277 | ||
278 | it "removing a notice removes string from #messages" do | 278 | it "removing a notice removes string from #messages" do |
279 | notice1 = Fabricate(:notice, :err => @err, :message => 'ERR 1') | 279 | notice1 = Fabricate(:notice, :err => @err, :message => 'ERR 1') |
280 | - lambda { | 280 | + expect { |
281 | @err.notices.first.destroy | 281 | @err.notices.first.destroy |
282 | @problem.reload | 282 | @problem.reload |
283 | - }.should change(@problem, :messages).from({Digest::MD5.hexdigest('ERR 1') => {'value' => 'ERR 1', 'count' => 1}}).to({}) | 283 | + }.to change(@problem, :messages).from({Digest::MD5.hexdigest('ERR 1') => {'value' => 'ERR 1', 'count' => 1}}).to({}) |
284 | end | 284 | end |
285 | 285 | ||
286 | it "removing a notice from the problem with broken counter should not raise an error" do | 286 | it "removing a notice from the problem with broken counter should not raise an error" do |
@@ -299,21 +299,21 @@ describe Problem do | @@ -299,21 +299,21 @@ describe Problem do | ||
299 | end | 299 | end |
300 | 300 | ||
301 | it "#hosts should be empty by default" do | 301 | it "#hosts should be empty by default" do |
302 | - @problem.hosts.should == {} | 302 | + expect(@problem.hosts).to eq ({}) |
303 | end | 303 | end |
304 | 304 | ||
305 | it "adding a notice adds a string to #hosts" do | 305 | it "adding a notice adds a string to #hosts" do |
306 | - lambda { | 306 | + expect { |
307 | Fabricate(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) | 307 | Fabricate(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) |
308 | - }.should change(@problem, :hosts).from({}).to({Digest::MD5.hexdigest('example.com') => {'value' => 'example.com', 'count' => 1}}) | 308 | + }.to change(@problem, :hosts).from({}).to({Digest::MD5.hexdigest('example.com') => {'value' => 'example.com', 'count' => 1}}) |
309 | end | 309 | end |
310 | 310 | ||
311 | it "removing a notice removes string from #hosts" do | 311 | it "removing a notice removes string from #hosts" do |
312 | notice1 = Fabricate(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) | 312 | notice1 = Fabricate(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) |
313 | - lambda { | 313 | + expect { |
314 | @err.notices.first.destroy | 314 | @err.notices.first.destroy |
315 | @problem.reload | 315 | @problem.reload |
316 | - }.should change(@problem, :hosts).from({Digest::MD5.hexdigest('example.com') => {'value' => 'example.com', 'count' => 1}}).to({}) | 316 | + }.to change(@problem, :hosts).from({Digest::MD5.hexdigest('example.com') => {'value' => 'example.com', 'count' => 1}}).to({}) |
317 | end | 317 | end |
318 | end | 318 | end |
319 | 319 | ||
@@ -325,21 +325,21 @@ describe Problem do | @@ -325,21 +325,21 @@ describe Problem do | ||
325 | end | 325 | end |
326 | 326 | ||
327 | it "#user_agents should be empty by default" do | 327 | it "#user_agents should be empty by default" do |
328 | - @problem.user_agents.should == {} | 328 | + expect(@problem.user_agents).to eq ({}) |
329 | end | 329 | end |
330 | 330 | ||
331 | it "adding a notice adds a string to #user_agents" do | 331 | it "adding a notice adds a string to #user_agents" do |
332 | - lambda { | 332 | + expect { |
333 | 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'}}) | 333 | 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'}}) |
334 | - }.should change(@problem, :user_agents).from({}).to({Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => {'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1}}) | 334 | + }.to change(@problem, :user_agents).from({}).to({Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => {'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1}}) |
335 | end | 335 | end |
336 | 336 | ||
337 | it "removing a notice removes string from #user_agents" do | 337 | 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'}}) | 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'}}) |
339 | - lambda { | 339 | + expect { |
340 | @err.notices.first.destroy | 340 | @err.notices.first.destroy |
341 | @problem.reload | 341 | @problem.reload |
342 | - }.should change(@problem, :user_agents).from({ | 342 | + }.to change(@problem, :user_agents).from({ |
343 | Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => {'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1} | 343 | Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => {'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1} |
344 | }).to({}) | 344 | }).to({}) |
345 | end | 345 | end |
@@ -352,21 +352,21 @@ describe Problem do | @@ -352,21 +352,21 @@ describe Problem do | ||
352 | end | 352 | end |
353 | 353 | ||
354 | it "#comments_count returns 0 by default" do | 354 | it "#comments_count returns 0 by default" do |
355 | - @problem.comments_count.should == 0 | 355 | + expect(@problem.comments_count).to eq 0 |
356 | end | 356 | end |
357 | 357 | ||
358 | it "adding a comment increases #comments_count by 1" do | 358 | it "adding a comment increases #comments_count by 1" do |
359 | - lambda { | 359 | + expect { |
360 | Fabricate(:comment, :err => @problem) | 360 | Fabricate(:comment, :err => @problem) |
361 | - }.should change(@problem, :comments_count).from(0).to(1) | 361 | + }.to change(@problem, :comments_count).from(0).to(1) |
362 | end | 362 | end |
363 | 363 | ||
364 | it "removing a comment decreases #comments_count by 1" do | 364 | it "removing a comment decreases #comments_count by 1" do |
365 | comment1 = Fabricate(:comment, :err => @problem) | 365 | comment1 = Fabricate(:comment, :err => @problem) |
366 | - lambda { | 366 | + expect { |
367 | @problem.reload.comments.first.destroy | 367 | @problem.reload.comments.first.destroy |
368 | @problem.reload | 368 | @problem.reload |
369 | - }.should change(@problem, :comments_count).from(1).to(0) | 369 | + }.to change(@problem, :comments_count).from(1).to(0) |
370 | end | 370 | end |
371 | end | 371 | end |
372 | 372 |
spec/models/user_spec.rb
@@ -5,38 +5,38 @@ describe User do | @@ -5,38 +5,38 @@ describe User do | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'require that a name is present' do | 6 | it 'require that a name is present' do |
7 | user = Fabricate.build(:user, :name => nil) | 7 | user = Fabricate.build(:user, :name => nil) |
8 | - user.should_not be_valid | ||
9 | - user.errors[:name].should include("can't be blank") | 8 | + expect(user).to_not be_valid |
9 | + expect(user.errors[:name]).to include("can't be blank") | ||
10 | end | 10 | end |
11 | 11 | ||
12 | it 'requires password without github login' do | 12 | it 'requires password without github login' do |
13 | user = Fabricate.build(:user, :password => nil) | 13 | user = Fabricate.build(:user, :password => nil) |
14 | - user.should_not be_valid | ||
15 | - user.errors[:password].should include("can't be blank") | 14 | + expect(user).to_not be_valid |
15 | + expect(user.errors[:password]).to include("can't be blank") | ||
16 | end | 16 | end |
17 | 17 | ||
18 | it "doesn't require password with github login" do | 18 | it "doesn't require password with github login" do |
19 | user = Fabricate.build(:user, :password => nil, :github_login => 'nashby') | 19 | user = Fabricate.build(:user, :password => nil, :github_login => 'nashby') |
20 | - user.should be_valid | 20 | + expect(user).to be_valid |
21 | end | 21 | end |
22 | 22 | ||
23 | it 'requires uniq github login' do | 23 | it 'requires uniq github login' do |
24 | user1 = Fabricate(:user, :github_login => 'nashby') | 24 | user1 = Fabricate(:user, :github_login => 'nashby') |
25 | - user1.should be_valid | 25 | + expect(user1).to be_valid |
26 | 26 | ||
27 | user2 = Fabricate.build(:user, :github_login => 'nashby') | 27 | user2 = Fabricate.build(:user, :github_login => 'nashby') |
28 | user2.save | 28 | user2.save |
29 | - user2.should_not be_valid | ||
30 | - user2.errors[:github_login].should include("is already taken") | 29 | + expect(user2).to_not be_valid |
30 | + expect(user2.errors[:github_login]).to include("is already taken") | ||
31 | end | 31 | end |
32 | 32 | ||
33 | it 'allows blank / null github_login' do | 33 | it 'allows blank / null github_login' do |
34 | user1 = Fabricate(:user, :github_login => ' ') | 34 | user1 = Fabricate(:user, :github_login => ' ') |
35 | - user1.should be_valid | 35 | + expect(user1).to be_valid |
36 | 36 | ||
37 | user2 = Fabricate.build(:user, :github_login => ' ') | 37 | user2 = Fabricate.build(:user, :github_login => ' ') |
38 | user2.save | 38 | user2.save |
39 | - user2.should be_valid | 39 | + expect(user2).to be_valid |
40 | end | 40 | end |
41 | end | 41 | end |
42 | 42 | ||
@@ -45,8 +45,8 @@ describe User do | @@ -45,8 +45,8 @@ describe User do | ||
45 | it 'has many watchers' do | 45 | it 'has many watchers' do |
46 | user = Fabricate(:user) | 46 | user = Fabricate(:user) |
47 | watcher = Fabricate(:user_watcher, :user => user) | 47 | watcher = Fabricate(:user_watcher, :user => user) |
48 | - user.watchers.should_not be_empty | ||
49 | - user.watchers.should include(watcher) | 48 | + expect(user.watchers).to_not be_empty |
49 | + expect(user.watchers).to include(watcher) | ||
50 | end | 50 | end |
51 | 51 | ||
52 | it "has many apps through watchers" do | 52 | it "has many apps through watchers" do |
@@ -54,8 +54,8 @@ describe User do | @@ -54,8 +54,8 @@ describe User do | ||
54 | watched_app = Fabricate(:app) | 54 | watched_app = Fabricate(:app) |
55 | unwatched_app = Fabricate(:app) | 55 | unwatched_app = Fabricate(:app) |
56 | watcher = Fabricate(:user_watcher, :app => watched_app, :user => user) | 56 | watcher = Fabricate(:user_watcher, :app => watched_app, :user => user) |
57 | - user.apps.all.should include(watched_app) | ||
58 | - user.apps.all.should_not include(unwatched_app) | 57 | + expect(user.apps.all).to include(watched_app) |
58 | + expect(user.apps.all).to_not include(unwatched_app) | ||
59 | end | 59 | end |
60 | 60 | ||
61 | end | 61 | end |
spec/models/watcher_spec.rb
@@ -5,18 +5,18 @@ describe Watcher do | @@ -5,18 +5,18 @@ describe Watcher do | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'requires an email address or an associated user' do | 6 | it 'requires an email address or an associated user' do |
7 | watcher = Fabricate.build(:watcher, :email => nil, :user => nil) | 7 | watcher = Fabricate.build(:watcher, :email => nil, :user => nil) |
8 | - watcher.should_not be_valid | ||
9 | - watcher.errors[:base].should include("You must specify either a user or an email address") | 8 | + expect(watcher).to_not be_valid |
9 | + expect(watcher.errors[:base]).to include("You must specify either a user or an email address") | ||
10 | 10 | ||
11 | watcher.email = 'watcher@example.com' | 11 | watcher.email = 'watcher@example.com' |
12 | - watcher.should be_valid | 12 | + expect(watcher).to be_valid |
13 | 13 | ||
14 | watcher.email = nil | 14 | watcher.email = nil |
15 | - watcher.should_not be_valid | 15 | + expect(watcher).to_not be_valid |
16 | 16 | ||
17 | watcher.user = Fabricate(:user) | 17 | watcher.user = Fabricate(:user) |
18 | watcher.watcher_type = 'user' | 18 | watcher.watcher_type = 'user' |
19 | - watcher.should be_valid | 19 | + expect(watcher).to be_valid |
20 | end | 20 | end |
21 | end | 21 | end |
22 | 22 | ||
@@ -24,12 +24,12 @@ describe Watcher do | @@ -24,12 +24,12 @@ describe Watcher do | ||
24 | it "returns the user's email address if there is a user" do | 24 | it "returns the user's email address if there is a user" do |
25 | user = Fabricate(:user, :email => 'foo@bar.com') | 25 | user = Fabricate(:user, :email => 'foo@bar.com') |
26 | watcher = Fabricate(:user_watcher, :user => user) | 26 | watcher = Fabricate(:user_watcher, :user => user) |
27 | - watcher.address.should == 'foo@bar.com' | 27 | + expect(watcher.address).to eq 'foo@bar.com' |
28 | end | 28 | end |
29 | 29 | ||
30 | it "returns the email if there is no user" do | 30 | it "returns the email if there is no user" do |
31 | watcher = Fabricate(:watcher, :email => 'widgets@acme.com') | 31 | watcher = Fabricate(:watcher, :email => 'widgets@acme.com') |
32 | - watcher.address.should == 'widgets@acme.com' | 32 | + expect(watcher.address).to eq 'widgets@acme.com' |
33 | end | 33 | end |
34 | end | 34 | end |
35 | 35 |
spec/views/apps/edit.html.haml_spec.rb
@@ -14,7 +14,7 @@ describe "apps/edit.html.haml" do | @@ -14,7 +14,7 @@ describe "apps/edit.html.haml" do | ||
14 | 14 | ||
15 | it "should confirm the 'destroy' link" do | 15 | it "should confirm the 'destroy' link" do |
16 | render | 16 | render |
17 | - action_bar.should have_selector('a.button[data-confirm="%s"]' % I18n.t('apps.confirm_delete')) | 17 | + expect(action_bar).to have_selector('a.button[data-confirm="%s"]' % I18n.t('apps.confirm_delete')) |
18 | end | 18 | end |
19 | 19 | ||
20 | end | 20 | end |
@@ -28,7 +28,7 @@ describe "apps/edit.html.haml" do | @@ -28,7 +28,7 @@ describe "apps/edit.html.haml" do | ||
28 | 28 | ||
29 | it 'see the error' do | 29 | it 'see the error' do |
30 | render | 30 | render |
31 | - rendered.should match(/You must specify your/) | 31 | + expect(rendered).to match(/You must specify your/) |
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 |
spec/views/apps/index.html.haml_spec.rb
@@ -10,7 +10,7 @@ describe "apps/index.html.haml" do | @@ -10,7 +10,7 @@ describe "apps/index.html.haml" do | ||
10 | describe "deploy column" do | 10 | describe "deploy column" do |
11 | it "should show the first 7 characters of the revision in parentheses" do | 11 | it "should show the first 7 characters of the revision in parentheses" do |
12 | render | 12 | render |
13 | - rendered.should match(/\(1234567\)/) | 13 | + expect(rendered).to match(/\(1234567\)/) |
14 | end | 14 | end |
15 | end | 15 | end |
16 | end | 16 | end |
spec/views/apps/new.html.haml_spec.rb
@@ -15,7 +15,7 @@ describe "apps/new.html.haml" do | @@ -15,7 +15,7 @@ describe "apps/new.html.haml" do | ||
15 | it "should confirm the 'cancel' link" do | 15 | it "should confirm the 'cancel' link" do |
16 | render | 16 | render |
17 | 17 | ||
18 | - action_bar.should have_selector('a.button', :text => 'cancel') | 18 | + expect(action_bar).to have_selector('a.button', :text => 'cancel') |
19 | end | 19 | end |
20 | 20 | ||
21 | end | 21 | end |
@@ -29,7 +29,7 @@ describe "apps/new.html.haml" do | @@ -29,7 +29,7 @@ describe "apps/new.html.haml" do | ||
29 | 29 | ||
30 | it 'see the error' do | 30 | it 'see the error' do |
31 | render | 31 | render |
32 | - rendered.should match(/You must specify your/) | 32 | + expect(rendered).to match(/You must specify your/) |
33 | end | 33 | end |
34 | end | 34 | end |
35 | 35 |
spec/views/apps/show.html.haml_spec.rb
@@ -20,7 +20,7 @@ describe "apps/show.html.haml" do | @@ -20,7 +20,7 @@ describe "apps/show.html.haml" do | ||
20 | it "should confirm the 'cancel' link" do | 20 | it "should confirm the 'cancel' link" do |
21 | render | 21 | render |
22 | 22 | ||
23 | - action_bar.should have_selector('a.button', :text => 'all errs') | 23 | + expect(action_bar).to have_selector('a.button', :text => 'all errs') |
24 | end | 24 | end |
25 | 25 | ||
26 | end | 26 | end |
@@ -28,7 +28,7 @@ describe "apps/show.html.haml" do | @@ -28,7 +28,7 @@ describe "apps/show.html.haml" do | ||
28 | context "without errs" do | 28 | context "without errs" do |
29 | it 'see no errs' do | 29 | it 'see no errs' do |
30 | render | 30 | render |
31 | - rendered.should match(/No errs have been/) | 31 | + expect(rendered).to match(/No errs have been/) |
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 |
spec/views/notices/_summary.html.haml_spec.rb
@@ -6,7 +6,7 @@ describe "notices/_summary.html.haml" do | @@ -6,7 +6,7 @@ describe "notices/_summary.html.haml" do | ||
6 | it "renders application framework" do | 6 | it "renders application framework" do |
7 | render "notices/summary", :notice => notice, :problem => notice.problem | 7 | render "notices/summary", :notice => notice, :problem => notice.problem |
8 | 8 | ||
9 | - rendered.should have_content('Rails 3.2.11') | 9 | + expect(rendered).to have_content('Rails 3.2.11') |
10 | end | 10 | end |
11 | end | 11 | end |
12 | 12 |
spec/views/notices/_user_attributes.html.haml_spec.rb
@@ -11,7 +11,7 @@ describe "notices/_user_attributes.html.haml" do | @@ -11,7 +11,7 @@ describe "notices/_user_attributes.html.haml" do | ||
11 | assign :app, notice.err.app | 11 | assign :app, notice.err.app |
12 | 12 | ||
13 | render "notices/user_attributes", :user => notice.user_attributes | 13 | render "notices/user_attributes", :user => notice.user_attributes |
14 | - rendered.should have_link('http://example.com') | 14 | + expect(rendered).to have_link('http://example.com') |
15 | end | 15 | end |
16 | end | 16 | end |
17 | end | 17 | end |
spec/views/problems/index.atom.builder_spec.rb
@@ -8,7 +8,7 @@ describe "problems/index.atom.builder" do | @@ -8,7 +8,7 @@ describe "problems/index.atom.builder" do | ||
8 | :message => 'foo', | 8 | :message => 'foo', |
9 | :new_record => false, :app => app), Problem.new(:new_record => false, :app => app)]) | 9 | :new_record => false, :app => app), Problem.new(:new_record => false, :app => app)]) |
10 | render | 10 | render |
11 | - rendered.should match('foo') | 11 | + expect(rendered).to match('foo') |
12 | end | 12 | end |
13 | 13 | ||
14 | end | 14 | end |
spec/views/problems/index.html.haml_spec.rb
@@ -17,7 +17,7 @@ describe "problems/index.html.haml" do | @@ -17,7 +17,7 @@ describe "problems/index.html.haml" do | ||
17 | 17 | ||
18 | it 'should works' do | 18 | it 'should works' do |
19 | render | 19 | render |
20 | - rendered.should have_selector('div#problem_table.problem_table') | 20 | + expect(rendered).to have_selector('div#problem_table.problem_table') |
21 | end | 21 | end |
22 | end | 22 | end |
23 | 23 |
spec/views/problems/show.html.haml_spec.rb
@@ -28,26 +28,26 @@ describe "problems/show.html.haml" do | @@ -28,26 +28,26 @@ describe "problems/show.html.haml" do | ||
28 | 28 | ||
29 | it "should confirm the 'resolve' link by default" do | 29 | it "should confirm the 'resolve' link by default" do |
30 | render | 30 | render |
31 | - action_bar.should have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) | 31 | + expect(action_bar).to have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) |
32 | end | 32 | end |
33 | 33 | ||
34 | it "should confirm the 'resolve' link if configuration is unset" do | 34 | it "should confirm the 'resolve' link if configuration is unset" do |
35 | Errbit::Config.stub(:confirm_err_actions).and_return(nil) | 35 | Errbit::Config.stub(:confirm_err_actions).and_return(nil) |
36 | render | 36 | render |
37 | - action_bar.should have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) | 37 | + expect(action_bar).to have_selector('a.resolve[data-confirm="%s"]' % I18n.t('problems.confirm.resolve_one')) |
38 | end | 38 | end |
39 | 39 | ||
40 | it "should not confirm the 'resolve' link if configured not to" do | 40 | it "should not confirm the 'resolve' link if configured not to" do |
41 | Errbit::Config.stub(:confirm_err_actions).and_return(false) | 41 | Errbit::Config.stub(:confirm_err_actions).and_return(false) |
42 | render | 42 | render |
43 | - action_bar.should have_selector('a.resolve[data-confirm="null"]') | 43 | + expect(action_bar).to have_selector('a.resolve[data-confirm="null"]') |
44 | end | 44 | end |
45 | 45 | ||
46 | it "should link 'up' to HTTP_REFERER if is set" do | 46 | it "should link 'up' to HTTP_REFERER if is set" do |
47 | url = 'http://localhost:3000/problems' | 47 | url = 'http://localhost:3000/problems' |
48 | controller.request.env['HTTP_REFERER'] = url | 48 | controller.request.env['HTTP_REFERER'] = url |
49 | render | 49 | render |
50 | - action_bar.should have_selector("span a.up[href='#{url}']", :text => 'up') | 50 | + expect(action_bar).to have_selector("span a.up[href='#{url}']", :text => 'up') |
51 | end | 51 | end |
52 | 52 | ||
53 | it "should link 'up' to app_problems_path if HTTP_REFERER isn't set'" do | 53 | it "should link 'up' to app_problems_path if HTTP_REFERER isn't set'" do |
@@ -57,7 +57,7 @@ describe "problems/show.html.haml" do | @@ -57,7 +57,7 @@ describe "problems/show.html.haml" do | ||
57 | view.stub(:app).and_return(problem.app) | 57 | view.stub(:app).and_return(problem.app) |
58 | render | 58 | render |
59 | 59 | ||
60 | - action_bar.should have_selector("span a.up[href='#{app_problems_path(problem.app)}']", :text => 'up') | 60 | + expect(action_bar).to have_selector("span a.up[href='#{app_problems_path(problem.app)}']", :text => 'up') |
61 | end | 61 | end |
62 | 62 | ||
63 | context 'create issue links' do | 63 | context 'create issue links' do |
@@ -70,7 +70,7 @@ describe "problems/show.html.haml" do | @@ -70,7 +70,7 @@ describe "problems/show.html.haml" do | ||
70 | view.stub(:app).and_return(problem.app) | 70 | view.stub(:app).and_return(problem.app) |
71 | render | 71 | render |
72 | 72 | ||
73 | - action_bar.should have_selector("span a.github_create.create-issue", :text => 'create issue') | 73 | + expect(action_bar).to have_selector("span a.github_create.create-issue", :text => 'create issue') |
74 | end | 74 | end |
75 | 75 | ||
76 | it 'should allow creating issue for github if application has a github tracker' do | 76 | it 'should allow creating issue for github if application has a github tracker' do |
@@ -80,7 +80,7 @@ describe "problems/show.html.haml" do | @@ -80,7 +80,7 @@ describe "problems/show.html.haml" do | ||
80 | view.stub(:app).and_return(problem.app) | 80 | view.stub(:app).and_return(problem.app) |
81 | render | 81 | render |
82 | 82 | ||
83 | - action_bar.should have_selector("span a.github_create.create-issue", :text => 'create issue') | 83 | + expect(action_bar).to have_selector("span a.github_create.create-issue", :text => 'create issue') |
84 | end | 84 | end |
85 | 85 | ||
86 | context "without issue tracker associate on app" do | 86 | context "without issue tracker associate on app" do |
@@ -139,9 +139,9 @@ describe "problems/show.html.haml" do | @@ -139,9 +139,9 @@ describe "problems/show.html.haml" do | ||
139 | view.stub(:app).and_return(problem.app) | 139 | view.stub(:app).and_return(problem.app) |
140 | render | 140 | render |
141 | 141 | ||
142 | - view.content_for(:comments).should include('Test comment') | ||
143 | - view.content_for(:comments).should have_selector('img[src^="http://www.gravatar.com/avatar"]') | ||
144 | - view.content_for(:comments).should include('Add a comment') | 142 | + expect(view.content_for(:comments)).to include('Test comment') |
143 | + expect(view.content_for(:comments)).to have_selector('img[src^="http://www.gravatar.com/avatar"]') | ||
144 | + expect(view.content_for(:comments)).to include('Add a comment') | ||
145 | end | 145 | end |
146 | 146 | ||
147 | context "with issue tracker" do | 147 | context "with issue tracker" do |
@@ -149,7 +149,7 @@ describe "problems/show.html.haml" do | @@ -149,7 +149,7 @@ describe "problems/show.html.haml" do | ||
149 | problem = Fabricate(:problem) | 149 | problem = Fabricate(:problem) |
150 | with_issue_tracker(PivotalLabsTracker, problem) | 150 | with_issue_tracker(PivotalLabsTracker, problem) |
151 | render | 151 | render |
152 | - view.view_flow.get(:comments).should be_blank | 152 | + expect(view.view_flow.get(:comments)).to be_blank |
153 | end | 153 | end |
154 | 154 | ||
155 | it 'should display existing comments' do | 155 | it 'should display existing comments' do |
@@ -158,9 +158,9 @@ describe "problems/show.html.haml" do | @@ -158,9 +158,9 @@ describe "problems/show.html.haml" do | ||
158 | with_issue_tracker(PivotalLabsTracker, problem) | 158 | with_issue_tracker(PivotalLabsTracker, problem) |
159 | render | 159 | render |
160 | 160 | ||
161 | - view.content_for(:comments).should include('Test comment') | ||
162 | - view.content_for(:comments).should have_selector('img[src^="http://www.gravatar.com/avatar"]') | ||
163 | - view.content_for(:comments).should_not include('Add a comment') | 161 | + expect(view.content_for(:comments)).to include('Test comment') |
162 | + expect(view.content_for(:comments)).to have_selector('img[src^="http://www.gravatar.com/avatar"]') | ||
163 | + expect(view.content_for(:comments)).to_not include('Add a comment') | ||
164 | end | 164 | end |
165 | end | 165 | end |
166 | end | 166 | end |
spec/views/users/show.html.haml_spec.rb
@@ -16,14 +16,14 @@ describe 'users/show.html.haml' do | @@ -16,14 +16,14 @@ describe 'users/show.html.haml' do | ||
16 | it 'shows github login' do | 16 | it 'shows github login' do |
17 | user.github_login = 'test_user' | 17 | user.github_login = 'test_user' |
18 | render | 18 | render |
19 | - rendered.should match(/GitHub/) | ||
20 | - rendered.should match(/test_user/) | 19 | + expect(rendered).to match(/GitHub/) |
20 | + expect(rendered).to match(/test_user/) | ||
21 | end | 21 | end |
22 | 22 | ||
23 | it 'does not show github if blank' do | 23 | it 'does not show github if blank' do |
24 | user.github_login = ' ' | 24 | user.github_login = ' ' |
25 | render | 25 | render |
26 | - rendered.should_not match(/GitHub/) | 26 | + expect(rendered).to_not match(/GitHub/) |
27 | end | 27 | end |
28 | end | 28 | end |
29 | 29 | ||
@@ -31,8 +31,8 @@ describe 'users/show.html.haml' do | @@ -31,8 +31,8 @@ describe 'users/show.html.haml' do | ||
31 | context 'viewing another user page' do | 31 | context 'viewing another user page' do |
32 | it "doesn't show and github linking buttons if user is not current user" do | 32 | it "doesn't show and github linking buttons if user is not current user" do |
33 | render | 33 | render |
34 | - view.content_for(:action_bar).should_not include('Link GitHub account') | ||
35 | - view.content_for(:action_bar).should_not include('Unlink GitHub account') | 34 | + expect(view.content_for(:action_bar)).to_not include('Link GitHub account') |
35 | + expect(view.content_for(:action_bar)).to_not include('Unlink GitHub account') | ||
36 | end | 36 | end |
37 | end | 37 | end |
38 | 38 | ||
@@ -43,7 +43,7 @@ describe 'users/show.html.haml' do | @@ -43,7 +43,7 @@ describe 'users/show.html.haml' do | ||
43 | 43 | ||
44 | it 'shows link github button when no login or token' do | 44 | it 'shows link github button when no login or token' do |
45 | render | 45 | render |
46 | - view.content_for(:action_bar).should include('Link GitHub account') | 46 | + expect(view.content_for(:action_bar)).to include('Link GitHub account') |
47 | end | 47 | end |
48 | 48 | ||
49 | it 'shows unlink github button when login and token' do | 49 | it 'shows unlink github button when login and token' do |
@@ -51,12 +51,12 @@ describe 'users/show.html.haml' do | @@ -51,12 +51,12 @@ describe 'users/show.html.haml' do | ||
51 | user.github_oauth_token = 'abcdef' | 51 | user.github_oauth_token = 'abcdef' |
52 | 52 | ||
53 | render | 53 | render |
54 | - view.content_for(:action_bar).should include('Unlink GitHub account') | 54 | + expect(view.content_for(:action_bar)).to include('Unlink GitHub account') |
55 | end | 55 | end |
56 | 56 | ||
57 | it "should confirm the 'resolve' link by default" do | 57 | it "should confirm the 'resolve' link by default" do |
58 | render | 58 | render |
59 | - view.content_for(:action_bar).should have_selector('a.delete[data-confirm="%s"]' % I18n.t('.users.confirm_delete')) | 59 | + expect(view.content_for(:action_bar)).to have_selector('a.delete[data-confirm="%s"]' % I18n.t('.users.confirm_delete')) |
60 | end | 60 | end |
61 | 61 | ||
62 | end | 62 | end |