File: failure_message.rb

package info (click to toggle)
ruby-i18n-spec 0.6.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 224 kB
  • sloc: ruby: 478; makefile: 3
file content (23 lines) | stat: -rw-r--r-- 613 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module I18nSpec
  module FailureMessage
    def failure_for_should(&block)
      if respond_to?(:failure_message)
        # Rspec 3
        failure_message { |f| instance_exec(f, &block) }
      else
        # Rspec 2
        failure_message_for_should { |f| instance_exec(f, &block) }
      end
    end

    def failure_for_should_not(&block)
      if respond_to?(:failure_message_when_negated)
        # Rspec 3
        failure_message_when_negated { |f| instance_exec(f, &block) }
      else
        # Rspec 2
        failure_message_for_should_not { |f| instance_exec(f, &block) }
      end
    end
  end
end