From d5443c15db2294a8a7f9ad45b7acb10ba3b75323 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 --- spec/lib/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 | 8 ++++---- 6 files changed, 17 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 0a12538160bcdf..86aa6b87bd83d8 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 ef0aa6977a3c30..240a90e5a77eaa 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 468ac35a86ec71..cdaac927fbb60f 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.exists?(id: upload.id)).to eq(true) 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.exists?(id: upload.id)).to eq(true) 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.exists?(id: upload.id)).to eq(true) 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 2df1513391655e..c6558406fe3998 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 691d8a5860327e..51711214153b07 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 7d8dc6d075c99d..3671a78aad2043 100644 --- a/spec/models/topic_spec.rb +++ b/spec/models/topic_spec.rb @@ -2353,16 +2353,16 @@ def set_state!(group, user, state) 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(Topic.new(category: category).read_restricted_category?).to eq(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(Topic.new(category: category).read_restricted_category?).to eq(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(Topic.new(category: nil).read_restricted_category?).to eq(nil) end end