module MotionSpec

MotionSpec is built off of MacBacon, which is derived from Bacon, which is a micro-port of Rspec. See the LICENSE for core contributors and copyright years

Constants

Backtraces
Counter
DEFAULT_OUTPUT_MODULE
ErrorLog
Outputs
RestrictContext
RestrictName
Shared
VERSION

Public Class Methods

add_context(context) click to toggle source
# File lib/motion-spec/core.rb, line 28
def self.add_context(context)
  (@contexts ||= []) << context
end
context_did_finish(_context) click to toggle source
# File lib/motion-spec/core.rb, line 76
def self.context_did_finish(_context)
  return if Platform.android?

  handle_specification_end

  Counter[:context_depth] -= 1

  if (@current_context_index + 1) < @contexts.size
    @current_context_index += 1
    return run
  end

  handle_summary
  exit(Counter.values_at(:failed, :errors).inject(:+))
end
current_context() click to toggle source
# File lib/motion-spec/core.rb, line 36
def self.current_context
  @contexts[current_context_index]
end
current_context_index() click to toggle source
# File lib/motion-spec/core.rb, line 32
def self.current_context_index
  @current_context_index ||= 0
end
execute_context(context) click to toggle source
# File lib/motion-spec/core.rb, line 59
def self.execute_context(context)
  unless respond_to?(:handle_specification_begin)
    extend(Outputs[ENV['output']] || DEFAULT_OUTPUT_MODULE)
  end

  Counter[:context_depth] += 1
  handle_specification_begin(context.name)
  context.run
  handle_specification_end
  Counter[:context_depth] -= 1
end
main_activity() click to toggle source

Android-only.

# File lib/motion-spec/core.rb, line 72
def self.main_activity
  @main_activity
end
run(arg = nil) click to toggle source
# File lib/motion-spec/core.rb, line 40
def self.run(arg = nil)
  unless respond_to?(:handle_specification_begin)
    extend(Outputs[ENV['output']] || DEFAULT_OUTPUT_MODULE)
  end

  @timer ||= Time.now

  if Platform.android?
    @main_activity ||= arg

    @contexts.each { |context| execute_context(context) }
    return handle_summary
  end

  Counter[:context_depth] += 1
  handle_specification_begin(current_context.name)
  current_context.performSelector('run', withObject: nil, afterDelay: 0)
end