module Appydays::SpecHelpers

Public Instance Methods

trunc_time(t) click to toggle source

Zero out nsecs to t can be compared to one from the database.

# File lib/appydays/spec_helpers.rb, line 13
                def trunc_time(t)
  return t.change(nsec: t.usec * 1000)
end

Matchers

↑ top

Public Instance Methods

have_a_line_matching(regexp) click to toggle source

RSpec matcher – set up the expectation that the lefthand side is Enumerable, and that at least one of the objects yielded while iterating matches regexp when converted to a String.

# File lib/appydays/spec_helpers.rb, line 49
                def have_a_line_matching(regexp)
  return HaveALineMatching.new(regexp)
end
have_length(x) click to toggle source
# File lib/appydays/spec_helpers.rb, line 53
                def have_length(x)
  return RSpec::Matchers::BuiltIn::HaveAttributes.new(length: x)
end
money(s) click to toggle source
# File lib/appydays/spec_helpers.rb, line 97
def money(s)
  return Monetize.parse(s) if s.is_a?(String)
  return s if s.is_a?(Money)
  return Money.new(s) if s.is_a?(Integer)
  return Money.new(s[:cents], s[:currency]) if s.respond_to?(:key?) && s.key?(:cents) && s.key?(:currency)
  raise "#{s} type #{s.class.name} not convertable to Money (add support or use supported type)"
end
time(s) click to toggle source
# File lib/appydays/spec_helpers.rb, line 77
def time(s)
  return Time.parse(s) if s.is_a?(String)
  return s.to_time
end