Sha256: a52fa71416c88ea56dd3080d9a52f32cc58344e437b0958d9cd33a32a3d27967

Contents?: true

Size: 1.05 KB

Versions: 1

Compression:

Stored size: 1.05 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
      content = <<-END
        method1 do
          method2 do
          end
        end
      END
      @excellent.check_content(content)
      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
      content = <<-END
        def method
          method1 do
          end
          method2 do
          end
        end
      END
      @excellent.check_content(content)
      warnings = @excellent.warnings

      warnings.should be_empty
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
simplabs-excellent-1.2.1 spec/checks/nested_iterators_check_spec.rb