Sha256: fe432e318db420bd0f1e903e4dfb231dabed68ac680514ebc2b77730e2cdc872

Contents?: true

Size: 886 Bytes

Versions: 26

Compression:

Stored size: 886 Bytes

Contents

require 'rspec/expectations'

RSpec::Matchers.define :be_successful do
  match do |actual|
    actual.success? &&
      actual.messages.empty?
  end

  failure_message do |actual|
    "expected that #{actual.inspect} would be successful"
  end

  failure_message_when_negated do |actual|
    "expected that #{actual.inspect} would NOT be successful"
  end
end

RSpec::Matchers.define :be_failing do |messages|
  match do |actual|
    messages = case messages
               when Hash
                 messages
               else
                 Array(messages)
               end

    !actual.success? &&
      actual.messages.fetch(:foo) == messages
  end

  failure_message do |actual|
    "expected that #{actual.inspect} would be failing (#{messages.inspect})"
  end

  failure_message_when_negated do |actual|
    "expected that #{actual.inspect} would NOT be failing"
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
dry-validation-0.9.4 spec/support/matchers.rb
dry-validation-0.9.3 spec/support/matchers.rb
dry-validation-0.9.2 spec/support/matchers.rb
dry-validation-0.9.1 spec/support/matchers.rb
dry-validation-0.9.0 spec/support/matchers.rb
dry-validation-0.8.0 spec/support/matchers.rb