Commit 32901bc26a3769fd2f0b466c9d539c720284547e

Authored by Cyril Mougel
1 parent 1e32567f
Exists in master and in 1 other branch production

fix all warning deprecation from rspec 2.14

spec/controllers/api/v1/notices_controller_spec.rb
@@ -17,7 +17,7 @@ describe Api::V1::NoticesController do @@ -17,7 +17,7 @@ describe Api::V1::NoticesController do
17 17
18 it "should return JSON if JSON is requested" do 18 it "should return JSON if JSON is requested" do
19 get :index, :auth_token => @user.authentication_token, :format => "json" 19 get :index, :auth_token => @user.authentication_token, :format => "json"
20 - lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) 20 + expect { JSON.load(response.body) }.not_to raise_error() #JSON::ParserError)
21 end 21 end
22 22
23 it "should return XML if XML is requested" do 23 it "should return XML if XML is requested" do
@@ -27,7 +27,7 @@ describe Api::V1::NoticesController do @@ -27,7 +27,7 @@ describe Api::V1::NoticesController do
27 27
28 it "should return JSON by default" do 28 it "should return JSON by default" do
29 get :index, :auth_token => @user.authentication_token 29 get :index, :auth_token => @user.authentication_token
30 - lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) 30 + expect { JSON.load(response.body) }.not_to raise_error() #JSON::ParserError)
31 end 31 end
32 32
33 describe "given a date range" do 33 describe "given a date range" do
spec/controllers/api/v1/problems_controller_spec.rb
@@ -19,7 +19,7 @@ describe Api::V1::ProblemsController do @@ -19,7 +19,7 @@ describe Api::V1::ProblemsController do
19 19
20 it "should return JSON if JSON is requested" do 20 it "should return JSON if JSON is requested" do
21 get :index, :auth_token => @user.authentication_token, :format => "json" 21 get :index, :auth_token => @user.authentication_token, :format => "json"
22 - lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) 22 + expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError)
23 end 23 end
24 24
25 it "should return XML if XML is requested" do 25 it "should return XML if XML is requested" do
@@ -29,7 +29,7 @@ describe Api::V1::ProblemsController do @@ -29,7 +29,7 @@ describe Api::V1::ProblemsController do
29 29
30 it "should return JSON by default" do 30 it "should return JSON by default" do
31 get :index, :auth_token => @user.authentication_token 31 get :index, :auth_token => @user.authentication_token
32 - lambda { JSON.load(response.body) }.should_not raise_error(JSON::ParserError) 32 + expect { JSON.load(response.body) }.not_to raise_error()#JSON::ParserError)
33 end 33 end
34 34
35 35
spec/controllers/notices_controller_spec.rb
@@ -6,7 +6,7 @@ describe NoticesController do @@ -6,7 +6,7 @@ describe NoticesController do
6 let(:notice) { Fabricate(:notice) } 6 let(:notice) { Fabricate(:notice) }
7 let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read } 7 let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read }
8 let(:app) { Fabricate(:app) } 8 let(:app) { Fabricate(:app) }
9 - let(:error_report) { mock(:valid? => true, :generate_notice! => true, :notice => notice) } 9 + let(:error_report) { double(:valid? => true, :generate_notice! => true, :notice => notice) }
10 10
11 context 'notices API' do 11 context 'notices API' do
12 context "with all params" do 12 context "with all params" do
@@ -46,7 +46,7 @@ describe NoticesController do @@ -46,7 +46,7 @@ describe NoticesController do
46 response.body.should match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) 46 response.body.should 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) { mock(:valid? => false) } 49 + let(:error_report) { double(:valid? => false) }
50 it 'return 422' do 50 it 'return 422' do
51 post :create, :format => :xml, :data => xml 51 post :create, :format => :xml, :data => xml
52 expect(response.status).to eq 422 52 expect(response.status).to eq 422
spec/controllers/problems_controller_spec.rb
@@ -103,7 +103,7 @@ describe ProblemsController do @@ -103,7 +103,7 @@ describe ProblemsController do
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 Problem.should_receive(:ordered_by).and_return(
106 - mock('proxy', :page => mock('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 controller.problems.should == problems
spec/controllers/users/omniauth_callbacks_controller_spec.rb
@@ -12,7 +12,7 @@ describe Users::OmniauthCallbacksController do @@ -12,7 +12,7 @@ describe Users::OmniauthCallbacksController do
12 :credentials => { :token => token } 12 :credentials => { :token => token }
13 ) 13 )
14 } 14 }
15 - @controller.stub!(:env).and_return(env) 15 + @controller.stub(:env).and_return(env)
16 end 16 end
17 17
18 context 'Linking a GitHub account to a signed in user' do 18 context 'Linking a GitHub account to a signed in user' do
spec/controllers/users_controller_spec.rb
@@ -207,7 +207,7 @@ describe UsersController do @@ -207,7 +207,7 @@ describe UsersController do
207 context "DELETE /users/:id" do 207 context "DELETE /users/:id" do
208 208
209 context "with a destroy success" do 209 context "with a destroy success" do
210 - let(:user_destroy) { mock(: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 UserDestroy.should_receive(:new).with(user).and_return(user_destroy)
spec/interactors/problem_destroy_spec.rb
@@ -8,8 +8,8 @@ describe ProblemDestroy do @@ -8,8 +8,8 @@ describe ProblemDestroy do
8 context "in unit way" do 8 context "in unit way" do
9 let(:problem) { 9 let(:problem) {
10 problem = Problem.new 10 problem = Problem.new
11 - problem.stub(:errs).and_return(mock(:criteria, :only => [err_1, err_2]))  
12 - problem.stub(:comments).and_return(mock(:criteria, :only => [comment_1, comment_2])) 11 + problem.stub(:errs).and_return(double(:criteria, :only => [err_1, err_2]))
  12 + problem.stub(:comments).and_return(double(:criteria, :only => [comment_1, comment_2]))
13 problem.stub(:delete) 13 problem.stub(:delete)
14 problem 14 problem
15 } 15 }
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(mock(:update => true)) 45 + ProblemUpdaterCache.should_receive(:new).with(problem).and_return(double(:update => true))
46 problem_merge.merge 46 problem_merge.merge
47 end 47 end
48 48
spec/models/backtrace_spec.rb
@@ -22,8 +22,8 @@ describe Backtrace do @@ -22,8 +22,8 @@ describe Backtrace do
22 22
23 describe "find_or_create" do 23 describe "find_or_create" do
24 subject { described_class.find_or_create(attributes) } 24 subject { described_class.find_or_create(attributes) }
25 - let(:attributes) { mock :attributes }  
26 - let(:backtrace) { mock :backtrace } 25 + let(:attributes) { double :attributes }
  26 + let(:backtrace) { double :backtrace }
27 27
28 before { described_class.stub(:new => backtrace) } 28 before { described_class.stub(:new => backtrace) }
29 29
@@ -37,7 +37,7 @@ describe Backtrace do @@ -37,7 +37,7 @@ describe Backtrace do
37 end 37 end
38 38
39 context "similar backtrace exist" do 39 context "similar backtrace exist" do
40 - let(:similar_backtrace) { mock :similar_backtrace } 40 + let(:similar_backtrace) { double :similar_backtrace }
41 before { backtrace.stub(:similar => similar_backtrace) } 41 before { backtrace.stub(:similar => similar_backtrace) }
42 42
43 it { should == similar_backtrace } 43 it { should == similar_backtrace }
spec/models/comment_observer_spec.rb
@@ -10,7 +10,7 @@ describe CommentObserver do @@ -10,7 +10,7 @@ describe CommentObserver do
10 it 'should send an email notification' do 10 it 'should send an email notification' do
11 Mailer.should_receive(:comment_notification). 11 Mailer.should_receive(:comment_notification).
12 with(comment). 12 with(comment).
13 - and_return(mock('email', :deliver => true)) 13 + and_return(double('email', :deliver => true))
14 comment.save 14 comment.save
15 end 15 end
16 end 16 end
spec/models/deploy_observer_spec.rb
@@ -5,7 +5,7 @@ describe DeployObserver do @@ -5,7 +5,7 @@ describe DeployObserver 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 Mailer.should_receive(:deploy_notification).
8 - and_return(mock('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
11 end 11 end
spec/models/issue_trackers/fogbugz_tracker_spec.rb
@@ -9,7 +9,7 @@ describe IssueTrackers::FogbugzTracker do @@ -9,7 +9,7 @@ describe IssueTrackers::FogbugzTracker do
9 number = 123 9 number = 123
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 = mock 12 + http_mock = double
13 http_mock.should_receive(:new).and_return(http_mock) 13 http_mock.should_receive(:new).and_return(http_mock)
14 http_mock.should_receive(:request).twice.and_return(response) 14 http_mock.should_receive(:request).twice.and_return(response)
15 Fogbugz.adapter[:http] = http_mock 15 Fogbugz.adapter[:http] = http_mock
spec/models/notice_observer_spec.rb
@@ -18,7 +18,7 @@ describe NoticeObserver do @@ -18,7 +18,7 @@ describe NoticeObserver do
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 Mailer.should_receive(:err_notification).
21 - and_return(mock('email', :deliver => true)) 21 + and_return(double('email', :deliver => true))
22 Fabricate(:notice, :err => @err) 22 Fabricate(:notice, :err => @err)
23 end 23 end
24 end 24 end
@@ -38,7 +38,7 @@ describe NoticeObserver do @@ -38,7 +38,7 @@ describe NoticeObserver do
38 it "should send email notification after 1 notice since an error has been resolved" do 38 it "should send email notification after 1 notice since an error has been resolved" do
39 @err.problem.resolve! 39 @err.problem.resolve!
40 Mailer.should_receive(:err_notification). 40 Mailer.should_receive(:err_notification).
41 - and_return(mock('email', :deliver => true)) 41 + and_return(double('email', :deliver => true))
42 Fabricate(:notice, :err => @err) 42 Fabricate(:notice, :err => @err)
43 end 43 end
44 end 44 end
@@ -103,7 +103,7 @@ describe NoticeObserver do @@ -103,7 +103,7 @@ describe NoticeObserver do
103 Fabricate(:notice, :err => err) 103 Fabricate(:notice, :err => err)
104 end 104 end
105 end 105 end
106 - 106 +
107 describe "should send a notification at desired intervals" do 107 describe "should send a notification at desired intervals" do
108 let(:app) { Fabricate(:app, :email_at_notices => [1], :notification_service => Fabricate(:campfire_notification_service, :notify_at_notices => [1,2]))} 108 let(:app) { Fabricate(:app, :email_at_notices => [1], :notification_service => Fabricate(:campfire_notification_service, :notify_at_notices => [1,2]))}
109 let(:backtrace) { Fabricate(:backtrace) } 109 let(:backtrace) { Fabricate(:backtrace) }
spec/models/notification_service/campfire_service_spec.rb
@@ -8,7 +8,7 @@ describe NotificationService::CampfireService do @@ -8,7 +8,7 @@ describe NotificationService::CampfireService do
8 problem = notice.problem 8 problem = notice.problem
9 9
10 #campy stubbing 10 #campy stubbing
11 - campy = mock('CampfireService') 11 + campy = double('CampfireService')
12 Campy::Room.stub(:new).and_return(campy) 12 Campy::Room.stub(:new).and_return(campy)
13 campy.stub(:speak) { true } 13 campy.stub(:speak) { true }
14 14
spec/models/notification_service/gtalk_service_spec.rb
@@ -9,7 +9,7 @@ describe NotificationService::GtalkService do @@ -9,7 +9,7 @@ describe NotificationService::GtalkService do
9 problem = notice.problem 9 problem = notice.problem
10 10
11 #gtalk stubbing 11 #gtalk stubbing
12 - gtalk = mock('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) 15 Jabber::JID.should_receive(:new).with(notification_service.subdomain).and_return(jid)
@@ -19,13 +19,13 @@ describe NotificationService::GtalkService do @@ -19,13 +19,13 @@ describe NotificationService::GtalkService do
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) 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) 24 Jabber::Message.should_receive(:new).with(notification_service.room_id, message_value).and_return(message)
25 - 25 +
26 Jabber::MUC::SimpleMUCClient.should_receive(:new).and_return(gtalk) 26 Jabber::MUC::SimpleMUCClient.should_receive(:new).and_return(gtalk)
27 gtalk.should_receive(:join).with(notification_service.room_id + "/errbit") 27 gtalk.should_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 gtalk.should_receive(:send).exactly(2).times.with(message)
31 31
@@ -43,7 +43,7 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} @@ -43,7 +43,7 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s}
43 #{@notification_service.notification_description @problem}""" 43 #{@notification_service.notification_description @problem}"""
44 44
45 # gtalk stubbing 45 # gtalk stubbing
46 - @gtalk = mock('GtalkService') 46 + @gtalk = double('GtalkService')
47 @gtalk.should_receive(:connect) 47 @gtalk.should_receive(:connect)
48 @gtalk.should_receive(:auth) 48 @gtalk.should_receive(:auth)
49 jid = double("jid") 49 jid = double("jid")
@@ -86,7 +86,7 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} @@ -86,7 +86,7 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s}
86 @notification_service.room_id = "" 86 @notification_service.room_id = ""
87 @notification_service.create_notification(@problem) 87 @notification_service.create_notification(@problem)
88 end 88 end
89 - 89 +
90 end 90 end
91 91
92 it "it should send a notification to room only" do 92 it "it should send a notification to room only" do
@@ -97,7 +97,7 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} @@ -97,7 +97,7 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s}
97 problem = notice.problem 97 problem = notice.problem
98 98
99 #gtalk stubbing 99 #gtalk stubbing
100 - gtalk = mock('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) 103 Jabber::JID.should_receive(:new).with(notification_service.subdomain).and_return(jid)
@@ -107,11 +107,11 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} @@ -107,11 +107,11 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s}
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 Jabber::Message.should_receive(:new).with(notification_service.room_id, message_value).and_return(message)
112 - 112 +
113 Jabber::MUC::SimpleMUCClient.should_receive(:new).and_return(gtalk) 113 Jabber::MUC::SimpleMUCClient.should_receive(:new).and_return(gtalk)
114 - gtalk.should_receive(:join).with(notification_service.room_id + "/errbit") 114 + gtalk.should_receive(:join).with(notification_service.room_id + "/errbit")
115 115
116 notification_service.user_id = "" 116 notification_service.user_id = ""
117 117
spec/models/notification_service/hoiio_service_spec.rb
@@ -8,7 +8,7 @@ describe NotificationService::HoiioService do @@ -8,7 +8,7 @@ describe NotificationService::HoiioService do
8 problem = notice.problem 8 problem = notice.problem
9 9
10 # hoi stubbing 10 # hoi stubbing
11 - sms = mock('HoiioService') 11 + sms = double('HoiioService')
12 Hoi::SMS.stub(:new).and_return(sms) 12 Hoi::SMS.stub(:new).and_return(sms)
13 sms.stub(:send) { true } 13 sms.stub(:send) { true }
14 14
spec/models/notification_service/pushover_service_spec.rb
@@ -8,7 +8,7 @@ describe NotificationService::PushoverService do @@ -8,7 +8,7 @@ describe NotificationService::PushoverService do
8 problem = notice.problem 8 problem = notice.problem
9 9
10 # hoi stubbing 10 # hoi stubbing
11 - notification = mock('PushoverService') 11 + notification = double('PushoverService')
12 Rushover::Client.stub(:new).and_return(notification) 12 Rushover::Client.stub(:new).and_return(notification)
13 notification.stub(:notify) { true } 13 notification.stub(:notify) { true }
14 14
spec/models/problem_spec.rb
@@ -123,12 +123,12 @@ describe Problem do @@ -123,12 +123,12 @@ describe Problem do
123 it "should throw an err if it's not successful" do 123 it "should throw an err if it's not successful" do
124 problem = Fabricate(:problem) 124 problem = Fabricate(:problem)
125 problem.should_not be_resolved 125 problem.should_not be_resolved
126 - problem.stub!(:valid?).and_return(false) 126 + problem.stub(:valid?).and_return(false)
127 ## update_attributes not test #valid? but #errors.any? 127 ## update_attributes not test #valid? but #errors.any?
128 # https://github.com/mongoid/mongoid/blob/master/lib/mongoid/persistence.rb#L137 128 # https://github.com/mongoid/mongoid/blob/master/lib/mongoid/persistence.rb#L137
129 er = ActiveModel::Errors.new(problem) 129 er = ActiveModel::Errors.new(problem)
130 er.add_on_blank(:resolved) 130 er.add_on_blank(:resolved)
131 - problem.stub!(:errors).and_return(er) 131 + problem.stub(:errors).and_return(er)
132 problem.should_not be_valid 132 problem.should_not be_valid
133 lambda { 133 lambda {
134 problem.resolve! 134 problem.resolve!