Skip to content

Commit

Permalink
Comply to strict predicate matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
pirj committed Jul 25, 2022
1 parent c2039a7 commit 586f10a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 17 deletions.
4 changes: 2 additions & 2 deletions spec/lib/freedom_patches/mail_disable_starttls_spec.rb
Expand Up @@ -9,15 +9,15 @@
let(:options) { {} }

it "doesn't disable starttls" do
expect(smtp_session).to be_starttls
expect(smtp_session.starttls?).to eq(:auto)
end
end

context "when the starttls option is set to `false`" do
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
8 changes: 4 additions & 4 deletions spec/lib/quote_comparer_spec.rb
Expand Up @@ -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

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/svg_sprite/svg_sprite_spec.rb
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
6 changes: 3 additions & 3 deletions spec/lib/topic_view_spec.rb
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion spec/models/theme_spec.rb
Expand Up @@ -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
Expand Down
12 changes: 8 additions & 4 deletions spec/models/topic_spec.rb
Expand Up @@ -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

Expand Down

0 comments on commit 586f10a

Please sign in to comment.