micronaut 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- 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,54 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
|
+
|
3
|
+
describe "should respond_to(:sym)" do
|
4
|
+
|
5
|
+
it "should pass if target responds to :sym" do
|
6
|
+
Object.new.should respond_to(:methods)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should fail target does not respond to :sym" do
|
10
|
+
lambda {
|
11
|
+
"this string".should respond_to(:some_method)
|
12
|
+
}.should fail_with("expected \"this string\" to respond to :some_method")
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "should respond_to(message1, message2)" do
|
18
|
+
|
19
|
+
it "should pass if target responds to both messages" do
|
20
|
+
Object.new.should respond_to('methods', 'inspect')
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should fail target does not respond to first message" do
|
24
|
+
lambda {
|
25
|
+
Object.new.should respond_to('method_one', 'inspect')
|
26
|
+
}.should fail_with(/expected #<Object:.*> to respond to "method_one"/)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should fail target does not respond to second message" do
|
30
|
+
lambda {
|
31
|
+
Object.new.should respond_to('inspect', 'method_one')
|
32
|
+
}.should fail_with(/expected #<Object:.*> to respond to "method_one"/)
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should fail target does not respond to either message" do
|
36
|
+
lambda {
|
37
|
+
Object.new.should respond_to('method_one', 'method_two')
|
38
|
+
}.should fail_with(/expected #<Object:.*> to respond to "method_one", "method_two"/)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "should_not respond_to(:sym)" do
|
43
|
+
|
44
|
+
it "should pass if target does not respond to :sym" do
|
45
|
+
Object.new.should_not respond_to(:some_method)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should fail target responds to :sym" do
|
49
|
+
lambda {
|
50
|
+
Object.new.should_not respond_to(:methods)
|
51
|
+
}.should fail_with(/expected #<Object:.*> not to respond to :methods/)
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
|
+
|
3
|
+
describe "should satisfy { block }" do
|
4
|
+
it "should pass if block returns true" do
|
5
|
+
true.should satisfy { |val| val }
|
6
|
+
true.should satisfy do |val|
|
7
|
+
val
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should fail if block returns false" do
|
12
|
+
lambda {
|
13
|
+
false.should satisfy { |val| val }
|
14
|
+
}.should fail_with("expected false to satisfy block")
|
15
|
+
lambda do
|
16
|
+
false.should satisfy do |val|
|
17
|
+
val
|
18
|
+
end
|
19
|
+
end.should fail_with("expected false to satisfy block")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe "should_not satisfy { block }" do
|
24
|
+
it "should pass if block returns false" do
|
25
|
+
false.should_not satisfy { |val| val }
|
26
|
+
false.should_not satisfy do |val|
|
27
|
+
val
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should fail if block returns true" do
|
32
|
+
lambda {
|
33
|
+
true.should_not satisfy { |val| val }
|
34
|
+
}.should fail_with("expected true not to satisfy block")
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
|
+
|
3
|
+
module Micronaut
|
4
|
+
module Matchers
|
5
|
+
describe SimpleMatcher do
|
6
|
+
it "should pass match arg to block" do
|
7
|
+
actual = nil
|
8
|
+
matcher = simple_matcher("message") do |given| actual = given end
|
9
|
+
matcher.matches?("foo")
|
10
|
+
actual.should == "foo"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should provide a stock failure message" do
|
14
|
+
matcher = simple_matcher("thing") do end
|
15
|
+
matcher.matches?("other")
|
16
|
+
matcher.failure_message.should =~ /expected \"thing\" but got \"other\"/
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should provide a stock negative failure message" do
|
20
|
+
matcher = simple_matcher("thing") do end
|
21
|
+
matcher.matches?("other")
|
22
|
+
matcher.negative_failure_message.should =~ /expected not to get \"thing\", but got \"other\"/
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should provide the given description" do
|
26
|
+
matcher = simple_matcher("thing") do end
|
27
|
+
matcher.description.should =="thing"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should fail if a wrapped 'should' fails" do
|
31
|
+
matcher = simple_matcher("should fail") do
|
32
|
+
2.should == 3
|
33
|
+
end
|
34
|
+
lambda do
|
35
|
+
matcher.matches?("anything").should be_true
|
36
|
+
end.should fail_with(/expected: 3/)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe "with arity of 2" do
|
41
|
+
it "should provide the matcher so you can access its messages" do
|
42
|
+
provided_matcher = nil
|
43
|
+
matcher = simple_matcher("thing") do |given, matcher|
|
44
|
+
provided_matcher = matcher
|
45
|
+
end
|
46
|
+
matcher.matches?("anything")
|
47
|
+
provided_matcher.should equal(matcher)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should support a custom failure message" do
|
51
|
+
matcher = simple_matcher("thing") do |given, matcher|
|
52
|
+
matcher.failure_message = "custom message"
|
53
|
+
end
|
54
|
+
matcher.matches?("other")
|
55
|
+
matcher.failure_message.should == "custom message"
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should complain when asked for a failure message if you don't give it a description or a message" do
|
59
|
+
matcher = simple_matcher do |given, matcher| end
|
60
|
+
matcher.matches?("other")
|
61
|
+
matcher.failure_message.should =~ /No description provided/
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should support a custom negative failure message" do
|
65
|
+
matcher = simple_matcher("thing") do |given, matcher|
|
66
|
+
matcher.negative_failure_message = "custom message"
|
67
|
+
end
|
68
|
+
matcher.matches?("other")
|
69
|
+
matcher.negative_failure_message.should == "custom message"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should complain when asked for a negative failure message if you don't give it a description or a message" do
|
73
|
+
matcher = simple_matcher do |given, matcher| end
|
74
|
+
matcher.matches?("other")
|
75
|
+
matcher.negative_failure_message.should =~ /No description provided/
|
76
|
+
end
|
77
|
+
|
78
|
+
it "should support a custom description" do
|
79
|
+
matcher = simple_matcher("thing") do |given, matcher|
|
80
|
+
matcher.description = "custom message"
|
81
|
+
end
|
82
|
+
matcher.matches?("description")
|
83
|
+
matcher.description.should == "custom message"
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should tell you no description was provided when it doesn't receive one" do
|
87
|
+
matcher = simple_matcher do end
|
88
|
+
matcher.description.should =~ /No description provided/
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
end
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
2
|
+
|
3
|
+
describe Micronaut::Matchers::ThrowSymbol do
|
4
|
+
|
5
|
+
describe "with no args" do
|
6
|
+
|
7
|
+
before do
|
8
|
+
@matcher = Micronaut::Matchers::ThrowSymbol.new
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should match if any Symbol is thrown" do
|
12
|
+
@matcher.matches?(lambda{ throw :sym }).should be_true
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should match if any Symbol is thrown with an arg" do
|
16
|
+
@matcher.matches?(lambda{ throw :sym, "argument" }).should be_true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should not match if no Symbol is thrown" do
|
20
|
+
@matcher.matches?(lambda{ }).should be_false
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should provide a failure message" do
|
24
|
+
@matcher.matches?(lambda{})
|
25
|
+
@matcher.failure_message.should == "expected a Symbol but nothing was thrown"
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should provide a negative failure message" do
|
29
|
+
@matcher.matches?(lambda{ throw :sym})
|
30
|
+
@matcher.negative_failure_message.should == "expected no Symbol, got :sym"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "with a symbol" do
|
36
|
+
|
37
|
+
before do
|
38
|
+
@matcher = Micronaut::Matchers::ThrowSymbol.new(:sym)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should match if correct Symbol is thrown" do
|
42
|
+
@matcher.matches?(lambda{ throw :sym }).should be_true
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should match if correct Symbol is thrown with an arg" do
|
46
|
+
@matcher.matches?(lambda{ throw :sym, "argument" }).should be_true
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should not match if no Symbol is thrown" do
|
50
|
+
@matcher.matches?(lambda{ }).should be_false
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should not match if correct Symbol is thrown" do
|
54
|
+
@matcher.matches?(lambda{ throw :other_sym }).should be_false
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should provide a failure message when no Symbol is thrown" do
|
58
|
+
@matcher.matches?(lambda{})
|
59
|
+
@matcher.failure_message.should == "expected :sym but nothing was thrown"
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should provide a failure message when wrong Symbol is thrown" do
|
63
|
+
@matcher.matches?(lambda{ throw :other_sym })
|
64
|
+
@matcher.failure_message.should == "expected :sym, got :other_sym"
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should provide a negative failure message" do
|
68
|
+
@matcher.matches?(lambda{ throw :sym })
|
69
|
+
@matcher.negative_failure_message.should == "expected :sym not to be thrown"
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should only match NameErrors raised by uncaught throws" do
|
73
|
+
@matcher.matches?(lambda{ sym }).should be_false
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "with a symbol and an arg" do
|
79
|
+
|
80
|
+
before do
|
81
|
+
@matcher = Micronaut::Matchers::ThrowSymbol.new(:sym, "a")
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should match if correct Symbol and args are thrown" do
|
85
|
+
@matcher.matches?(lambda{ throw :sym, "a" }).should be_true
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should not match if nothing is thrown" do
|
89
|
+
@matcher.matches?(lambda{ }).should be_false
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should not match if other Symbol is thrown" do
|
93
|
+
@matcher.matches?(lambda{ throw :other_sym, "a" }).should be_false
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should not match if no arg is thrown" do
|
97
|
+
@matcher.matches?(lambda{ throw :sym }).should be_false
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should not match if wrong arg is thrown" do
|
101
|
+
@matcher.matches?(lambda{ throw :sym, "b" }).should be_false
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should provide a failure message when no Symbol is thrown" do
|
105
|
+
@matcher.matches?(lambda{})
|
106
|
+
@matcher.failure_message.should == %q[expected :sym with "a" but nothing was thrown]
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should provide a failure message when wrong Symbol is thrown" do
|
110
|
+
@matcher.matches?(lambda{ throw :other_sym })
|
111
|
+
@matcher.failure_message.should == %q[expected :sym with "a", got :other_sym]
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should provide a negative failure message" do
|
115
|
+
@matcher.matches?(lambda{ throw :sym })
|
116
|
+
@matcher.negative_failure_message.should == %q[expected :sym with "a" not to be thrown]
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should only match NameErrors raised by uncaught throws" do
|
120
|
+
@matcher.matches?(lambda{ sym }).should be_false
|
121
|
+
end
|
122
|
+
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
2
|
+
|
3
|
+
describe "Mocha Regression involving double reporting of errors" do
|
4
|
+
|
5
|
+
it "should not double report mocha errors" do
|
6
|
+
# The below example should have one error, not two
|
7
|
+
# I'm also not sure how to test this regression without having the failure counting by
|
8
|
+
# the running Micronaut instance
|
9
|
+
formatter = Micronaut::Formatters::BaseFormatter.new
|
10
|
+
|
11
|
+
use_formatter(formatter) do
|
12
|
+
|
13
|
+
isolate_behaviour do
|
14
|
+
desc = Micronaut::Behaviour.describe("my favorite pony") do
|
15
|
+
example("showing a double fail") do
|
16
|
+
foo = "string"
|
17
|
+
foo.expects(:something)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
desc.examples_to_run.replace(desc.examples)
|
21
|
+
desc.run(formatter)
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
formatter.examples.size.should == 1
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
2
|
+
|
3
|
+
describe Micronaut::Runner do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@runner = Micronaut::Runner.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe '#configuration' do
|
10
|
+
|
11
|
+
it "should return Micronaut.configuration" do
|
12
|
+
@runner.configuration.should == Micronaut.configuration
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
describe '#formatter' do
|
18
|
+
|
19
|
+
it 'should return the configured formatter' do
|
20
|
+
@runner.formatter.should == Micronaut.configuration.formatter
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'Micronaut::Runner.at_exit' do
|
26
|
+
|
27
|
+
it 'should set an at_exit hook if none is already set' do
|
28
|
+
Micronaut::Runner.stubs(:installed_at_exit?).returns(false)
|
29
|
+
Micronaut::Runner.expects(:at_exit)
|
30
|
+
Micronaut::Runner.autorun
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should not set the at_exit hook if it is already set' do
|
34
|
+
Micronaut::Runner.stubs(:installed_at_exit?).returns(true)
|
35
|
+
Micronaut::Runner.expects(:at_exit).never
|
36
|
+
Micronaut::Runner.autorun
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
2
|
+
|
3
|
+
class Bar; end
|
4
|
+
class Foo; end
|
5
|
+
|
6
|
+
describe Micronaut::World do
|
7
|
+
|
8
|
+
before do
|
9
|
+
@world = Micronaut::World.new
|
10
|
+
Micronaut.stubs(:world).returns(@world)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe "behaviour groups" do
|
14
|
+
|
15
|
+
it "should contain all defined behaviour groups" do
|
16
|
+
behaviour_group = Micronaut::Behaviour.describe(Bar, 'Empty Behaviour Group') { }
|
17
|
+
@world.behaviours.should include(behaviour_group)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "find" do
|
23
|
+
|
24
|
+
before(:all) do
|
25
|
+
options_1 = { :foo => 1, :color => 'blue', :feature => 'reporting' }
|
26
|
+
options_2 = { :pending => true, :feature => 'reporting' }
|
27
|
+
options_3 = { :array => [1,2,3,4], :color => 'blue', :feature => 'weather status' }
|
28
|
+
@bg1 = Micronaut::Behaviour.describe(Bar, "find group-1", options_1) { }
|
29
|
+
@bg2 = Micronaut::Behaviour.describe(Bar, "find group-2", options_2) { }
|
30
|
+
@bg3 = Micronaut::Behaviour.describe(Bar, "find group-3", options_3) { }
|
31
|
+
@bg4 = Micronaut::Behaviour.describe(Foo, "find these examples") do
|
32
|
+
it('I have no options') {}
|
33
|
+
it("this is awesome", :awesome => true) {}
|
34
|
+
it("this is too", :awesome => true) {}
|
35
|
+
it("not so awesome", :awesome => false) {}
|
36
|
+
it("I also have no options") {}
|
37
|
+
end
|
38
|
+
@behaviours = [@bg1, @bg2, @bg3, @bg4]
|
39
|
+
end
|
40
|
+
|
41
|
+
after(:all) do
|
42
|
+
Micronaut.world.behaviours.delete(@bg1)
|
43
|
+
Micronaut.world.behaviours.delete(@bg2)
|
44
|
+
Micronaut.world.behaviours.delete(@bg3)
|
45
|
+
Micronaut.world.behaviours.delete(@bg4)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should find awesome examples" do
|
49
|
+
@world.find(@bg4.examples, :awesome => true).should == [@bg4.examples[1], @bg4.examples[2]]
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should find no groups when given no search parameters" do
|
53
|
+
@world.find([]).should == []
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should find three groups when searching for :behaviour_describes => Bar" do
|
57
|
+
@world.find(@behaviours, :behaviour => { :describes => Bar }).should == [@bg1, @bg2, @bg3]
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should find one group when searching for :description => 'find group-1'" do
|
61
|
+
@world.find(@behaviours, :behaviour => { :description => 'find group-1' }).should == [@bg1]
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should find two groups when searching for :description => lambda { |v| v.include?('-1') || v.include?('-3') }" do
|
65
|
+
@world.find(@behaviours, :behaviour => { :description => lambda { |v| v.include?('-1') || v.include?('-3') } }).should == [@bg1, @bg3]
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should find three groups when searching for :description => /find group/" do
|
69
|
+
@world.find(@behaviours, :behaviour => { :description => /find group/ }).should == [@bg1, @bg2, @bg3]
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should find one group when searching for :foo => 1" do
|
73
|
+
@world.find(@behaviours, :foo => 1 ).should == [@bg1]
|
74
|
+
end
|
75
|
+
|
76
|
+
it "should find one group when searching for :pending => true" do
|
77
|
+
@world.find(@behaviours, :pending => true ).should == [@bg2]
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should find one group when searching for :array => [1,2,3,4]" do
|
81
|
+
@world.find(@behaviours, :array => [1,2,3,4]).should == [@bg3]
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should find no group when searching for :array => [4,3,2,1]" do
|
85
|
+
@world.find(@behaviours, :array => [4,3,2,1]).should be_empty
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should find two groups when searching for :color => 'blue'" do
|
89
|
+
@world.find(@behaviours, :color => 'blue').should == [@bg1, @bg3]
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should find two groups when searching for :feature => 'reporting' }" do
|
93
|
+
@world.find(@behaviours, :feature => 'reporting').should == [@bg1, @bg2]
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
end
|