Module: Rcodetools::XMPRSpecFilter::OldAPI::WithParentheses

Defined in:
lib/rcodetools/xmptestunitfilter.rb

Instance Method Summary collapse

Instance Method Details

#equal_assertion(expected, actual) ⇒ Object



237
238
239
# File 'lib/rcodetools/xmptestunitfilter.rb', line 237

def equal_assertion(expected, actual)
  "(#{actual}).should_equal(#{expected})"
end

#nil_assertion(expression) ⇒ Object



217
218
219
# File 'lib/rcodetools/xmptestunitfilter.rb', line 217

def nil_assertion(expression)
  ["(#{expression}).should_be_nil"]
end

#object_assertions(klass_txt, value_txt, expression) ⇒ Object



232
233
234
235
# File 'lib/rcodetools/xmptestunitfilter.rb', line 232

def object_assertions(klass_txt, value_txt, expression)
  [ "(#{expression}).should_be_a_kind_of(#{klass_txt})",
    "(#{expression}.inspect).should_equal(#{value_txt.inspect})" ]
end

#value_assertions(klass_txt, value_txt, value, expression) ⇒ Object



221
222
223
224
225
226
227
228
229
230
# File 'lib/rcodetools/xmptestunitfilter.rb', line 221

def value_assertions(klass_txt, value_txt, value, expression)
  case value
  when Float
    ["(#{expression}).should_be_close(#{value.inspect}, #{FLOAT_TOLERANCE})"]
  when Numeric, String, Hash, Array, Regexp, TrueClass, FalseClass, Symbol, NilClass
    ["(#{expression}).should_equal(#{value_txt})"]
  else
    object_assertions klass_txt, value_txt, expression
  end
end