Sha256: 4e96cc1aacd3f9ed0786d733c3485726f491346b3d3e8181280de30394420f64

Contents?: true

Size: 807 Bytes

Versions: 2

Compression:

Stored size: 807 Bytes

Contents

if Rails.env.test?
  require 'rspec/expectations'

  # Validate the subject's class did call "acts_as_paranoid"
  RSpec::Matchers.define :act_as_paranoid do
    match { |subject| subject.class.ancestors.include?(Paranoia) }

    failure_message_proc = lambda do
      "expected #{subject.class} to use `acts_as_paranoid`"
    end

    failure_message_when_negated_proc = lambda do
      "expected #{subject.class} not to use `acts_as_paranoid`"
    end

    if respond_to?(:failure_message_when_negated)
      failure_message(&failure_message_proc)
      failure_message_when_negated(&failure_message_when_negated_proc)
    else
      # RSpec 2 compatibility:
      failure_message_for_should(&failure_message_proc)
      failure_message_for_should_not(&failure_message_when_negated_proc)
    end
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
paranoia-2.5.2 lib/paranoia/rspec.rb
paranoia-2.5.1 lib/paranoia/rspec.rb