Sha256: 377d77bd1948be809fa9182dafd05c49a6f8792a3531a3ee34c2de63ba876a97

Contents?: true

Size: 762 Bytes

Versions: 7

Compression:

Stored size: 762 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe RuboCop::Cop::Rails::Validation do
  subject(:cop) { described_class.new }

  described_class::BLACKLIST.each_with_index do |validation, number|
    it "registers an offense for #{validation}" do
      inspect_source(cop,
                     ["#{validation} :name"])
      expect(cop.offenses.size).to eq(1)
    end

    it "outputs the correct message for #{validation}" do
      inspect_source(cop,
                     ["#{validation} :name"])
      expect(cop.offenses.first.message)
        .to include(described_class::WHITELIST[number])
    end
  end

  it 'accepts new style validations' do
    inspect_source(cop,
                   ['validates :name'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/rails/validation_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/rails/validation_spec.rb
rubocop-0.28.0 spec/rubocop/cop/rails/validation_spec.rb
rubocop-0.27.1 spec/rubocop/cop/rails/validation_spec.rb
rubocop-0.27.0 spec/rubocop/cop/rails/validation_spec.rb
rubocop-0.26.1 spec/rubocop/cop/rails/validation_spec.rb
rubocop-0.26.0 spec/rubocop/cop/rails/validation_spec.rb