Class: Rcodetools::XMPExpectationsFilter
Constant Summary
Constants inherited
from XMPFilter
Rcodetools::XMPFilter::INITIALIZE_OPTS, Rcodetools::XMPFilter::INTERPRETER_FORK, Rcodetools::XMPFilter::INTERPRETER_RBTEST, Rcodetools::XMPFilter::INTERPRETER_RUBY, Rcodetools::XMPFilter::MARKER, Rcodetools::XMPFilter::MULTI_LINE_RE, Rcodetools::XMPFilter::SINGLE_LINE_RE, Rcodetools::XMPFilter::VAR, Rcodetools::XMPFilter::VERSION, Rcodetools::XMPFilter::WARNING_RE, Rcodetools::XMPFilter::XMP_RE
Instance Method Summary
collapse
Methods inherited from XMPFilter
#add_markers, #annotate, #annotated_line, #annotated_multi_line, #common_path, #debugprint, detect_rbtest, #execute, #execute_popen, #execute_ruby, #execute_script, #execute_tmpfile, #extract_data, #final_decoration, #get_test_method_from_lineno, #initialize_for_test_script, #initialize_rbtest, #initialize_rct_fork, #interpreter_command, #oneline_ize, #prepare_line_annotation, run, #windows?
Constructor Details
Returns a new instance of XMPExpectationsFilter.
273
274
275
276
|
# File 'lib/rcodetools/xmptestunitfilter.rb', line 273
def initialize(x={})
super(x.merge(:_no_extend_module => true))
@warnings = false
end
|
Instance Method Details
#expectation(expected, actual) ⇒ Object
Also known as:
equal_assertion
278
279
280
281
282
283
284
|
# File 'lib/rcodetools/xmptestunitfilter.rb', line 278
def expectation(expected, actual)
<<EOE
expect #{expected} do
#{actual}
end
EOE
end
|
#nil_assertion(expression) ⇒ Object
291
292
293
|
# File 'lib/rcodetools/xmptestunitfilter.rb', line 291
def nil_assertion(expression)
[ expectation("nil", expression) ]
end
|
#object_assertions(klass_txt, value_txt, expression) ⇒ Object
308
309
310
311
|
# File 'lib/rcodetools/xmptestunitfilter.rb', line 308
def object_assertions(klass_txt, value_txt, expression)
[ expectation(klass_txt, expression),
expectation(value_txt.inspect, "#{expression}.inspect") ]
end
|
#raise_assertion(expression, exceptions, index) ⇒ Object
287
288
289
|
# File 'lib/rcodetools/xmptestunitfilter.rb', line 287
def raise_assertion(expression, exceptions, index)
[ expectation(exceptions[index][0], expression) ]
end
|
#value_assertions(klass_txt, value_txt, value, expression) ⇒ Object
295
296
297
298
299
300
301
302
303
304
305
306
|
# File 'lib/rcodetools/xmptestunitfilter.rb', line 295
def value_assertions(klass_txt, value_txt, value, expression)
case value
when Float
min = "%.4f" % [value - FLOAT_TOLERANCE]
max = "%.4f" % [value + FLOAT_TOLERANCE]
[ expectation("#{min}..#{max}", expression) ]
when Numeric, String, Hash, Array, Regexp, TrueClass, FalseClass, Symbol, NilClass
[ expectation(value_txt, expression) ]
else
object_assertions klass_txt, value_txt, expression
end
end
|