Sha256: 6331217a0871b1c23abf600bc836ed6261e721d53994adb91621e9df46af2006

Contents?: true

Size: 645 Bytes

Versions: 6

Compression:

Stored size: 645 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Rails::ScopeArgs do
  subject(:cop) { described_class.new }

  it 'registers an offense a scope with a method arg' do
    inspect_source(cop,
                   ['scope :active, where(active: true)'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'accepts a lambda arg' do
    inspect_source(cop,
                   ['scope :active, -> { where(active: true) }'])
    expect(cop.offenses).to be_empty
  end

  it 'accepts a proc arg' do
    inspect_source(cop,
                   ['scope :active, proc { where(active: true) }'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/rails/scope_args_spec.rb
rubocop-0.21.0 spec/rubocop/cop/rails/scope_args_spec.rb
rubocop-0.20.1 spec/rubocop/cop/rails/scope_args_spec.rb
rubocop-0.20.0 spec/rubocop/cop/rails/scope_args_spec.rb
rubocop-0.19.1 spec/rubocop/cop/rails/scope_args_spec.rb
rubocop-0.19.0 spec/rubocop/cop/rails/scope_args_spec.rb