about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/api/v1/accounts/credentials_controller_spec.rb4
-rw-r--r--spec/controllers/api/v1/timelines/direct_controller_spec.rb2
-rw-r--r--spec/controllers/application_controller_spec.rb4
-rw-r--r--spec/controllers/settings/flavours_controller_spec.rb3
-rw-r--r--spec/lib/advanced_text_formatter_spec.rb82
-rw-r--r--spec/models/concerns/account_interactions_spec.rb39
-rw-r--r--spec/models/public_feed_spec.rb12
-rw-r--r--spec/models/status_spec.rb42
-rw-r--r--spec/models/tag_feed_spec.rb2
-rw-r--r--spec/policies/status_policy_spec.rb4
-rw-r--r--spec/services/notify_service_spec.rb2
-rw-r--r--spec/validators/status_length_validator_spec.rb2
12 files changed, 82 insertions, 116 deletions
diff --git a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb
index de08dd524..a677aaad0 100644
--- a/spec/controllers/api/v1/accounts/credentials_controller_spec.rb
+++ b/spec/controllers/api/v1/accounts/credentials_controller_spec.rb
@@ -75,10 +75,10 @@ describe Api::V1::Accounts::CredentialsController do
         end
       end
 
-      describe 'with invalid data' do
+      describe 'with a too long profile bio' do
         before do
           note = 'This is too long. '
-          note = note + 'a' * (Account::MAX_NOTE_LENGTH - note.length + 1)
+          note += 'a' * (Account::MAX_NOTE_LENGTH - note.length + 1)
           patch :update, params: { note: note }
         end
 
diff --git a/spec/controllers/api/v1/timelines/direct_controller_spec.rb b/spec/controllers/api/v1/timelines/direct_controller_spec.rb
index a22c2cbea..def67a0fe 100644
--- a/spec/controllers/api/v1/timelines/direct_controller_spec.rb
+++ b/spec/controllers/api/v1/timelines/direct_controller_spec.rb
@@ -2,7 +2,7 @@
 
 require 'rails_helper'
 
-RSpec.describe Api::V1::Timelines::DirectController, type: :controller do
+RSpec.describe Api::V1::Timelines::DirectController do
   let(:user)  { Fabricate(:user) }
   let(:token) { Fabricate(:accessible_access_token, resource_owner_id: user.id, scopes: 'read:statuses') }
 
diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb
index 1aabae0ea..82455d874 100644
--- a/spec/controllers/application_controller_spec.rb
+++ b/spec/controllers/application_controller_spec.rb
@@ -75,8 +75,8 @@ describe ApplicationController, type: :controller do
 
   describe 'helper_method :current_flavour' do
     it 'returns "glitch" when theme wasn\'t changed in admin settings' do
-      allow(Setting).to receive(:default_settings).and_return({'skin' => 'default'})
-      allow(Setting).to receive(:default_settings).and_return({'flavour' => 'glitch'})
+      allow(Setting).to receive(:default_settings).and_return({ 'skin' => 'default' })
+      allow(Setting).to receive(:default_settings).and_return({ 'flavour' => 'glitch' })
 
       expect(controller.view_context.current_flavour).to eq 'glitch'
     end
diff --git a/spec/controllers/settings/flavours_controller_spec.rb b/spec/controllers/settings/flavours_controller_spec.rb
index f89bde1f9..8c7d4a768 100644
--- a/spec/controllers/settings/flavours_controller_spec.rb
+++ b/spec/controllers/settings/flavours_controller_spec.rb
@@ -1,7 +1,8 @@
 # frozen_string_literal: true
+
 require 'rails_helper'
 
-RSpec.describe Settings::FlavoursController, type: :controller do
+RSpec.describe Settings::FlavoursController do
   let(:user) { Fabricate(:user) }
 
   before do
diff --git a/spec/lib/advanced_text_formatter_spec.rb b/spec/lib/advanced_text_formatter_spec.rb
index c1e469606..8b27b56a1 100644
--- a/spec/lib/advanced_text_formatter_spec.rb
+++ b/spec/lib/advanced_text_formatter_spec.rb
@@ -1,12 +1,14 @@
+# frozen_string_literal: true
+
 require 'rails_helper'
 
 RSpec.describe AdvancedTextFormatter do
   describe '#to_s' do
+    subject { described_class.new(text, preloaded_accounts: preloaded_accounts, content_type: content_type).to_s }
+
     let(:preloaded_accounts) { nil }
     let(:content_type) { 'text/markdown' }
 
-    subject { described_class.new(text, preloaded_accounts: preloaded_accounts, content_type: content_type).to_s }
-
     context 'given a markdown source' do
       let(:content_type) { 'text/markdown' }
 
@@ -14,7 +16,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'text' }
 
         it 'paragraphizes the text' do
-          is_expected.to eq '<p>text</p>'
+          expect(subject).to eq '<p>text</p>'
         end
       end
 
@@ -22,7 +24,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { "line\nfeed" }
 
         it 'removes line feeds' do
-          is_expected.not_to include "\n"
+          expect(subject).to_not include "\n"
         end
       end
 
@@ -30,7 +32,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'test `foo` bar' }
 
         it 'formats code using <code>' do
-          is_expected.to include 'test <code>foo</code> bar'
+          expect(subject).to include 'test <code>foo</code> bar'
         end
       end
 
@@ -38,15 +40,15 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { "test\n\n```\nint main(void) {\n  return 0; // https://joinmastodon.org/foo\n}\n```\n" }
 
         it 'formats code using <pre> and <code>' do
-          is_expected.to include '<pre><code>int main'
+          expect(subject).to include '<pre><code>int main'
         end
 
         it 'does not strip leading spaces' do
-          is_expected.to include '>  return 0'
+          expect(subject).to include '>  return 0'
         end
 
         it 'does not format links' do
-          is_expected.to include 'return 0; // https://joinmastodon.org/foo'
+          expect(subject).to include 'return 0; // https://joinmastodon.org/foo'
         end
       end
 
@@ -54,7 +56,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'test `https://foo.bar/bar` bar' }
 
         it 'does not rewrite the link' do
-          is_expected.to include 'test <code>https://foo.bar/bar</code> bar'
+          expect(subject).to include 'test <code>https://foo.bar/bar</code> bar'
         end
       end
 
@@ -62,7 +64,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'foo https://cb6e6126.ngrok.io/about/more' }
 
         it 'creates a link' do
-          is_expected.to include '<a href="https://cb6e6126.ngrok.io/about/more"'
+          expect(subject).to include '<a href="https://cb6e6126.ngrok.io/about/more"'
         end
       end
 
@@ -71,7 +73,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '@alice' }
 
         it 'creates a mention link' do
-          is_expected.to include '<a href="https://cb6e6126.ngrok.io/@alice" class="u-url mention">@<span>alice</span></a></span>'
+          expect(subject).to include '<a href="https://cb6e6126.ngrok.io/@alice" class="u-url mention">@<span>alice</span></a></span>'
         end
       end
 
@@ -80,7 +82,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '@alice' }
 
         it 'does not create a mention link' do
-          is_expected.to include '@alice'
+          expect(subject).to include '@alice'
         end
       end
 
@@ -88,7 +90,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4"'
+          expect(subject).to include 'href="https://hackernoon.com/the-power-to-build-communities-a-response-to-mark-zuckerberg-3f2cac9148a4"'
         end
       end
 
@@ -96,7 +98,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'http://google.com' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="http://google.com"'
+          expect(subject).to include 'href="http://google.com"'
         end
       end
 
@@ -104,7 +106,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'http://example.gay' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="http://example.gay"'
+          expect(subject).to include 'href="http://example.gay"'
         end
       end
 
@@ -112,11 +114,11 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://nic.みんな/' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://nic.みんな/"'
+          expect(subject).to include 'href="https://nic.みんな/"'
         end
 
         it 'has display URL' do
-          is_expected.to include '<span class="">nic.みんな/</span>'
+          expect(subject).to include '<span class="">nic.みんな/</span>'
         end
       end
 
@@ -124,7 +126,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona. ' }
 
         it 'matches the full URL but not the period' do
-          is_expected.to include 'href="http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona"'
+          expect(subject).to include 'href="http://www.mcmansionhell.com/post/156408871451/50-states-of-mcmansion-hell-scottsdale-arizona"'
         end
       end
 
@@ -132,7 +134,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '(http://google.com/)' }
 
         it 'matches the full URL but not the parentheses' do
-          is_expected.to include 'href="http://google.com/"'
+          expect(subject).to include 'href="http://google.com/"'
         end
       end
 
@@ -140,7 +142,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'http://www.google.com!' }
 
         it 'matches the full URL but not the exclamation point' do
-          is_expected.to include 'href="http://www.google.com"'
+          expect(subject).to include 'href="http://www.google.com"'
         end
       end
 
@@ -148,7 +150,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { "http://www.google.com'" }
 
         it 'matches the full URL but not the single quote' do
-          is_expected.to include 'href="http://www.google.com"'
+          expect(subject).to include 'href="http://www.google.com"'
         end
       end
     end
@@ -157,7 +159,7 @@ RSpec.describe AdvancedTextFormatter do
       let(:text) { 'http://www.google.com>' }
 
       it 'matches the full URL but not the angle bracket' do
-        is_expected.to include 'href="http://www.google.com"'
+        expect(subject).to include 'href="http://www.google.com"'
       end
     end
 
@@ -166,7 +168,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&q=autolink' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&amp;q=autolink"'
+          expect(subject).to include 'href="https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&amp;q=autolink"'
         end
       end
 
@@ -174,7 +176,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://www.ruby-toolbox.com/search?utf8=✓&q=autolink' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://www.ruby-toolbox.com/search?utf8=✓&amp;q=autolink"'
+          expect(subject).to include 'href="https://www.ruby-toolbox.com/search?utf8=✓&amp;q=autolink"'
         end
       end
 
@@ -182,7 +184,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://www.ruby-toolbox.com/search?utf8=✓' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://www.ruby-toolbox.com/search?utf8=✓"'
+          expect(subject).to include 'href="https://www.ruby-toolbox.com/search?utf8=✓"'
         end
       end
 
@@ -190,7 +192,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&utf81=✓&q=autolink' }
 
         it 'preserves escaped unicode characters' do
-          is_expected.to include 'href="https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&amp;utf81=✓&amp;q=autolink"'
+          expect(subject).to include 'href="https://www.ruby-toolbox.com/search?utf8=%E2%9C%93&amp;utf81=✓&amp;q=autolink"'
         end
       end
 
@@ -198,7 +200,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'https://en.wikipedia.org/wiki/Diaspora_(software)' }
 
         it 'matches the full URL' do
-          is_expected.to include 'href="https://en.wikipedia.org/wiki/Diaspora_(software)"'
+          expect(subject).to include 'href="https://en.wikipedia.org/wiki/Diaspora_(software)"'
         end
       end
 
@@ -206,7 +208,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '"https://example.com/"' }
 
         it 'does not match the quotation marks' do
-          is_expected.to include 'href="https://example.com/"'
+          expect(subject).to include 'href="https://example.com/"'
         end
       end
 
@@ -214,19 +216,19 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '<https://example.com/>' }
 
         it 'does not match the angle brackets' do
-          is_expected.to include 'href="https://example.com/"'
+          expect(subject).to include 'href="https://example.com/"'
         end
       end
 
       context 'given a URL containing unsafe code (XSS attack, invisible part)' do
-        let(:text) { %q{http://example.com/blahblahblahblah/a<script>alert("Hello")</script>} }
+        let(:text) { 'http://example.com/blahblahblahblah/a<script>alert("Hello")</script>' }
 
         it 'does not include the HTML in the URL' do
-          is_expected.to include '"http://example.com/blahblahblahblah/a"'
+          expect(subject).to include '"http://example.com/blahblahblahblah/a"'
         end
 
         it 'does not include a script tag' do
-          is_expected.to_not include '<script>'
+          expect(subject).to_not include '<script>'
         end
       end
 
@@ -234,7 +236,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { '<script>alert("Hello")</script>' }
 
         it 'does not include a script tag' do
-          is_expected.to_not include '<script>'
+          expect(subject).to_not include '<script>'
         end
       end
 
@@ -242,7 +244,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { %q{<img src="javascript:alert('XSS');">} }
 
         it 'does not include the javascript' do
-          is_expected.to_not include 'href="javascript:'
+          expect(subject).to_not include 'href="javascript:'
         end
       end
 
@@ -250,7 +252,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'http://www\.google\.com' }
 
         it 'outputs the raw URL' do
-          is_expected.to eq '<p>http://www\.google\.com</p>'
+          expect(subject).to eq '<p>http://www\.google\.com</p>'
         end
       end
 
@@ -258,7 +260,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text)  { '#hashtag' }
 
         it 'creates a hashtag link' do
-          is_expected.to include '/tags/hashtag" class="mention hashtag" rel="tag">#<span>hashtag</span></a>'
+          expect(subject).to include '/tags/hashtag" class="mention hashtag" rel="tag">#<span>hashtag</span></a>'
         end
       end
 
@@ -266,7 +268,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text)  { '#hashtagタグ' }
 
         it 'creates a hashtag link' do
-          is_expected.to include '/tags/hashtag%E3%82%BF%E3%82%B0" class="mention hashtag" rel="tag">#<span>hashtagタグ</span></a>'
+          expect(subject).to include '/tags/hashtag%E3%82%BF%E3%82%B0" class="mention hashtag" rel="tag">#<span>hashtagタグ</span></a>'
         end
       end
 
@@ -274,7 +276,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'xmpp:user@instance.com' }
 
         it 'matches the full URI' do
-          is_expected.to include 'href="xmpp:user@instance.com"'
+          expect(subject).to include 'href="xmpp:user@instance.com"'
         end
       end
 
@@ -282,7 +284,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'please join xmpp:muc@instance.com?join right now' }
 
         it 'matches the full URI' do
-          is_expected.to include 'href="xmpp:muc@instance.com?join"'
+          expect(subject).to include 'href="xmpp:muc@instance.com?join"'
         end
       end
 
@@ -290,7 +292,7 @@ RSpec.describe AdvancedTextFormatter do
         let(:text) { 'wikipedia gives this example of a magnet uri: magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a' }
 
         it 'matches the full URI' do
-          is_expected.to include 'href="magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a"'
+          expect(subject).to include 'href="magnet:?xt=urn:btih:c12fe1c06bba254a9dc9f519b335aa7c1367a88a"'
         end
       end
     end
diff --git a/spec/models/concerns/account_interactions_spec.rb b/spec/models/concerns/account_interactions_spec.rb
index 863b025af..32e08d5f7 100644
--- a/spec/models/concerns/account_interactions_spec.rb
+++ b/spec/models/concerns/account_interactions_spec.rb
@@ -23,7 +23,7 @@ describe AccountInteractions do
     context 'account with Follow but with reblogs disabled' do
       it 'returns { target_account_id => { reblogs: false } }' do
         Fabricate(:follow, account: account, target_account: target_account, show_reblogs: false)
-        is_expected.to eq(target_account_id => { reblogs: false, notify: false, languages: nil })
+        expect(subject).to eq(target_account_id => { reblogs: false, notify: false, languages: nil })
       end
     end
 
@@ -690,41 +690,4 @@ describe AccountInteractions do
       end
     end
   end
-
-  describe 'ignoring reblogs from an account' do
-    before do
-      @me = Fabricate(:account, username: 'Me')
-      @you = Fabricate(:account, username: 'You')
-    end
-
-    context 'with the reblogs option unspecified' do
-      before do
-        @me.follow!(@you)
-      end
-
-      it 'defaults to showing reblogs' do
-        expect(@me.muting_reblogs?(@you)).to be(false)
-      end
-    end
-
-    context 'with the reblogs option set to false' do
-      before do
-        @me.follow!(@you, reblogs: false)
-      end
-
-      it 'does mute reblogs' do
-        expect(@me.muting_reblogs?(@you)).to be(true)
-      end
-    end
-
-    context 'with the reblogs option set to true' do
-      before do
-        @me.follow!(@you, reblogs: true)
-      end
-
-      it 'does not mute reblogs' do
-        expect(@me.muting_reblogs?(@you)).to be(false)
-      end
-    end
-  end
 end
diff --git a/spec/models/public_feed_spec.rb b/spec/models/public_feed_spec.rb
index f607f10ec..d31aba084 100644
--- a/spec/models/public_feed_spec.rb
+++ b/spec/models/public_feed_spec.rb
@@ -64,7 +64,7 @@ RSpec.describe PublicFeed, type: :model do
         end
 
         it 'does not include local-only statuses' do
-          expect(subject).not_to include(local_only_status.id)
+          expect(subject).to_not include(local_only_status.id)
         end
       end
 
@@ -80,12 +80,14 @@ RSpec.describe PublicFeed, type: :model do
         end
 
         it 'does not include local-only statuses' do
-          expect(subject).not_to include(local_only_status.id)
+          expect(subject).to_not include(local_only_status.id)
         end
       end
     end
 
     context 'without local_only option but allow_local_only' do
+      subject { described_class.new(viewer, allow_local_only: true).get(20).map(&:id) }
+
       let(:viewer) { nil }
 
       let!(:local_account)  { Fabricate(:account, domain: nil) }
@@ -94,8 +96,6 @@ RSpec.describe PublicFeed, type: :model do
       let!(:remote_status)  { Fabricate(:status, account: remote_account) }
       let!(:local_only_status) { Fabricate(:status, account: local_account, local_only: true) }
 
-      subject { described_class.new(viewer, allow_local_only: true).get(20).map(&:id) }
-
       context 'without a viewer' do
         let(:viewer) { nil }
 
@@ -108,7 +108,7 @@ RSpec.describe PublicFeed, type: :model do
         end
 
         it 'does not include local-only statuses' do
-          expect(subject).not_to include(local_only_status.id)
+          expect(subject).to_not include(local_only_status.id)
         end
       end
 
@@ -147,7 +147,7 @@ RSpec.describe PublicFeed, type: :model do
         end
 
         it 'does not include local-only statuses' do
-          expect(subject).not_to include(local_only_status.id)
+          expect(subject).to_not include(local_only_status.id)
         end
       end
 
diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb
index 7022c5f00..04e5c26af 100644
--- a/spec/models/status_spec.rb
+++ b/spec/models/status_spec.rb
@@ -206,14 +206,14 @@ RSpec.describe Status, type: :model do
   end
 
   describe 'on create' do
+    subject { Status.new }
+
     let(:local_account) { Fabricate(:account, username: 'local', domain: nil) }
     let(:remote_account) { Fabricate(:account, username: 'remote', domain: 'example.com') }
 
-    subject { Status.new }
-
     describe 'on a status that ends with the local-only emoji' do
       before do
-        subject.text = 'A toot ' + subject.local_only_emoji
+        subject.text = "A toot #{subject.local_only_emoji}"
       end
 
       context 'if the status originates from this instance' do
@@ -291,52 +291,52 @@ RSpec.describe Status, type: :model do
   end
 
   describe '.as_direct_timeline' do
+    subject(:results) { Status.as_direct_timeline(account) }
+
     let(:account) { Fabricate(:account) }
     let(:followed) { Fabricate(:account) }
     let(:not_followed) { Fabricate(:account) }
 
-    before do
-      Fabricate(:follow, account: account, target_account: followed)
-
-      @self_public_status = Fabricate(:status, account: account, visibility: :public)
-      @self_direct_status = Fabricate(:status, account: account, visibility: :direct)
-      @followed_public_status = Fabricate(:status, account: followed, visibility: :public)
-      @followed_direct_status = Fabricate(:status, account: followed, visibility: :direct)
-      @not_followed_direct_status = Fabricate(:status, account: not_followed, visibility: :direct)
+    let!(:self_public_status) { Fabricate(:status, account: account, visibility: :public) }
+    let!(:self_direct_status) { Fabricate(:status, account: account, visibility: :direct) }
+    let!(:followed_public_status) { Fabricate(:status, account: followed, visibility: :public) }
+    let!(:followed_direct_status) { Fabricate(:status, account: followed, visibility: :direct) }
+    let!(:not_followed_direct_status) { Fabricate(:status, account: not_followed, visibility: :direct) }
 
-      @results = Status.as_direct_timeline(account)
+    before do
+      account.follow!(followed)
     end
 
     it 'does not include public statuses from self' do
-      expect(@results).to_not include(@self_public_status)
+      expect(results).to_not include(self_public_status)
     end
 
     it 'includes direct statuses from self' do
-      expect(@results).to include(@self_direct_status)
+      expect(results).to include(self_direct_status)
     end
 
     it 'does not include public statuses from followed' do
-      expect(@results).to_not include(@followed_public_status)
+      expect(results).to_not include(followed_public_status)
     end
 
     it 'does not include direct statuses not mentioning recipient from followed' do
-      expect(@results).to_not include(@followed_direct_status)
+      expect(results).to_not include(followed_direct_status)
     end
 
     it 'does not include direct statuses not mentioning recipient from non-followed' do
-      expect(@results).to_not include(@not_followed_direct_status)
+      expect(results).to_not include(not_followed_direct_status)
     end
 
     it 'includes direct statuses mentioning recipient from followed' do
-      Fabricate(:mention, account: account, status: @followed_direct_status)
+      Fabricate(:mention, account: account, status: followed_direct_status)
       results2 = Status.as_direct_timeline(account)
-      expect(results2).to include(@followed_direct_status)
+      expect(results2).to include(followed_direct_status)
     end
 
     it 'includes direct statuses mentioning recipient from non-followed' do
-      Fabricate(:mention, account: account, status: @not_followed_direct_status)
+      Fabricate(:mention, account: account, status: not_followed_direct_status)
       results2 = Status.as_direct_timeline(account)
-      expect(results2).to include(@not_followed_direct_status)
+      expect(results2).to include(not_followed_direct_status)
     end
   end
 
diff --git a/spec/models/tag_feed_spec.rb b/spec/models/tag_feed_spec.rb
index b961481c8..d8683b86f 100644
--- a/spec/models/tag_feed_spec.rb
+++ b/spec/models/tag_feed_spec.rb
@@ -67,7 +67,7 @@ describe TagFeed, type: :service do
       expect(results).to include(status)
     end
 
-    context 'on a local-only status' do
+    context 'when the feed contains a local-only status' do
       let!(:status) { Fabricate(:status, tags: [tag1], local_only: true) }
 
       it 'does not show local-only statuses without a viewer' do
diff --git a/spec/policies/status_policy_spec.rb b/spec/policies/status_policy_spec.rb
index 9a30aef3c..38b9c4fdb 100644
--- a/spec/policies/status_policy_spec.rb
+++ b/spec/policies/status_policy_spec.rb
@@ -83,14 +83,14 @@ RSpec.describe StatusPolicy, type: :model do
     end
 
     it 'denies access when local-only and the viewer is not logged in' do
-      allow(status).to receive(:local_only?) { true }
+      allow(status).to receive(:local_only?).and_return(true)
 
       expect(subject).to_not permit(nil, status)
     end
 
     it 'denies access when local-only and the viewer is from another domain' do
       viewer = Fabricate(:account, domain: 'remote-domain')
-      allow(status).to receive(:local_only?) { true }
+      allow(status).to receive(:local_only?).and_return(true)
       expect(subject).to_not permit(viewer, status)
     end
   end
diff --git a/spec/services/notify_service_spec.rb b/spec/services/notify_service_spec.rb
index 4d66f255c..616a7aa20 100644
--- a/spec/services/notify_service_spec.rb
+++ b/spec/services/notify_service_spec.rb
@@ -48,7 +48,7 @@ RSpec.describe NotifyService, type: :service do
     recipient.suspend!
     expect { subject }.to_not change(Notification, :count)
   end
-  
+
   context 'for direct messages' do
     let(:activity) { Fabricate(:mention, account: recipient, status: Fabricate(:status, account: sender, visibility: :direct)) }
     let(:type)     { :mention }
diff --git a/spec/validators/status_length_validator_spec.rb b/spec/validators/status_length_validator_spec.rb
index 2cd369335..7e06b9bd9 100644
--- a/spec/validators/status_length_validator_spec.rb
+++ b/spec/validators/status_length_validator_spec.rb
@@ -65,7 +65,7 @@ describe StatusLengthValidator do
     it 'counts only the front part of remote usernames' do
       username = '@alice'
       chars = StatusLengthValidator::MAX_CHARS - 1 - username.length
-      text   = ('a' * 475) + " #{username}@#{'b' * 30}.com"
+      text   = ('a' * chars) + " #{username}@#{'b' * 30}.com"
       status = double(spoiler_text: '', text: text, errors: double(add: nil), local?: true, reblog?: false)
 
       subject.validate(status)