Commit 32901bc26a3769fd2f0b466c9d539c720284547e
1 parent
1e32567f
Exists in
master
and in
1 other branch
fix all warning deprecation from rspec 2.14
Showing
18 changed files
with
36 additions
and
36 deletions
Show diff stats
spec/controllers/api/v1/notices_controller_spec.rb
... | ... | @@ -17,7 +17,7 @@ describe Api::V1::NoticesController do |
17 | 17 | |
18 | 18 | it "should return JSON if JSON is requested" do |
19 | 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 | 21 | end |
22 | 22 | |
23 | 23 | it "should return XML if XML is requested" do |
... | ... | @@ -27,7 +27,7 @@ describe Api::V1::NoticesController do |
27 | 27 | |
28 | 28 | it "should return JSON by default" do |
29 | 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 | 31 | end |
32 | 32 | |
33 | 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 | 19 | |
20 | 20 | it "should return JSON if JSON is requested" do |
21 | 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 | 23 | end |
24 | 24 | |
25 | 25 | it "should return XML if XML is requested" do |
... | ... | @@ -29,7 +29,7 @@ describe Api::V1::ProblemsController do |
29 | 29 | |
30 | 30 | it "should return JSON by default" do |
31 | 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 | 33 | end |
34 | 34 | |
35 | 35 | ... | ... |
spec/controllers/notices_controller_spec.rb
... | ... | @@ -6,7 +6,7 @@ describe NoticesController do |
6 | 6 | let(:notice) { Fabricate(:notice) } |
7 | 7 | let(:xml) { Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read } |
8 | 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 | 11 | context 'notices API' do |
12 | 12 | context "with all params" do |
... | ... | @@ -46,7 +46,7 @@ describe NoticesController do |
46 | 46 | response.body.should match(%r{<url[^>]*>(.+)#{locate_path(notice.id)}</url>}) |
47 | 47 | end |
48 | 48 | context "with an invalid API_KEY" do |
49 | - let(:error_report) { mock(:valid? => false) } | |
49 | + let(:error_report) { double(:valid? => false) } | |
50 | 50 | it 'return 422' do |
51 | 51 | post :create, :format => :xml, :data => xml |
52 | 52 | expect(response.status).to eq 422 | ... | ... |
spec/controllers/problems_controller_spec.rb
... | ... | @@ -103,7 +103,7 @@ describe ProblemsController do |
103 | 103 | 3.times { problems << Fabricate(:err).problem } |
104 | 104 | 3.times { problems << Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem } |
105 | 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 | 108 | get :index, :all_errs => true |
109 | 109 | controller.problems.should == problems | ... | ... |
spec/controllers/users/omniauth_callbacks_controller_spec.rb
... | ... | @@ -12,7 +12,7 @@ describe Users::OmniauthCallbacksController do |
12 | 12 | :credentials => { :token => token } |
13 | 13 | ) |
14 | 14 | } |
15 | - @controller.stub!(:env).and_return(env) | |
15 | + @controller.stub(:env).and_return(env) | |
16 | 16 | end |
17 | 17 | |
18 | 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 | 207 | context "DELETE /users/:id" do |
208 | 208 | |
209 | 209 | context "with a destroy success" do |
210 | - let(:user_destroy) { mock(:destroy => true) } | |
210 | + let(:user_destroy) { double(:destroy => true) } | |
211 | 211 | |
212 | 212 | before { |
213 | 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 | context "in unit way" do |
9 | 9 | let(:problem) { |
10 | 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 | 13 | problem.stub(:delete) |
14 | 14 | problem |
15 | 15 | } | ... | ... |
spec/interactors/problem_merge_spec.rb
... | ... | @@ -42,7 +42,7 @@ describe ProblemMerge do |
42 | 42 | end |
43 | 43 | |
44 | 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 | 46 | problem_merge.merge |
47 | 47 | end |
48 | 48 | ... | ... |
spec/models/backtrace_spec.rb
... | ... | @@ -22,8 +22,8 @@ describe Backtrace do |
22 | 22 | |
23 | 23 | describe "find_or_create" do |
24 | 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 | 28 | before { described_class.stub(:new => backtrace) } |
29 | 29 | |
... | ... | @@ -37,7 +37,7 @@ describe Backtrace do |
37 | 37 | end |
38 | 38 | |
39 | 39 | context "similar backtrace exist" do |
40 | - let(:similar_backtrace) { mock :similar_backtrace } | |
40 | + let(:similar_backtrace) { double :similar_backtrace } | |
41 | 41 | before { backtrace.stub(:similar => similar_backtrace) } |
42 | 42 | |
43 | 43 | it { should == similar_backtrace } | ... | ... |
spec/models/comment_observer_spec.rb
... | ... | @@ -10,7 +10,7 @@ describe CommentObserver do |
10 | 10 | it 'should send an email notification' do |
11 | 11 | Mailer.should_receive(:comment_notification). |
12 | 12 | with(comment). |
13 | - and_return(mock('email', :deliver => true)) | |
13 | + and_return(double('email', :deliver => true)) | |
14 | 14 | comment.save |
15 | 15 | end |
16 | 16 | end | ... | ... |
spec/models/deploy_observer_spec.rb
... | ... | @@ -5,7 +5,7 @@ describe DeployObserver do |
5 | 5 | context 'and the app should notify on deploys' do |
6 | 6 | it 'should send an email notification' do |
7 | 7 | Mailer.should_receive(:deploy_notification). |
8 | - and_return(mock('email', :deliver => true)) | |
8 | + and_return(double('email', :deliver => true)) | |
9 | 9 | Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => true)) |
10 | 10 | end |
11 | 11 | end | ... | ... |
spec/models/issue_trackers/fogbugz_tracker_spec.rb
... | ... | @@ -9,7 +9,7 @@ describe IssueTrackers::FogbugzTracker do |
9 | 9 | number = 123 |
10 | 10 | @issue_link = "https://#{tracker.account}.fogbugz.com/default.asp?#{number}" |
11 | 11 | response = "<response><token>12345</token><case><ixBug>123</ixBug></case></response>" |
12 | - http_mock = mock | |
12 | + http_mock = double | |
13 | 13 | http_mock.should_receive(:new).and_return(http_mock) |
14 | 14 | http_mock.should_receive(:request).twice.and_return(response) |
15 | 15 | Fogbugz.adapter[:http] = http_mock | ... | ... |
spec/models/notice_observer_spec.rb
... | ... | @@ -18,7 +18,7 @@ describe NoticeObserver do |
18 | 18 | it "sends an email notification after #{threshold} notice(s)" do |
19 | 19 | @err.problem.stub(:notices_count).and_return(threshold) |
20 | 20 | Mailer.should_receive(:err_notification). |
21 | - and_return(mock('email', :deliver => true)) | |
21 | + and_return(double('email', :deliver => true)) | |
22 | 22 | Fabricate(:notice, :err => @err) |
23 | 23 | end |
24 | 24 | end |
... | ... | @@ -38,7 +38,7 @@ describe NoticeObserver do |
38 | 38 | it "should send email notification after 1 notice since an error has been resolved" do |
39 | 39 | @err.problem.resolve! |
40 | 40 | Mailer.should_receive(:err_notification). |
41 | - and_return(mock('email', :deliver => true)) | |
41 | + and_return(double('email', :deliver => true)) | |
42 | 42 | Fabricate(:notice, :err => @err) |
43 | 43 | end |
44 | 44 | end |
... | ... | @@ -103,7 +103,7 @@ describe NoticeObserver do |
103 | 103 | Fabricate(:notice, :err => err) |
104 | 104 | end |
105 | 105 | end |
106 | - | |
106 | + | |
107 | 107 | describe "should send a notification at desired intervals" do |
108 | 108 | let(:app) { Fabricate(:app, :email_at_notices => [1], :notification_service => Fabricate(:campfire_notification_service, :notify_at_notices => [1,2]))} |
109 | 109 | let(:backtrace) { Fabricate(:backtrace) } | ... | ... |
spec/models/notification_service/campfire_service_spec.rb
spec/models/notification_service/gtalk_service_spec.rb
... | ... | @@ -9,7 +9,7 @@ describe NotificationService::GtalkService do |
9 | 9 | problem = notice.problem |
10 | 10 | |
11 | 11 | #gtalk stubbing |
12 | - gtalk = mock('GtalkService') | |
12 | + gtalk = double('GtalkService') | |
13 | 13 | jid = double("jid") |
14 | 14 | message = double("message") |
15 | 15 | Jabber::JID.should_receive(:new).with(notification_service.subdomain).and_return(jid) |
... | ... | @@ -19,13 +19,13 @@ describe NotificationService::GtalkService do |
19 | 19 | message_value = """#{problem.app.name.to_s} |
20 | 20 | http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} |
21 | 21 | #{notification_service.notification_description problem}""" |
22 | - | |
22 | + | |
23 | 23 | Jabber::Message.should_receive(:new).with(notification_service.user_id, message_value).and_return(message) |
24 | 24 | Jabber::Message.should_receive(:new).with(notification_service.room_id, message_value).and_return(message) |
25 | - | |
25 | + | |
26 | 26 | Jabber::MUC::SimpleMUCClient.should_receive(:new).and_return(gtalk) |
27 | 27 | gtalk.should_receive(:join).with(notification_service.room_id + "/errbit") |
28 | - | |
28 | + | |
29 | 29 | #assert |
30 | 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 | 43 | #{@notification_service.notification_description @problem}""" |
44 | 44 | |
45 | 45 | # gtalk stubbing |
46 | - @gtalk = mock('GtalkService') | |
46 | + @gtalk = double('GtalkService') | |
47 | 47 | @gtalk.should_receive(:connect) |
48 | 48 | @gtalk.should_receive(:auth) |
49 | 49 | jid = double("jid") |
... | ... | @@ -86,7 +86,7 @@ http://#{Errbit::Config.host}/apps/#{@problem.app.id.to_s} |
86 | 86 | @notification_service.room_id = "" |
87 | 87 | @notification_service.create_notification(@problem) |
88 | 88 | end |
89 | - | |
89 | + | |
90 | 90 | end |
91 | 91 | |
92 | 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 | 97 | problem = notice.problem |
98 | 98 | |
99 | 99 | #gtalk stubbing |
100 | - gtalk = mock('GtalkService') | |
100 | + gtalk = double('GtalkService') | |
101 | 101 | jid = double("jid") |
102 | 102 | message = double("message") |
103 | 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 | 107 | message_value = """#{problem.app.name.to_s} |
108 | 108 | http://#{Errbit::Config.host}/apps/#{problem.app.id.to_s} |
109 | 109 | #{notification_service.notification_description problem}""" |
110 | - | |
110 | + | |
111 | 111 | Jabber::Message.should_receive(:new).with(notification_service.room_id, message_value).and_return(message) |
112 | - | |
112 | + | |
113 | 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 | 116 | notification_service.user_id = "" |
117 | 117 | ... | ... |
spec/models/notification_service/hoiio_service_spec.rb
spec/models/notification_service/pushover_service_spec.rb
... | ... | @@ -8,7 +8,7 @@ describe NotificationService::PushoverService do |
8 | 8 | problem = notice.problem |
9 | 9 | |
10 | 10 | # hoi stubbing |
11 | - notification = mock('PushoverService') | |
11 | + notification = double('PushoverService') | |
12 | 12 | Rushover::Client.stub(:new).and_return(notification) |
13 | 13 | notification.stub(:notify) { true } |
14 | 14 | ... | ... |
spec/models/problem_spec.rb
... | ... | @@ -123,12 +123,12 @@ describe Problem do |
123 | 123 | it "should throw an err if it's not successful" do |
124 | 124 | problem = Fabricate(:problem) |
125 | 125 | problem.should_not be_resolved |
126 | - problem.stub!(:valid?).and_return(false) | |
126 | + problem.stub(:valid?).and_return(false) | |
127 | 127 | ## update_attributes not test #valid? but #errors.any? |
128 | 128 | # https://github.com/mongoid/mongoid/blob/master/lib/mongoid/persistence.rb#L137 |
129 | 129 | er = ActiveModel::Errors.new(problem) |
130 | 130 | er.add_on_blank(:resolved) |
131 | - problem.stub!(:errors).and_return(er) | |
131 | + problem.stub(:errors).and_return(er) | |
132 | 132 | problem.should_not be_valid |
133 | 133 | lambda { |
134 | 134 | problem.resolve! | ... | ... |