Class Spec::Expectations::Should::Base
In: lib/spec/expectations/diff.rb
lib/spec/expectations/should/base.rb
Parent: Object

Methods

External Aliases

default_message -> old_default_message

Public Class methods

[Source]

    # File lib/spec/expectations/diff.rb, line 8
 8:         def self.differ=(differ)
 9:           @@differ = differ
10:         end

Public Instance methods

[Source]

   # File lib/spec/expectations/should/base.rb, line 6
6:         def <(expected)
7:           __delegate_method_missing_to_target "<", "<", expected
8:         end

[Source]

    # File lib/spec/expectations/should/base.rb, line 10
10:         def <=(expected)
11:           __delegate_method_missing_to_target "<=", "<=", expected
12:         end

[Source]

    # File lib/spec/expectations/should/base.rb, line 14
14:         def ==(expected)
15:           __delegate_method_missing_to_target "==", "==", expected
16:         end

[Source]

    # File lib/spec/expectations/should/base.rb, line 18
18:         def =~(expected)
19:           __delegate_method_missing_to_target "=~", "=~", expected
20:         end

[Source]

    # File lib/spec/expectations/should/base.rb, line 26
26:         def >(expected)
27:           __delegate_method_missing_to_target ">", ">", expected
28:         end

[Source]

    # File lib/spec/expectations/should/base.rb, line 22
22:         def >=(expected)
23:           __delegate_method_missing_to_target ">=", ">=", expected
24:         end

[Source]

    # File lib/spec/expectations/should/base.rb, line 30
30:         def default_message(expectation, expected=nil)
31:           Spec::Expectations.build_message(@target, expectation, expected)
32:          end

[Source]

    # File lib/spec/expectations/diff.rb, line 13
13:         def default_message(expectation, expected=:no_expectation_specified)
14:           result = old_default_message(expectation, expected)
15:           if expected != :no_expectation_specified
16:             if expected.is_a?(String)
17:               result << "\nDiff:" << @@differ.diff_as_string(@target.to_s, expected) unless @@differ.nil?
18:             elsif ! @target.is_a? Proc
19:               result << "\nDiff:" << @@differ.diff_as_object(@target, expected) unless @@differ.nil?
20:             end
21:           end
22: 
23:           result
24:         end

[Source]

    # File lib/spec/expectations/should/base.rb, line 34
34:         def fail_with_message(message)
35:           Spec::Expectations.fail_with(message)
36:         end

[Source]

    # File lib/spec/expectations/should/base.rb, line 38
38:         def find_supported_sym(original_sym)
39:           ["#{original_sym}?", "#{original_sym}s?"].each do |alternate_sym|
40:             return alternate_sym.to_s if @target.respond_to?(alternate_sym.to_s)
41:           end
42:           return ["<","<=",">=",">","==","=~"].include?(original_sym) ? original_sym : "#{original_sym}?"
43:         end

[Source]

    # File lib/spec/expectations/should/base.rb, line 45
45:         def method_missing(original_sym, *args, &block)
46:           if original_sym.to_s =~ /^not_/
47:             return Not.new(@target).__send__(original_sym.to_s[4..-1].to_sym, *args, &block)
48:           end
49:           if original_sym.to_s =~ /^be_/
50:             @be_seen = true
51:             return __send__(original_sym.to_s[3..-1].to_sym, *args, &block)
52:           end
53:           if original_sym.to_s =~ /^have_/
54:             return have.__send__(original_sym.to_s[5..-1].to_sym, *args, &block)
55:           end
56:           __delegate_method_missing_to_target original_sym, find_supported_sym(original_sym), *args
57:         end

[Validate]