Module: MotionSpec
- Defined in:
- lib/motion-spec/core.rb,
lib/motion-spec/error.rb,
lib/motion-spec/should.rb,
lib/motion-spec/context.rb,
lib/motion-spec/version.rb,
lib/motion-spec/platform.rb,
lib/motion-spec/matcher/be.rb,
lib/motion-spec/matcher/eq.rb,
lib/motion-spec/mock/mocks.rb,
lib/motion-spec/mock/stubs.rb,
lib/motion-spec/output/tap.rb,
lib/motion-spec/expectation.rb,
lib/motion-spec/matcher/eql.rb,
lib/motion-spec/output/fast.rb,
lib/motion-spec/matcher/be_a.rb,
lib/motion-spec/output/knock.rb,
lib/motion-spec/matcher/match.rb,
lib/motion-spec/specification.rb,
lib/motion-spec/matcher/be_nil.rb,
lib/motion-spec/matcher/change.rb,
lib/motion-spec/matcher/be_true.rb,
lib/motion-spec/matcher/include.rb,
lib/motion-spec/matcher/satisfy.rb,
lib/motion-spec/output/spec_dox.rb,
lib/motion-spec/matcher/be_false.rb,
lib/motion-spec/matcher/end_with.rb,
lib/motion-spec/output/colorized.rb,
lib/motion-spec/output/ruby_mine.rb,
lib/motion-spec/output/test_unit.rb,
lib/motion-spec/matcher/be_within.rb,
lib/motion-spec/matcher/be_generic.rb,
lib/motion-spec/matcher/have_items.rb,
lib/motion-spec/matcher/respond_to.rb,
lib/motion-spec/matcher/start_with.rb,
lib/motion-spec/matcher/match_array.rb,
lib/motion-spec/matcher/raise_error.rb,
lib/motion-spec/matcher/have_generic.rb,
lib/motion-spec/context_helper/should.rb,
lib/motion-spec/fail_message_renderer.rb,
lib/motion-spec/matcher/single_method.rb,
lib/motion-spec/context_helper/matchers.rb,
lib/motion-spec/context_helper/expectation.rb,
lib/motion-spec/context_helper/memoized_helpers.rb
Overview
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
Defined Under Namespace
Modules: ColorizedOutput, ContextHelper, FastOutput, KnockOutput, Matcher, RubyMineOutput, SpecDoxOutput, TapOutput, TestUnitOutput
Classes: Context, Error, Expectation, FailMessageRenderer, FailedExpectation, InvalidMatcher, Mocks, Platform, Should, Specification, Stubs
Constant Summary
collapse
- DEFAULT_OUTPUT_MODULE =
SpecDoxOutput
- Counter =
Hash.new(0)
- ErrorLog =
''
- Shared =
Hash.new do |_, name|
fail NameError, "no such context: #{name.inspect}"
end
- RestrictName =
//
- RestrictContext =
//
- Backtraces =
true
- Outputs =
{
'spec_dox' => SpecDoxOutput,
'fast' => FastOutput,
'test_unit' => TestUnitOutput,
'tap' => TapOutput,
'knock' => KnockOutput,
'rubymine' => RubyMineOutput,
'colorized' => ColorizedOutput
}
- VERSION =
'0.6.0'
Class Method Summary
collapse
Class Method Details
.add_context(context) ⇒ Object
29
30
31
|
# File 'lib/motion-spec/core.rb', line 29
def self.add_context(context)
(@contexts ||= []) << context
end
|
.context_did_finish(_context) ⇒ Object
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/motion-spec/core.rb', line 77
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 ⇒ Object
37
38
39
|
# File 'lib/motion-spec/core.rb', line 37
def self.current_context
@contexts[current_context_index]
end
|
.current_context_index ⇒ Object
33
34
35
|
# File 'lib/motion-spec/core.rb', line 33
def self.current_context_index
@current_context_index ||= 0
end
|
.execute_context(context) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/motion-spec/core.rb', line 60
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 ⇒ Object
73
74
75
|
# File 'lib/motion-spec/core.rb', line 73
def self.main_activity
@main_activity
end
|
.run(arg = nil) ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/motion-spec/core.rb', line 41
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
|