Class: Spec::Matchers::MatcherDSL

Inherits:
Object
  • Object
show all
Includes:
Merb::Test::RouteHelper
Defined in:
merb-core/lib/merb-core/test/test_ext/rspec.rb

Class Method Summary (collapse)

Methods included from Merb::Test::RouteHelper

#request_to, #resource, #url

Methods included from Merb::Test::RequestHelper

#build_request, #check_request_for_route, #describe_input, #describe_request, #dispatch_request, #dispatch_to, #dispatch_with_basic_authentication_to, #fake_request, #merge_controller_and_action, #mock_request, #status_code, #with_cookies

Class Method Details

+ (Object) expected_value(&block)



78
79
80
81
82
83
84
# File 'merb-core/lib/merb-core/test/test_ext/rspec.rb', line 78

def self.expected_value(&block)
  define_method(:transform_expected, &block)

  define_method(:initialize) do |expected_value|
    @expected_value = transform_expected(expected_value) || expected_value
  end
end

+ (Object) failure_message(&block)



94
95
96
97
98
99
100
# File 'merb-core/lib/merb-core/test/test_ext/rspec.rb', line 94

def self.failure_message(&block)
  define_method(:proxy_failure_message, &block)

  define_method(:failure_message) do
    proxy_failure_message(@object, @expected_value)
  end
end

+ (Object) matches(&block)



65
66
67
68
69
70
71
72
73
74
75
76
# File 'merb-core/lib/merb-core/test/test_ext/rspec.rb', line 65

def self.matches(&block)
  define_method(:matches_proxy, &block)

  define_method(:matches?) do |object|
    @object = object
    if block.arity == 2
      matches_proxy(@object, @expected_value)
    else
      matches_proxy(@object)
    end
  end
end

+ (Object) message(&block)



102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'merb-core/lib/merb-core/test/test_ext/rspec.rb', line 102

def self.message(&block)
  class_eval do
    def failure_message
      generic_message(@object, @expected_value, nil)
    end

    def negative_failure_message
      generic_message(@object, @expected_value, " not")
    end
  end

  define_method(:proxy_generic_message, &block)

  ar = block.arity

  define_method(:generic_message) do |object, expected, not_string|
    if ar == 3
      proxy_generic_message(not_string, object, expected)
    else
      proxy_generic_message(not_string, object)
    end
  end
end

+ (Object) negative_failure_message(&block)



86
87
88
89
90
91
92
# File 'merb-core/lib/merb-core/test/test_ext/rspec.rb', line 86

def self.negative_failure_message(&block)
  define_method(:proxy_negative_failure_message, &block)

  define_method(:negative_failure_message) do
    proxy_negative_failure_message(@object, @expected_value)
  end
end