Sha256: e5ce31324e75e980611894d06d11219125784d8e1dd280adb08ec4ec0ffd19a2

Contents?: true

Size: 742 Bytes

Versions: 4

Compression:

Stored size: 742 Bytes

Contents

RSpec::Matchers.define :enclose_scope do |expected_scope|
  chain(:under) do |scope_variants|
    @external_scope_variants = scope_variants
  end

  match do |actual|
    @result = true
    @external_scope_variants.each do |external_scope_variant|
      dsl(external_scope_variant || scopes[:config]) do |c|
        @result &= !c.send(:current_scope?, expected_scope)
        c.send(expected_scope, :foo) do
          @result &= c.send(:current_scope?, expected_scope)
        end
        @result &= !c.send(:current_scope?, expected_scope)
      end
    end
    @result
  end

  description do
    msg = "enclose scope #{expected_scope}"
    msg += " under #{@external_scope_variants.inspect}" if @external_scope_variants
    msg
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
taketo-0.3.1 spec/support/matchers/enclose_scope_matcher.rb
taketo-0.3.0 spec/support/matchers/enclose_scope_matcher.rb
taketo-0.2.0 spec/support/matchers/enclose_scope_matcher.rb
taketo-0.2.0.alpha spec/support/matchers/enclose_scope_matcher.rb