Sha256: 15a248e0cd9d5b9261e01aacc77bb9caa5d6560ce7feee970939f7def796543b

Contents?: true

Size: 1.03 KB

Versions: 15

Compression:

Stored size: 1.03 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Simplabs::Excellent::Checks::NestedIteratorsCheck do

  before do
    @excellent = Simplabs::Excellent::Runner.new(Simplabs::Excellent::Checks::NestedIteratorsCheck.new)
  end

  describe '#evaluate' do

    it 'should reject a block inside a block' do
      code = <<-END
        method1 do
          method2 do
          end
        end
      END
      @excellent.check_code(code)
      warnings = @excellent.warnings

      warnings.should_not be_empty
      warnings[0].info.should        == { :block => 'block', :parent => 'block' }
      warnings[0].line_number.should == 2
      warnings[0].message.should     == 'block inside of block.'
    end

    it 'should accept 2 blocks inside a method that are not nested' do
      code = <<-END
        def method
          method1 do
          end
          method2 do
          end
        end
      END
      @excellent.check_code(code)
      warnings = @excellent.warnings

      warnings.should be_empty
    end

  end

end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
simplabs-excellent-1.2.2 spec/checks/nested_iterators_check_spec.rb
simplabs-excellent-1.3.0 spec/checks/nested_iterators_check_spec.rb
simplabs-excellent-1.3.1 spec/checks/nested_iterators_check_spec.rb
simplabs-excellent-1.4.0 spec/checks/nested_iterators_check_spec.rb
simplabs-excellent-1.4.1 spec/checks/nested_iterators_check_spec.rb
simplabs-excellent-1.4.2 spec/checks/nested_iterators_check_spec.rb
simplabs-excellent-1.5.0 spec/checks/nested_iterators_check_spec.rb
simplabs-excellent-1.5.1 spec/checks/nested_iterators_check_spec.rb
simplabs-excellent-1.5.2 spec/checks/nested_iterators_check_spec.rb
simplabs-excellent-1.5.3 spec/checks/nested_iterators_check_spec.rb
excellent-1.7.2 spec/checks/nested_iterators_check_spec.rb
excellent-1.7.1 spec/checks/nested_iterators_check_spec.rb
excellent-1.7.0 spec/checks/nested_iterators_check_spec.rb
excellent-1.6.0 spec/checks/nested_iterators_check_spec.rb
excellent-1.5.4 spec/checks/nested_iterators_check_spec.rb