Sha256: 26f0655f770a6787d3a96f56e81c21cdc1e289b8f2ebba5e0f4fa83ee52f47be

Contents?: true

Size: 1.02 KB

Versions: 6

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

6 entries across 6 versions & 1 rubygems

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