Sha256: c2237238433e3c37e37c636443459462ebbaae597c5a8cbfdb786caf78d2dc1a

Contents?: true

Size: 1.02 KB

Versions: 11

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  it 'registers an offense for default scope with a lambda arg' do
    inspect_source(cop,
                   ['default_scope -> { something }'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'registers an offense for default scope with a proc arg' do
    inspect_source(cop,
                   ['default_scope proc { something }'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'registers an offense for default scope with a proc(Proc.new) arg' do
    inspect_source(cop,
                   ['default_scope Proc.new { something }'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'registers an offense for non blocks' do
    inspect_source(cop,
                   ['default_scope order: "position"'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'accepts a block arg' do
    inspect_source(cop,
                   ['default_scope { something }'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/rails/default_scope_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/rails/default_scope_spec.rb
rubocop-0.28.0 spec/rubocop/cop/rails/default_scope_spec.rb
rubocop-0.27.1 spec/rubocop/cop/rails/default_scope_spec.rb
rubocop-0.27.0 spec/rubocop/cop/rails/default_scope_spec.rb
rubocop-0.26.1 spec/rubocop/cop/rails/default_scope_spec.rb
rubocop-0.26.0 spec/rubocop/cop/rails/default_scope_spec.rb
rubocop-0.25.0 spec/rubocop/cop/rails/default_scope_spec.rb
rubocop-0.24.1 spec/rubocop/cop/rails/default_scope_spec.rb
rubocop-0.24.0 spec/rubocop/cop/rails/default_scope_spec.rb
rubocop-0.23.0 spec/rubocop/cop/rails/default_scope_spec.rb