Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom Cop spec
# frozen_string_literal: true
require 'rails_helper'
require 'rubocop'
require 'rubocop/rspec/support'
require_relative '../../config/rubocop/custom_cops/use_save_bang_on_test'
describe CustomCops::UseSaveBangOnTest do
include RuboCop::RSpec::ExpectOffense
let(:cop) { described_class.new }
it do
inspect_source('hoge.save')
expect(cop.offenses.size).to eq(1)
end
it do
inspect_source('piyo.update(fuga: true)')
expect(cop.offenses.size).to eq(1)
end
it do
inspect_source('piyo.update!')
expect(cop.offenses.size).to eq(0)
end
it do
inspect_source('hoge.save!')
expect(cop.offenses.size).to eq(0)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment