Class: Spec::Matchers::MatcherDSL
Class Method Summary
collapse
#request_to, #resource, #url
#build_request, #check_request_for_route, #delete, #describe_input, #describe_request, #dispatch_request, #dispatch_to, #dispatch_with_basic_authentication_to, #fake_request, #get, #merge_controller_and_action, #mock_request, #post, #put, #requesting, #response_for, #status_code, #with_cookies
#request
Class Method Details
.expected_value(&block) ⇒ Object
120
121
122
123
124
125
126
|
# File 'lib/merb-core/test/test_ext/rspec.rb', line 120
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
|
.failure_message(&block) ⇒ Object
136
137
138
139
140
141
142
|
# File 'lib/merb-core/test/test_ext/rspec.rb', line 136
def self.failure_message(&block)
define_method(:proxy_failure_message, &block)
define_method(:failure_message) do
proxy_failure_message(@object, @expected_value)
end
end
|
.matches(&block) ⇒ Object
107
108
109
110
111
112
113
114
115
116
117
118
|
# File 'lib/merb-core/test/test_ext/rspec.rb', line 107
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
|
.message(&block) ⇒ Object
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
|
# File 'lib/merb-core/test/test_ext/rspec.rb', line 144
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
|
.negative_failure_message(&block) ⇒ Object
128
129
130
131
132
133
134
|
# File 'lib/merb-core/test/test_ext/rspec.rb', line 128
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
|