From 586f10a0304ccfe71ef5ceb4e66a96abe3e91ece Mon Sep 17 00:00:00 2001 From: Phil Pirozhkov Date: Mon, 25 Jul 2022 22:12:15 +0300 Subject: [PATCH] Comply to strict predicate matchers See: - https://github.com/rspec/rspec-expectations/pull/1195 - https://github.com/rspec/rspec-expectations/pull/1196 - https://github.com/rspec/rspec-expectations/pull/1277 --- .../freedom_patches/mail_disable_starttls_spec.rb | 4 ++-- spec/lib/quote_comparer_spec.rb | 8 ++++---- spec/lib/svg_sprite/svg_sprite_spec.rb | 6 +++--- spec/lib/topic_view_spec.rb | 6 +++--- spec/models/theme_spec.rb | 2 +- spec/models/topic_spec.rb | 12 ++++++++---- 6 files changed, 21 insertions(+), 17 deletions(-) diff --git a/spec/lib/freedom_patches/mail_disable_starttls_spec.rb b/spec/lib/freedom_patches/mail_disable_starttls_spec.rb index 0a12538160bcd..86aa6b87bd83d 100644 --- a/spec/lib/freedom_patches/mail_disable_starttls_spec.rb +++ b/spec/lib/freedom_patches/mail_disable_starttls_spec.rb @@ -9,7 +9,7 @@ let(:options) { {} } it "doesn't disable starttls" do - expect(smtp_session).to be_starttls + expect(smtp_session.starttls?).to eq(:auto) end end @@ -17,7 +17,7 @@ let(:options) { { enable_starttls_auto: false } } it "properly disables starttls" do - expect(smtp_session).not_to be_starttls + expect(smtp_session.starttls?).to eq(false) end end end diff --git a/spec/lib/quote_comparer_spec.rb b/spec/lib/quote_comparer_spec.rb index ef0aa6977a3c3..240a90e5a77ea 100644 --- a/spec/lib/quote_comparer_spec.rb +++ b/spec/lib/quote_comparer_spec.rb @@ -19,12 +19,12 @@ expect(QuoteComparer.new(post.topic_id, nil, "test")).to be_missing end - it "returns false for only missing text" do - expect(QuoteComparer.new(post.topic_id, post.post_number, nil)).to_not be_missing + it "returns a falsey value for only missing text" do + expect(QuoteComparer.new(post.topic_id, post.post_number, nil).missing?).to be(nil) end - it "returns false for no missing topic and post" do - expect(QuoteComparer.new(post.topic_id, post.post_number, "test")).to_not be_missing + it "returns a falsey value for no missing topic and post" do + expect(QuoteComparer.new(post.topic_id, post.post_number, "test").missing?).to be(nil) end end diff --git a/spec/lib/svg_sprite/svg_sprite_spec.rb b/spec/lib/svg_sprite/svg_sprite_spec.rb index 468ac35a86ec7..0f12fd74e8e4b 100644 --- a/spec/lib/svg_sprite/svg_sprite_spec.rb +++ b/spec/lib/svg_sprite/svg_sprite_spec.rb @@ -254,7 +254,7 @@ theme.set_field(target: :common, name: SvgSprite.theme_sprite_variable_name, upload_id: upload.id, type: :theme_upload_var) theme.save! - expect(Upload.where(id: upload.id)).to be_exist + expect(Upload.where(id: upload.id)).to be_exists expect(SvgSprite.bundle(theme.id)).to match(/my-custom-theme-icon/) end @@ -266,7 +266,7 @@ theme.set_field(target: :common, name: SvgSprite.theme_sprite_variable_name, upload_id: upload.id, type: :theme_upload_var) theme.save! - expect(Upload.where(id: upload.id)).to be_exist + expect(Upload.where(id: upload.id)).to be_exists expect(SvgSprite.bundle(theme.id)).to match(/arrow-down/) end @@ -280,7 +280,7 @@ child_theme.set_field(target: :common, name: SvgSprite.theme_sprite_variable_name, upload_id: upload.id, type: :theme_upload_var) child_theme.save! - expect(Upload.where(id: upload.id)).to be_exist + expect(Upload.where(id: upload.id)).to be_exists expect(SvgSprite.bundle(theme.id)).to match(/my-custom-theme-icon/) end diff --git a/spec/lib/topic_view_spec.rb b/spec/lib/topic_view_spec.rb index 2df1513391655..c6558406fe399 100644 --- a/spec/lib/topic_view_spec.rb +++ b/spec/lib/topic_view_spec.rb @@ -1012,7 +1012,7 @@ def topic_view_for_post(post_number) context "when queue is enabled globally" do let(:queue_enabled) { true } - it { is_expected.to be_queued_posts_enabled } + it { expect(topic_view.queued_posts_enabled?).to be(true) } end context "when queue is not enabled globally" do @@ -1023,11 +1023,11 @@ def topic_view_for_post(post_number) category.custom_fields[Category::REQUIRE_REPLY_APPROVAL] = true end - it { is_expected.to be_queued_posts_enabled } + it { expect(topic_view.queued_posts_enabled?).to be(true) } end context "when category is not moderated" do - it { is_expected.not_to be_queued_posts_enabled } + it { expect(topic_view.queued_posts_enabled?).to be(nil) } end end end diff --git a/spec/models/theme_spec.rb b/spec/models/theme_spec.rb index 691d8a5860327..51711214153b0 100644 --- a/spec/models/theme_spec.rb +++ b/spec/models/theme_spec.rb @@ -282,7 +282,7 @@ def transpile(html) freeze_time (SiteSetting.clean_orphan_uploads_grace_period_hours + 1).hours.from_now Jobs::CleanUpUploads.new.execute(nil) - expect(Upload.where(id: upload.id)).to be_exist + expect(Upload.where(id: upload.id)).to be_exists # no error for theme field theme.reload diff --git a/spec/models/topic_spec.rb b/spec/models/topic_spec.rb index f8344cd492573..3064117551bd3 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -2351,18 +2351,22 @@ def set_state!(group, user, state) describe '#secure_category?' do let(:category) { Category.new } + def read_restricted_category?(topic) + topic.read_restricted_category? + end + it "is true if the category is secure" do category.stubs(:read_restricted).returns(true) - expect(Topic.new(category: category)).to be_read_restricted_category + expect(read_restricted_category?(Topic.new(category: category))).to be(true) end it "is false if the category is not secure" do category.stubs(:read_restricted).returns(false) - expect(Topic.new(category: category)).not_to be_read_restricted_category + expect(read_restricted_category?(Topic.new(category: category))).to be(false) end - it "is false if there is no category" do - expect(Topic.new(category: nil)).not_to be_read_restricted_category + it "is falsey if there is no category" do + expect(read_restricted_category?(Topic.new(category: nil))).to be(nil) end end