Skip to content

Instantly share code, notes, and snippets.

@urbanautomaton
Created September 19, 2019 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save urbanautomaton/7b073e7a98846eaf08a6ab49fcc144d9 to your computer and use it in GitHub Desktop.
Save urbanautomaton/7b073e7a98846eaf08a6ab49fcc144d9 to your computer and use it in GitHub Desktop.
require 'spec_helper'
require 'rubocop'
require 'rubocop/rspec/cop_helper'
require 'support/rubocop/expect_offense'
require 'future_learn/cops/forbid_shoulda_matchers'
RSpec.describe RuboCop::Cop::FutureLearn::ForbidShouldaMatchers do
include CopHelper
include RuboCop::RSpec::ExpectOffense
let(:config) { RuboCop::Config.new }
subject(:cop) { described_class.new(config) }
it 'hisses at the belong_to matcher' do
expect_offense(<<~RUBY)
it { is_expected.to belong_to(:no_man) }
^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
RUBY
end
it 'hisses at the have_many matcher' do
expect_offense(<<~RUBY)
it { is_expected.to have_many(:ghastly_tongue_teeth) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
RUBY
end
it 'hisses at the have_one matcher' do
expect_offense(<<~RUBY)
it { is_expected.to have_one(:unquenchable_desire_for_havoc) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
RUBY
end
it 'hisses at the validate_presence_of matcher' do
expect_offense(<<~RUBY)
it { is_expected.to validate_presence_of(:anti_goose_protective_gear) }
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #{described_class::MSG}
RUBY
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment