class Swat::TestWorld::Base

Constants

BASE_OPTIONS
DEFAULT_OPTIONS
SITUATIONS

Attributes

options[R]

Public Class Methods

moment() click to toggle source
# File lib/swat/test_world/base.rb, line 15
def self.moment
  m = TestWorld.config.options[:moment]
  return unless m
  m.is_a?(Time) ? m : Time.parse(m.to_s)
end
new(opts = {}) click to toggle source
# File lib/swat/test_world/base.rb, line 10
def initialize(opts = {})
  @options = init_options(opts)
  init_situation
end

Public Instance Methods

after_each(example, context) click to toggle source
# File lib/swat/test_world/base.rb, line 31
def after_each(example, context)
  #can be implemented in subclass
end
before_each(example, context) click to toggle source
# File lib/swat/test_world/base.rb, line 27
def before_each(example, context)
  #can be implemented in subclass
end
moment() click to toggle source
# File lib/swat/test_world/base.rb, line 21
def moment
  self.class.moment
end
Also aliased as: now
now()
Alias for: moment

Protected Instance Methods

base_options() click to toggle source
# File lib/swat/test_world/base.rb, line 37
def base_options
  self.class::BASE_OPTIONS
end
default_options() click to toggle source
# File lib/swat/test_world/base.rb, line 41
def default_options
  self.class::DEFAULT_OPTIONS
end
init_situation() click to toggle source
# File lib/swat/test_world/base.rb, line 49
def init_situation
  raise 'method "init_situation" should be implemented in subclass'
end
situations() click to toggle source
# File lib/swat/test_world/base.rb, line 45
def situations
  self.class::SITUATIONS
end

Private Instance Methods

init_options(opts) click to toggle source
# File lib/swat/test_world/base.rb, line 55
def init_options(opts)
  res = if opts.is_a?(Hash)
    default_options.merge(opts)
  elsif opts.is_a?(Symbol)
    default_options.merge(situations[opts])
  else
    raise 'Invalid TW options passed! should be Hash or Symbol(situation identifier)'
  end
  base_options.merge res
end