File: rspec.rb

package info (click to toggle)
ruby-paranoia 3.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 164 kB
  • sloc: ruby: 399; makefile: 6
file content (26 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if defined?(RSpec)
  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