From efc4109902c04e49415a880734f776846e940f6f Mon Sep 17 00:00:00 2001 From: David McClure Date: Fri, 7 Nov 2014 06:05:44 -0800 Subject: [PATCH] update specs to remove deprecation warnings --- spec/components/category_list_spec.rb | 2 +- spec/controllers/admin/dashboard_controller_spec.rb | 4 ++-- spec/controllers/users_controller_spec.rb | 10 +++++----- spec/integration/spam_rules_spec.rb | 6 +++--- spec/integration/topic_auto_close_spec.rb | 8 ++++---- spec/models/color_scheme_spec.rb | 4 ++-- spec/models/incoming_links_report_spec.rb | 6 +++--- spec/models/invite_spec.rb | 2 +- spec/models/notification_spec.rb | 2 +- spec/services/post_alerter_spec.rb | 4 ++-- 10 files changed, 24 insertions(+), 24 deletions(-) diff --git a/spec/components/category_list_spec.rb b/spec/components/category_list_spec.rb index 92475f074..9d3f6df14 100644 --- a/spec/components/category_list_spec.rb +++ b/spec/components/category_list_spec.rb @@ -73,7 +73,7 @@ describe CategoryList do SiteSetting.stubs(:allow_uncategorized_topics).returns(true) Fabricate(:topic, category: Fabricate(:category)) Guardian.any_instance.expects(:can_create?).with(Category).returns(true) - category_list.categories.should have(3).categories + category_list.categories.size.should == 3 category_list.categories.should include(topic_category) end diff --git a/spec/controllers/admin/dashboard_controller_spec.rb b/spec/controllers/admin/dashboard_controller_spec.rb index 332e335f2..97cb8727d 100644 --- a/spec/controllers/admin/dashboard_controller_spec.rb +++ b/spec/controllers/admin/dashboard_controller_spec.rb @@ -60,7 +60,7 @@ describe Admin::DashboardController do it 'returns an empty array' do xhr :get, :problems json = JSON.parse(response.body) - json['problems'].should have(0).problems + json['problems'].size.should == 0 end end @@ -72,7 +72,7 @@ describe Admin::DashboardController do it 'returns an array of strings' do xhr :get, :problems json = JSON.parse(response.body) - json['problems'].should have(2).problems + json['problems'].size.should == 2 json['problems'][0].should be_a(String) json['problems'][1].should be_a(String) end diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index d5e1db797..192e000cc 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -782,7 +782,7 @@ describe UsersController do xhr :get, :invited, username: inviter.username, filter: 'billybob' invites = JSON.parse(response.body)['invites'] - expect(invites).to have(1).item + invites.size.should == 1 expect(invites.first).to include('email' => 'billybob@example.com') end @@ -804,7 +804,7 @@ describe UsersController do xhr :get, :invited, username: inviter.username, filter: 'billybob' invites = JSON.parse(response.body)['invites'] - expect(invites).to have(1).item + invites.size.should == 1 expect(invites.first).to include('email' => 'billybob@example.com') end @@ -830,7 +830,7 @@ describe UsersController do xhr :get, :invited, username: inviter.username invites = JSON.parse(response.body)['invites'] - expect(invites).to have(1).item + invites.size.should == 1 expect(invites.first).to include('email' => invite.email) end end @@ -851,7 +851,7 @@ describe UsersController do xhr :get, :invited, username: inviter.username invites = JSON.parse(response.body)['invites'] - expect(invites).to have(1).item + invites.size.should == 1 expect(invites.first).to include("email" => invite.email) end end @@ -885,7 +885,7 @@ describe UsersController do xhr :get, :invited, username: inviter.username invites = JSON.parse(response.body)['invites'] - expect(invites).to have(1).item + invites.size.should == 1 expect(invites.first).to include('email' => invite.email) end end diff --git a/spec/integration/spam_rules_spec.rb b/spec/integration/spam_rules_spec.rb index 0666b0a88..022b0fd74 100644 --- a/spec/integration/spam_rules_spec.rb +++ b/spec/integration/spam_rules_spec.rb @@ -39,7 +39,7 @@ describe SpamRulesEnforcer do When { PostAction.act(user2, spam_post, PostActionType.types[:spam]) } - Invariant { expect(Guardian.new(spammer).can_create_topic?(nil)).should == false } + Invariant { expect(Guardian.new(spammer).can_create_topic?(nil)).to be false } Invariant { expect{PostCreator.create(spammer, {title: 'limited time offer for you', raw: 'better buy this stuff ok', archetype_id: 1})}.to raise_error(Discourse::InvalidAccess) } Invariant { expect{PostCreator.create(spammer, {topic_id: another_topic.id, raw: 'my reply is spam in your topic', archetype_id: 1})}.to raise_error(Discourse::InvalidAccess) } @@ -73,7 +73,7 @@ describe SpamRulesEnforcer do Given { SiteSetting.stubs(:flags_required_to_hide_post).returns(2) } When { PostAction.act(user2, spam_post, PostActionType.types[:spam]) } Then { expect(spammer.reload).to be_blocked } - And { expect(Guardian.new(spammer).can_create_topic?(nil)).should == false } + And { expect(Guardian.new(spammer).can_create_topic?(nil)).to be false } end end end @@ -87,7 +87,7 @@ describe SpamRulesEnforcer do When { PostAction.act(user1, spam_post, PostActionType.types[:spam]) } When { PostAction.act(user2, spam_post, PostActionType.types[:spam]) } Then { expect(spam_post.reload).to_not be_hidden } - And { expect(Guardian.new(spammer).can_create_topic?(nil)).should == true } + And { expect(Guardian.new(spammer).can_create_topic?(nil)).to be true } And { expect{PostCreator.create(spammer, {title: 'limited time offer for you', raw: 'better buy this stuff ok', archetype_id: 1})}.to_not raise_error } And { expect(spammer.reload.private_topics_count).to eq(private_messages_count) } end diff --git a/spec/integration/topic_auto_close_spec.rb b/spec/integration/topic_auto_close_spec.rb index 2e6df3a14..d1f1d371c 100644 --- a/spec/integration/topic_auto_close_spec.rb +++ b/spec/integration/topic_auto_close_spec.rb @@ -53,13 +53,13 @@ describe Topic do Given(:category) { Fabricate(:category, auto_close_hours: 2.0) } Then { topic.auto_close_at.should be_within_one_second_of(2.hours.from_now) } And { topic.auto_close_started_at.should == Time.zone.now } - And { scheduled_jobs_for(:close_topic, {topic_id: topic.id}).should have(1).job } + And { scheduled_jobs_for(:close_topic, {topic_id: topic.id}).size.should == 1 } And { scheduled_jobs_for(:close_topic, {topic_id: category.topic.id}).should be_empty } context 'topic was created by staff user' do Given(:admin) { Fabricate(:admin) } Given(:staff_topic) { Fabricate(:topic, user: admin, category: category) } - Then { scheduled_jobs_for(:close_topic, {topic_id: staff_topic.id, user_id: admin.id}).should have(1).job } + Then { scheduled_jobs_for(:close_topic, {topic_id: staff_topic.id, user_id: admin.id}).size.should == 1 } context 'topic is closed manually' do When { staff_topic.update_status('closed', true, admin) } @@ -73,7 +73,7 @@ describe Topic do Given { Discourse.stubs(:system_user).returns(system_user) } Given(:regular_user) { Fabricate(:user) } Given(:regular_user_topic) { Fabricate(:topic, user: regular_user, category: category) } - Then { scheduled_jobs_for(:close_topic, {topic_id: regular_user_topic.id, user_id: system_user.id}).should have(1).job } + Then { scheduled_jobs_for(:close_topic, {topic_id: regular_user_topic.id, user_id: system_user.id}).size.should == 1 } end context 'auto_close_hours of topic was set to 0' do @@ -84,7 +84,7 @@ describe Topic do context 'two topics in the category' do Given!(:other_topic) { Fabricate(:topic, category: category) } When { topic } # create the second topic - Then { scheduled_jobs_for(:close_topic).should have(2).jobs } + Then { scheduled_jobs_for(:close_topic).size.should == 2 } end end diff --git a/spec/models/color_scheme_spec.rb b/spec/models/color_scheme_spec.rb index 63e4993a1..729719304 100644 --- a/spec/models/color_scheme_spec.rb +++ b/spec/models/color_scheme_spec.rb @@ -11,7 +11,7 @@ describe ColorScheme do describe "new" do it "can take colors" do c = described_class.new(valid_params) - c.colors.should have(valid_colors.size).colors + c.colors.size.should == valid_colors.size c.colors.first.should be_a(ColorSchemeColor) expect { c.save.should == true @@ -32,7 +32,7 @@ describe ColorScheme do it "creates a new color scheme" do c = described_class.create_from_base(name: 'Yellow', colors: {first_one: 'FFFF00', third_one: 'F00D33'}) - c.colors.should have(base_colors.size).colors + c.colors.size.should == base_colors.size first = c.colors.find {|x| x.name == 'first_one'} second = c.colors.find {|x| x.name == 'second_one'} third = c.colors.find {|x| x.name == 'third_one'} diff --git a/spec/models/incoming_links_report_spec.rb b/spec/models/incoming_links_report_spec.rb index 98b0e1c21..780d0fa3d 100644 --- a/spec/models/incoming_links_report_spec.rb +++ b/spec/models/incoming_links_report_spec.rb @@ -48,7 +48,7 @@ describe IncomingLinksReport do it 'with no IncomingLink records, it returns correct data' do stub_empty_referrers_data - top_referrers[:data].should have(0).records + top_referrers[:data].size.should == 0 end it 'with some IncomingLink records, it returns correct data' do @@ -80,7 +80,7 @@ describe IncomingLinksReport do it 'with no IncomingLink records, it returns correct data' do stub_empty_traffic_source_data - top_traffic_sources[:data].should have(0).records + top_traffic_sources[:data].size.should == 0 end it 'with some IncomingLink records, it returns correct data' do @@ -108,7 +108,7 @@ describe IncomingLinksReport do it 'with no IncomingLink records, it returns correct data' do stub_empty_referred_topics_data - top_referred_topics[:data].should have(0).records + top_referred_topics[:data].size.should == 0 end it 'with some IncomingLink records, it returns correct data' do diff --git a/spec/models/invite_spec.rb b/spec/models/invite_spec.rb index db3c0ee1a..63e902b33 100644 --- a/spec/models/invite_spec.rb +++ b/spec/models/invite_spec.rb @@ -366,7 +366,7 @@ describe Invite do invites = Invite.find_redeemed_invites_from(inviter) - expect(invites).to have(1).items + invites.size.should == 1 expect(invites.first).to eq redeemed_invite end end diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 2f688b89d..d6b4da4cc 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -40,7 +40,7 @@ describe Notification do lambda { reply = Fabricate(:basic_reply, user: post.user, topic: post.topic) process_alerts(reply) - }.should_not change(post.user.notifications, :count).by(1) + }.should_not change(post.user.notifications, :count) end end diff --git a/spec/services/post_alerter_spec.rb b/spec/services/post_alerter_spec.rb index 6c789eb7c..1de486e19 100644 --- a/spec/services/post_alerter_spec.rb +++ b/spec/services/post_alerter_spec.rb @@ -28,7 +28,7 @@ describe PostAlerter do topic = create_post_with_alerts.topic lambda { Fabricate(:post, topic: topic, user: topic.user, raw: '[quote="Bruce Wayne, post:1"]whatup[/quote]') - }.should_not change(topic.user.notifications, :count).by(1) + }.should_not change(topic.user.notifications, :count) end end @@ -76,7 +76,7 @@ describe PostAlerter do mention_post lambda { create_post_with_alerts(user: user, raw: 'second post', topic: topic) - }.should_not change(user.notifications, :count).by(1) + }.should_not change(user.notifications, :count) end end