Sha256: d3b596dd674a3f645f68e42c794bea4f8907b8693fcfb4750764738a9ca37631

Contents?: true

Size: 773 Bytes

Versions: 5

Compression:

Stored size: 773 Bytes

Contents

RSpec::Matchers.define :convert do |*from|
  from_description = from
  from_description = nil if from.empty?
  from_description = from.first if from.size == 1
  
  diffable

  define_method :actual do
    @real_actual ||= @actual.call(*from)
  end

  def expected
    [@to]
  end

  match do |method|
    actual == @to
  end

  description do
    "convert #{from_description.inspect} to #{@to.inspect}"
  end

  failure_message_for_should do |method|
    <<MESSAGE
expected #{from_description.inspect}
      to #{@to.inspect}
     got #{actual.inspect}
MESSAGE
  end

  failure_message_for_should_not do |method|
    <<MESSAGE
expected #{from_description.inspect}
  not to #{@to.inspect}
     got #{actual.inspect}
MESSAGE
  end

  chain :to do |to|
    @to = to
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
wikilink-converter-0.2.4 spec/support/matchers.rb
wikilink-converter-0.2.3 spec/support/matchers.rb
wikilink-converter-0.2.2 spec/support/matchers.rb
wikilink-converter-0.2.1 spec/support/matchers.rb
wikilink-converter-0.1.0 spec/support/matchers.rb