Sha256: 0bc664e2895034d04bce7c232f60e36ff33227c8340236deec88f8689ffbacd9

Contents?: true

Size: 547 Bytes

Versions: 1

Compression:

Stored size: 547 Bytes

Contents

# http://solnic.eu/2011/01/14/custom-rspec-2-matchers.html
RSpec::Matchers.define :have_reader do |attribute|
  match do |model|
    model.respond_to?(attribute)
  end

  failure_message_for_should do |model|
    if @message
      "Validation errors #{model.errors[attribute].inspect} should include #{@message.inspect}"
    else
      "#{model.class} should have attribute reader #{attribute.inspect}"
    end
  end

  failure_message_for_should_not do |model|
    "#{model.class} should not have attribute reader #{attribute.inspect}"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
circuit-0.2.0 spec/support/matchers/have_reader_matcher.rb