micronaut 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +15 -0
- data/LICENSE +45 -0
- data/README.markdown +66 -0
- data/RSPEC-LICENSE +23 -0
- data/Rakefile +78 -0
- data/VERSION.yml +4 -0
- data/bin/micronaut +4 -0
- data/examples/example_helper.rb +54 -0
- data/examples/lib/micronaut/behaviour_example.rb +351 -0
- data/examples/lib/micronaut/configuration_example.rb +133 -0
- data/examples/lib/micronaut/example_example.rb +67 -0
- data/examples/lib/micronaut/expectations/extensions/object_example.rb +146 -0
- data/examples/lib/micronaut/expectations/fail_with_example.rb +17 -0
- data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +27 -0
- data/examples/lib/micronaut/formatters/base_formatter_example.rb +117 -0
- data/examples/lib/micronaut/formatters/documentation_formatter_example.rb +5 -0
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +29 -0
- data/examples/lib/micronaut/kernel_extensions_example.rb +13 -0
- data/examples/lib/micronaut/matchers/be_close_example.rb +52 -0
- data/examples/lib/micronaut/matchers/be_example.rb +298 -0
- data/examples/lib/micronaut/matchers/change_example.rb +360 -0
- data/examples/lib/micronaut/matchers/description_generation_example.rb +175 -0
- data/examples/lib/micronaut/matchers/eql_example.rb +35 -0
- data/examples/lib/micronaut/matchers/equal_example.rb +35 -0
- data/examples/lib/micronaut/matchers/has_example.rb +69 -0
- data/examples/lib/micronaut/matchers/have_example.rb +392 -0
- data/examples/lib/micronaut/matchers/include_example.rb +103 -0
- data/examples/lib/micronaut/matchers/match_example.rb +43 -0
- data/examples/lib/micronaut/matchers/matcher_methods_example.rb +78 -0
- data/examples/lib/micronaut/matchers/operator_matcher_example.rb +193 -0
- data/examples/lib/micronaut/matchers/raise_error_example.rb +348 -0
- data/examples/lib/micronaut/matchers/respond_to_example.rb +54 -0
- data/examples/lib/micronaut/matchers/satisfy_example.rb +36 -0
- data/examples/lib/micronaut/matchers/simple_matcher_example.rb +93 -0
- data/examples/lib/micronaut/matchers/throw_symbol_example.rb +125 -0
- data/examples/lib/micronaut/mocha_example.rb +29 -0
- data/examples/lib/micronaut/runner_example.rb +41 -0
- data/examples/lib/micronaut/world_example.rb +98 -0
- data/examples/lib/micronaut_example.rb +43 -0
- data/examples/resources/example_classes.rb +67 -0
- data/lib/micronaut.rb +40 -0
- data/lib/micronaut/behaviour.rb +217 -0
- data/lib/micronaut/configuration.rb +162 -0
- data/lib/micronaut/example.rb +112 -0
- data/lib/micronaut/expectations.rb +45 -0
- data/lib/micronaut/expectations/extensions/object.rb +92 -0
- data/lib/micronaut/expectations/handler.rb +51 -0
- data/lib/micronaut/expectations/wrap_expectation.rb +52 -0
- data/lib/micronaut/formatters.rb +12 -0
- data/lib/micronaut/formatters/base_formatter.rb +127 -0
- data/lib/micronaut/formatters/base_text_formatter.rb +139 -0
- data/lib/micronaut/formatters/documentation_formatter.rb +78 -0
- data/lib/micronaut/formatters/progress_formatter.rb +30 -0
- data/lib/micronaut/kernel_extensions.rb +11 -0
- data/lib/micronaut/matchers.rb +141 -0
- data/lib/micronaut/matchers/be.rb +204 -0
- data/lib/micronaut/matchers/be_close.rb +37 -0
- data/lib/micronaut/matchers/change.rb +148 -0
- data/lib/micronaut/matchers/eql.rb +26 -0
- data/lib/micronaut/matchers/equal.rb +26 -0
- data/lib/micronaut/matchers/generated_descriptions.rb +36 -0
- data/lib/micronaut/matchers/has.rb +19 -0
- data/lib/micronaut/matchers/have.rb +153 -0
- data/lib/micronaut/matchers/include.rb +80 -0
- data/lib/micronaut/matchers/match.rb +22 -0
- data/lib/micronaut/matchers/method_missing.rb +9 -0
- data/lib/micronaut/matchers/operator_matcher.rb +50 -0
- data/lib/micronaut/matchers/raise_error.rb +128 -0
- data/lib/micronaut/matchers/respond_to.rb +50 -0
- data/lib/micronaut/matchers/satisfy.rb +50 -0
- data/lib/micronaut/matchers/simple_matcher.rb +135 -0
- data/lib/micronaut/matchers/throw_symbol.rb +108 -0
- data/lib/micronaut/mocking/with_absolutely_nothing.rb +11 -0
- data/lib/micronaut/mocking/with_mocha.rb +15 -0
- data/lib/micronaut/mocking/with_rr.rb +24 -0
- data/lib/micronaut/rake_task.rb +84 -0
- data/lib/micronaut/runner.rb +60 -0
- data/lib/micronaut/world.rb +75 -0
- metadata +165 -0
@@ -0,0 +1,133 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
2
|
+
|
3
|
+
describe Micronaut::Configuration do
|
4
|
+
|
5
|
+
describe "#mock_with" do
|
6
|
+
|
7
|
+
it "should require and include the mocha adapter when called with :mocha" do
|
8
|
+
Micronaut.configuration.expects(:require).with('micronaut/mocking/with_mocha')
|
9
|
+
Micronaut::Behaviour.expects(:send)
|
10
|
+
Micronaut.configuration.mock_with :mocha
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should include the null adapter for nil" do
|
14
|
+
Micronaut::Behaviour.expects(:send).with(:include, Micronaut::Mocking::WithAbsolutelyNothing)
|
15
|
+
Micronaut.configuration.mock_with nil
|
16
|
+
end
|
17
|
+
|
18
|
+
# if the below example doesn't pass, @behaviour_instance._setup_mocks and similiar calls fail without a mock library specified
|
19
|
+
# this is really a case where cucumber would be a better fit to catch these type of regressions
|
20
|
+
it "should include the null adapter by default, if no mocking library is specified" do
|
21
|
+
Micronaut::Behaviour.expects(:send).with(:include, Micronaut::Mocking::WithAbsolutelyNothing)
|
22
|
+
config = Micronaut::Configuration.new
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#include" do
|
28
|
+
|
29
|
+
module InstanceLevelMethods
|
30
|
+
def you_call_this_a_blt?
|
31
|
+
"egad man, where's the mayo?!?!?"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should include the given module into each matching behaviour" do
|
36
|
+
Micronaut.configuration.include(InstanceLevelMethods, :magic_key => :include)
|
37
|
+
group = Micronaut::Behaviour.describe(Object, 'does like, stuff and junk', :magic_key => :include) { }
|
38
|
+
group.should_not respond_to(:you_call_this_a_blt?)
|
39
|
+
remove_last_describe_from_world
|
40
|
+
|
41
|
+
group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#extend" do
|
47
|
+
|
48
|
+
module ThatThingISentYou
|
49
|
+
|
50
|
+
def that_thing
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should extend the given module into each matching behaviour" do
|
56
|
+
Micronaut.configuration.extend(ThatThingISentYou, :magic_key => :extend)
|
57
|
+
group = Micronaut::Behaviour.describe(ThatThingISentYou, :magic_key => :extend) { }
|
58
|
+
|
59
|
+
group.should respond_to(:that_thing)
|
60
|
+
remove_last_describe_from_world
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
describe "#run_all_when_everything_filtered" do
|
66
|
+
|
67
|
+
it "defaults to true" do
|
68
|
+
Micronaut::Configuration.new.run_all_when_everything_filtered.should == true
|
69
|
+
end
|
70
|
+
|
71
|
+
it "can be queried with question method" do
|
72
|
+
config = Micronaut::Configuration.new
|
73
|
+
config.run_all_when_everything_filtered = false
|
74
|
+
config.run_all_when_everything_filtered?.should == false
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe '#trace?' do
|
79
|
+
|
80
|
+
it "is false by default" do
|
81
|
+
Micronaut::Configuration.new.trace?.should == false
|
82
|
+
end
|
83
|
+
|
84
|
+
it "is true if configuration.trace is true" do
|
85
|
+
config = Micronaut::Configuration.new
|
86
|
+
config.trace = true
|
87
|
+
config.trace?.should == true
|
88
|
+
end
|
89
|
+
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '#trace' do
|
93
|
+
|
94
|
+
it "requires a block" do
|
95
|
+
config = Micronaut::Configuration.new
|
96
|
+
config.trace = true
|
97
|
+
lambda { config.trace(true) }.should raise_error(ArgumentError)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "does nothing if trace is false" do
|
101
|
+
config = Micronaut::Configuration.new
|
102
|
+
config.trace = false
|
103
|
+
config.expects(:puts).with("my trace string is awesome").never
|
104
|
+
config.trace { "my trace string is awesome" }
|
105
|
+
end
|
106
|
+
|
107
|
+
it "allows overriding tracing an optional param" do
|
108
|
+
config = Micronaut::Configuration.new
|
109
|
+
config.trace = false
|
110
|
+
config.expects(:puts).with(includes("my trace string is awesome"))
|
111
|
+
config.trace(true) { "my trace string is awesome" }
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
115
|
+
|
116
|
+
describe '#formatter' do
|
117
|
+
|
118
|
+
it "sets formatter_to_use based on name" do
|
119
|
+
config = Micronaut::Configuration.new
|
120
|
+
config.formatter = :documentation
|
121
|
+
config.instance_eval { @formatter_to_use.should == Micronaut::Formatters::DocumentationFormatter }
|
122
|
+
config.formatter = 'documentation'
|
123
|
+
config.instance_eval { @formatter_to_use.should == Micronaut::Formatters::DocumentationFormatter }
|
124
|
+
end
|
125
|
+
|
126
|
+
it "raises ArgumentError if formatter is unknown" do
|
127
|
+
config = Micronaut::Configuration.new
|
128
|
+
lambda { config.formatter = :progresss }.should raise_error(ArgumentError)
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
2
|
+
|
3
|
+
describe Micronaut::Example, :parent_metadata => 'sample' do
|
4
|
+
|
5
|
+
before do
|
6
|
+
behaviour = stub('behaviour', :metadata => { :behaviour => { :name => 'behaviour_name' }})
|
7
|
+
@example = Micronaut::Example.new(behaviour, 'description', {}, (lambda {}))
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "attr readers" do
|
11
|
+
|
12
|
+
it "should have one for the parent behaviour" do
|
13
|
+
@example.should respond_to(:behaviour)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should have one for it's description" do
|
17
|
+
@example.should respond_to(:description)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have one for it's metadata" do
|
21
|
+
@example.should respond_to(:metadata)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have one for it's block" do
|
25
|
+
@example.should respond_to(:example_block)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#inspect' do
|
31
|
+
|
32
|
+
it "should return 'behaviour_name - description'" do
|
33
|
+
@example.inspect.should == 'behaviour_name - description'
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#to_s' do
|
39
|
+
|
40
|
+
it "should return #inspect" do
|
41
|
+
@example.to_s.should == @example.inspect
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "accessing metadata within a running example" do
|
47
|
+
|
48
|
+
it "should have a reference to itself when running" do
|
49
|
+
running_example.description.should == "should have a reference to itself when running"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should be able to access the behaviours top level metadata as if it were its own" do
|
53
|
+
running_example.behaviour.metadata.should include(:parent_metadata => 'sample')
|
54
|
+
running_example.metadata.should include(:parent_metadata => 'sample')
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "#run" do
|
60
|
+
|
61
|
+
pending "should run after(:each) when the example fails"
|
62
|
+
|
63
|
+
pending "should run after(:each) when the example raises an Exception"
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,146 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../../example_helper")
|
2
|
+
|
3
|
+
describe Object do
|
4
|
+
|
5
|
+
describe "#should" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@target = "target"
|
9
|
+
@matcher = mock("matcher")
|
10
|
+
@matcher.stubs(:matches?).returns(true)
|
11
|
+
@matcher.stubs(:failure_message)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should accept and interact with a matcher" do
|
15
|
+
@matcher.expects(:matches?).with(@target).returns(true)
|
16
|
+
@target.should @matcher
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should ask for a failure_message when matches? returns false" do
|
20
|
+
@matcher.expects(:matches?).with(@target).returns(false)
|
21
|
+
@matcher.expects(:failure_message).returns("the failure message")
|
22
|
+
lambda { @target.should @matcher }.should fail_with("the failure message")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise error if it receives false directly" do
|
26
|
+
lambda { @target.should false }.should raise_error(Micronaut::Expectations::InvalidMatcherError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should raise error if it receives false (evaluated)" do
|
30
|
+
lambda { @target.should eql?("foo") }.should raise_error(Micronaut::Expectations::InvalidMatcherError)
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should raise error if it receives true" do
|
34
|
+
lambda { @target.should true }.should raise_error(Micronaut::Expectations::InvalidMatcherError)
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#should_not" do
|
40
|
+
|
41
|
+
before do
|
42
|
+
@target = "target"
|
43
|
+
@matcher = mock("matcher")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should accept and interact with a matcher" do
|
47
|
+
@matcher.expects(:matches?).with(@target).returns(false)
|
48
|
+
@matcher.stubs(:negative_failure_message)
|
49
|
+
@target.should_not @matcher
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should ask for a negative_failure_message when matches? returns true" do
|
53
|
+
@matcher.expects(:matches?).with(@target).returns(true)
|
54
|
+
@matcher.expects(:negative_failure_message).returns("the negative failure message")
|
55
|
+
lambda { @target.should_not @matcher }.should fail_with("the negative failure message")
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should raise error if it receives false directly" do
|
59
|
+
lambda { @target.should_not false }.should raise_error(Micronaut::Expectations::InvalidMatcherError)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should raise error if it receives false (evaluated)" do
|
63
|
+
lambda { @target.should_not eql?("foo") }.should raise_error(Micronaut::Expectations::InvalidMatcherError)
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should raise error if it receives true" do
|
67
|
+
lambda { @target.should_not true }.should raise_error(Micronaut::Expectations::InvalidMatcherError)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
module ExampleExpectations
|
73
|
+
|
74
|
+
class ArbitraryMatcher
|
75
|
+
def initialize(*args, &block)
|
76
|
+
if args.last.is_a? Hash
|
77
|
+
@expected = args.last[:expected]
|
78
|
+
end
|
79
|
+
if block_given?
|
80
|
+
@expected = block.call
|
81
|
+
end
|
82
|
+
@block = block
|
83
|
+
end
|
84
|
+
|
85
|
+
def matches?(target)
|
86
|
+
@target = target
|
87
|
+
return @expected == target
|
88
|
+
end
|
89
|
+
|
90
|
+
def with(new_value)
|
91
|
+
@expected = new_value
|
92
|
+
self
|
93
|
+
end
|
94
|
+
|
95
|
+
def failure_message
|
96
|
+
"expected #{@expected}, got #{@target}"
|
97
|
+
end
|
98
|
+
|
99
|
+
def negative_failure_message
|
100
|
+
"expected not #{@expected}, got #{@target}"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
class PositiveOnlyMatcher < ArbitraryMatcher
|
105
|
+
undef negative_failure_message rescue nil
|
106
|
+
end
|
107
|
+
|
108
|
+
def arbitrary_matcher(*args, &block)
|
109
|
+
ArbitraryMatcher.new(*args, &block)
|
110
|
+
end
|
111
|
+
|
112
|
+
def positive_only_matcher(*args, &block)
|
113
|
+
PositiveOnlyMatcher.new(*args, &block)
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
describe "should and should not matcher handling" do
|
119
|
+
include ExampleExpectations
|
120
|
+
|
121
|
+
it "should handle submitted args" do
|
122
|
+
5.should arbitrary_matcher(:expected => 5)
|
123
|
+
5.should arbitrary_matcher(:expected => "wrong").with(5)
|
124
|
+
lambda { 5.should arbitrary_matcher(:expected => 4) }.should fail_with("expected 4, got 5")
|
125
|
+
lambda { 5.should arbitrary_matcher(:expected => 5).with(4) }.should fail_with("expected 4, got 5")
|
126
|
+
5.should_not arbitrary_matcher(:expected => 4)
|
127
|
+
5.should_not arbitrary_matcher(:expected => 5).with(4)
|
128
|
+
lambda { 5.should_not arbitrary_matcher(:expected => 5) }.should fail_with("expected not 5, got 5")
|
129
|
+
lambda { 5.should_not arbitrary_matcher(:expected => 4).with(5) }.should fail_with("expected not 5, got 5")
|
130
|
+
end
|
131
|
+
|
132
|
+
it "should handle the submitted block" do
|
133
|
+
5.should arbitrary_matcher { 5 }
|
134
|
+
5.should arbitrary_matcher(:expected => 4) { 5 }
|
135
|
+
5.should arbitrary_matcher(:expected => 4).with(5) { 3 }
|
136
|
+
end
|
137
|
+
|
138
|
+
it "should explain when matcher does not support should_not" do
|
139
|
+
lambda {
|
140
|
+
5.should_not positive_only_matcher(:expected => 5)
|
141
|
+
}.should fail_with(/Matcher does not support should_not.\n/)
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
|
+
|
3
|
+
describe Micronaut::Expectations do
|
4
|
+
|
5
|
+
describe "#fail_with" do
|
6
|
+
|
7
|
+
it "should handle just a message" do
|
8
|
+
lambda { Micronaut::Expectations.fail_with "the message" }.should fail_with("the message")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should handle an Array" do
|
12
|
+
lambda { Micronaut::Expectations.fail_with ["the message","expected","actual"] }.should fail_with("the message")
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
|
+
|
3
|
+
describe Micronaut::Matchers, '#wrap_expectation' do
|
4
|
+
|
5
|
+
def stub_matcher
|
6
|
+
@_stub_matcher ||= simple_matcher do
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def failing_matcher
|
11
|
+
@_failing_matcher ||= simple_matcher do
|
12
|
+
1.should == 2
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return true if there is no error" do
|
17
|
+
wrap_expectation stub_matcher do
|
18
|
+
end.should be_true
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return false if there is an error" do
|
22
|
+
wrap_expectation failing_matcher do
|
23
|
+
raise "error"
|
24
|
+
end.should be_false
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
|
+
|
3
|
+
describe Micronaut::Formatters::BaseFormatter do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@formatter = Micronaut::Formatters::BaseFormatter.new
|
7
|
+
end
|
8
|
+
|
9
|
+
class HaveInterfaceMatcher
|
10
|
+
def initialize(method)
|
11
|
+
@method = method
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :object
|
15
|
+
attr_reader :method
|
16
|
+
|
17
|
+
def matches?(object)
|
18
|
+
@object = object
|
19
|
+
object.respond_to?(@method)
|
20
|
+
end
|
21
|
+
|
22
|
+
def with(arity)
|
23
|
+
WithArity.new(self, @method, arity)
|
24
|
+
end
|
25
|
+
|
26
|
+
class WithArity
|
27
|
+
def initialize(matcher, method, arity)
|
28
|
+
@have_matcher = matcher
|
29
|
+
@method = method
|
30
|
+
@arity = arity
|
31
|
+
end
|
32
|
+
|
33
|
+
def matches?(an_object)
|
34
|
+
@have_matcher.matches?(an_object) && real_arity == @arity
|
35
|
+
end
|
36
|
+
|
37
|
+
def failure_message
|
38
|
+
"#{@have_matcher} should have method :#{@method} with #{argument_arity}, but it had #{real_arity}"
|
39
|
+
end
|
40
|
+
|
41
|
+
def arguments
|
42
|
+
self
|
43
|
+
end
|
44
|
+
|
45
|
+
alias_method :argument, :arguments
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def real_arity
|
50
|
+
@have_matcher.object.method(@method).arity
|
51
|
+
end
|
52
|
+
|
53
|
+
def argument_arity
|
54
|
+
if @arity == 1
|
55
|
+
"1 argument"
|
56
|
+
else
|
57
|
+
"#{@arity} arguments"
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def have_interface_for(method)
|
64
|
+
HaveInterfaceMatcher.new(method)
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have start as an interface with one argument" do
|
68
|
+
@formatter.should have_interface_for(:start).with(1).argument
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should have add_behaviour as an interface with one argument" do
|
72
|
+
@formatter.should have_interface_for(:add_behaviour).with(1).argument
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should have example_finished as an interface with one argument" do
|
76
|
+
@formatter.should have_interface_for(:example_finished).with(1).arguments
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should have start_dump as an interface with 1 arguments" do
|
80
|
+
@formatter.should have_interface_for(:start_dump).with(1).arguments
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should have dump_failures as an interface with no arguments" do
|
84
|
+
@formatter.should have_interface_for(:dump_failures).with(0).arguments
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should have dump_summary as an interface with zero arguments" do
|
88
|
+
@formatter.should have_interface_for(:dump_summary).with(0).arguments
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should have dump_pending as an interface with zero arguments" do
|
92
|
+
@formatter.should have_interface_for(:dump_pending).with(0).arguments
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should have close as an interface with zero arguments" do
|
96
|
+
@formatter.should have_interface_for(:close).with(0).arguments
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#format_backtrace' do
|
100
|
+
|
101
|
+
before do
|
102
|
+
@full_backtrace = ["examples/lib/micronaut/formatters/base_formatter_example.rb:118", "vendor/rails/x.rb:1", "/bin/micronaut"]
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should display the full backtrace when the example is given the :full_backtrace => true option", :full_backtrace => true do
|
106
|
+
running_example.metadata[:full_backtrace].should be_true
|
107
|
+
@formatter.format_backtrace(@full_backtrace, running_example).should == @full_backtrace
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should clean the backtrace when the full_backtrace option is not given" do
|
111
|
+
running_example.metadata[:full_backtrace].should be_nil
|
112
|
+
@formatter.format_backtrace(@full_backtrace, running_example).should == ["examples/lib/micronaut/formatters/base_formatter_example.rb:118"]
|
113
|
+
end
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|