rsanheim-micronaut 0.1.3.2
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/LICENSE +45 -0
- data/README +17 -0
- data/RSPEC-LICENSE +23 -0
- data/Rakefile +83 -0
- data/bin/micronaut +4 -0
- data/examples/example_helper.rb +36 -0
- data/examples/lib/micronaut/behaviour_example.rb +188 -0
- data/examples/lib/micronaut/configuration_example.rb +70 -0
- data/examples/lib/micronaut/example_example.rb +46 -0
- data/examples/lib/micronaut/expectations/extensions/object_example.rb +72 -0
- data/examples/lib/micronaut/expectations/fail_with_example.rb +17 -0
- data/examples/lib/micronaut/expectations/wrap_expectation_example.rb +31 -0
- data/examples/lib/micronaut/formatters/base_formatter_example.rb +107 -0
- data/examples/lib/micronaut/formatters/documentation_formatter_example.rb +5 -0
- data/examples/lib/micronaut/formatters/progress_formatter_example.rb +74 -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/handler_example.rb +153 -0
- data/examples/lib/micronaut/matchers/has_example.rb +71 -0
- data/examples/lib/micronaut/matchers/have_example.rb +575 -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 +66 -0
- data/examples/lib/micronaut/matchers/operator_matcher_example.rb +189 -0
- data/examples/lib/micronaut/matchers/raise_error_example.rb +346 -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 +96 -0
- data/examples/lib/micronaut/runner_example.rb +5 -0
- data/examples/lib/micronaut/runner_options_example.rb +5 -0
- data/examples/lib/micronaut/world_example.rb +102 -0
- data/examples/lib/micronaut_example.rb +23 -0
- data/examples/resources/example_classes.rb +67 -0
- data/lib/autotest/discover.rb +3 -0
- data/lib/autotest/micronaut.rb +47 -0
- data/lib/micronaut/behaviour.rb +211 -0
- data/lib/micronaut/configuration.rb +133 -0
- data/lib/micronaut/example.rb +28 -0
- data/lib/micronaut/expectations/extensions/object.rb +62 -0
- data/lib/micronaut/expectations/extensions/string_and_symbol.rb +19 -0
- data/lib/micronaut/expectations/handler.rb +52 -0
- data/lib/micronaut/expectations/wrap_expectation.rb +57 -0
- data/lib/micronaut/expectations.rb +46 -0
- data/lib/micronaut/formatters/base_formatter.rb +82 -0
- data/lib/micronaut/formatters/base_text_formatter.rb +148 -0
- data/lib/micronaut/formatters/documentation_formatter.rb +62 -0
- data/lib/micronaut/formatters/progress_formatter.rb +36 -0
- data/lib/micronaut/formatters.rb +12 -0
- data/lib/micronaut/kernel_extensions.rb +11 -0
- data/lib/micronaut/matchers/be.rb +204 -0
- data/lib/micronaut/matchers/be_close.rb +22 -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/matchers.rb +148 -0
- data/lib/micronaut/mocking/with_absolutely_nothing.rb +11 -0
- data/lib/micronaut/mocking/with_mocha.rb +13 -0
- data/lib/micronaut/mocking/with_rr.rb +24 -0
- data/lib/micronaut/mocking.rb +7 -0
- data/lib/micronaut/runner.rb +57 -0
- data/lib/micronaut/runner_options.rb +33 -0
- data/lib/micronaut/world.rb +75 -0
- data/lib/micronaut.rb +37 -0
- metadata +149 -0
data/LICENSE
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Copyright (c) 2008 Chad Humphries
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
The matchers and expectations are licensed:
|
|
24
|
+
(The MIT License)
|
|
25
|
+
|
|
26
|
+
Copyright (c) 2005-2008 The RSpec Development Team
|
|
27
|
+
|
|
28
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
29
|
+
a copy of this software and associated documentation files (the
|
|
30
|
+
"Software"), to deal in the Software without restriction, including
|
|
31
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
32
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
33
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
34
|
+
the following conditions:
|
|
35
|
+
|
|
36
|
+
The above copyright notice and this permission notice shall be
|
|
37
|
+
included in all copies or substantial portions of the Software.
|
|
38
|
+
|
|
39
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
40
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
41
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
42
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
43
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
44
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
45
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
= Micronaut
|
|
2
|
+
|
|
3
|
+
* http://github.com/spicycode/micronaut
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
Micronaut is an ultra light-weight BDD test framework. For the moment think of it is a prototype of
|
|
8
|
+
RSpec lite. Definitely pre alpha at the moment.
|
|
9
|
+
|
|
10
|
+
== REQUIREMENTS:
|
|
11
|
+
|
|
12
|
+
+ Ruby 1.8
|
|
13
|
+
|
|
14
|
+
== CREDITS:
|
|
15
|
+
|
|
16
|
+
* Mini/Unit for the great ideas and runner
|
|
17
|
+
* RSpec for the great ideas, matchers, expectations and formatter ideas
|
data/RSPEC-LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2005-2008 The RSpec Development Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'rake/gempackagetask'
|
|
3
|
+
require 'rubygems/specification'
|
|
4
|
+
|
|
5
|
+
GEM = "micronaut"
|
|
6
|
+
GEM_VERSION = "0.1.3.2"
|
|
7
|
+
AUTHOR = "Chad Humphries"
|
|
8
|
+
EMAIL = "chad@spicycode.com"
|
|
9
|
+
HOMEPAGE = "http://spicycode.com"
|
|
10
|
+
SUMMARY = "An excellent replacement for the wheel..."
|
|
11
|
+
|
|
12
|
+
spec = Gem::Specification.new do |s|
|
|
13
|
+
s.name = GEM
|
|
14
|
+
s.version = GEM_VERSION
|
|
15
|
+
s.platform = Gem::Platform::RUBY
|
|
16
|
+
s.has_rdoc = true
|
|
17
|
+
s.extra_rdoc_files = ["README", "LICENSE", "RSPEC-LICENSE"]
|
|
18
|
+
s.summary = SUMMARY
|
|
19
|
+
s.description = s.summary
|
|
20
|
+
s.author = AUTHOR
|
|
21
|
+
s.email = EMAIL
|
|
22
|
+
s.homepage = HOMEPAGE
|
|
23
|
+
s.bindir = 'bin'
|
|
24
|
+
s.default_executable = 'micronaut'
|
|
25
|
+
s.executables = ["micronaut"]
|
|
26
|
+
s.require_path = 'lib'
|
|
27
|
+
s.autorequire = GEM
|
|
28
|
+
s.files = %w(LICENSE README RSPEC-LICENSE Rakefile) + Dir.glob("{lib,examples}/**/*")
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
|
32
|
+
pkg.gem_spec = spec
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
desc "install the gem locally"
|
|
36
|
+
task :install => [:package] do
|
|
37
|
+
sh %{sudo gem install pkg/#{GEM}-#{GEM_VERSION}}
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
desc "create a gemspec file"
|
|
41
|
+
task :make_gemspec do
|
|
42
|
+
File.open("#{GEM}.gemspec", "w") do |file|
|
|
43
|
+
file.puts spec.to_ruby
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
namespace :micronaut do
|
|
48
|
+
|
|
49
|
+
desc 'Run all examples'
|
|
50
|
+
task :examples do
|
|
51
|
+
examples = Dir["examples/**/*_example.rb"].map { |g| Dir.glob(g) }.flatten
|
|
52
|
+
ruby examples.join(" ")
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
desc "List files that don't have examples"
|
|
56
|
+
task :untested do
|
|
57
|
+
code = Dir["lib/**/*.rb"].map { |g| Dir.glob(g) }.flatten
|
|
58
|
+
examples = Dir["examples/**/*_example.rb"].map { |g| Dir.glob(g) }.flatten
|
|
59
|
+
examples.map! { |f| f =~ /examples\/(.*)_example/; "#{$1}.rb" }
|
|
60
|
+
missing_examples = (code - examples)
|
|
61
|
+
puts
|
|
62
|
+
puts "The following files seem to be missing their examples:"
|
|
63
|
+
missing_examples.each do |missing|
|
|
64
|
+
puts " #{missing}"
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
desc "Run all examples using rcov"
|
|
69
|
+
task :coverage do
|
|
70
|
+
examples = Dir["examples/**/*_example.rb"].map { |g| Dir.glob(g) }.flatten
|
|
71
|
+
system "rcov --exclude \"examples/*,gems/*,db/*,/Library/Ruby/*,config/*\" --text-report --sort coverage --no-validator-links #{examples.join(' ')}"
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
desc "Delete coverage artifacts"
|
|
75
|
+
task :clean_coverage do
|
|
76
|
+
rm_rf Dir["coverage/**/*"]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
task :default => 'micronaut:coverage'
|
|
82
|
+
task :clobber_package => 'micronaut:clean_coverage'
|
|
83
|
+
|
data/bin/micronaut
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
lib_path = File.expand_path(File.dirname(__FILE__) + "/../lib")
|
|
2
|
+
$LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
|
|
3
|
+
|
|
4
|
+
require 'micronaut'
|
|
5
|
+
gem :mocha
|
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + "/resources/example_classes")
|
|
7
|
+
|
|
8
|
+
module Micronaut
|
|
9
|
+
module Matchers
|
|
10
|
+
def fail
|
|
11
|
+
raise_error(::Micronaut::Expectations::ExpectationNotMetError)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def fail_with(message)
|
|
15
|
+
raise_error(::Micronaut::Expectations::ExpectationNotMetError, message)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def remove_last_describe_from_world
|
|
21
|
+
Micronaut::World.behaviours.pop
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class DummyFormatter < Micronaut::Formatters::BaseTextFormatter; end
|
|
25
|
+
|
|
26
|
+
def dummy_reporter
|
|
27
|
+
DummyFormatter.new({}, StringIO.new)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
Micronaut.configure do |config|
|
|
31
|
+
config.mock_with :mocha
|
|
32
|
+
config.options = Micronaut::RunnerOptions.new(:color => true, :formatter => :progress)
|
|
33
|
+
config.profile_examples = true
|
|
34
|
+
config.add_filter :options => { :focused => true }
|
|
35
|
+
config.autorun!
|
|
36
|
+
end
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
|
2
|
+
|
|
3
|
+
describe Micronaut::Behaviour do
|
|
4
|
+
|
|
5
|
+
class Foo
|
|
6
|
+
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def empty_behaviour_group
|
|
10
|
+
group = Micronaut::Behaviour.describe(Foo, 'Empty Behaviour Group') { }
|
|
11
|
+
remove_last_describe_from_world
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "describing behaviour with #describe" do
|
|
15
|
+
|
|
16
|
+
it "should raise an ArgumentError if no name is given" do
|
|
17
|
+
lambda { Micronaut::Behaviour.describe() {} }.should raise_error(ArgumentError)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should raise an ArgumentError if no block is given" do
|
|
21
|
+
lambda { Micronaut::Behaviour.describe('foo') }.should raise_error(ArgumentError)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe '#name' do
|
|
25
|
+
|
|
26
|
+
it "should expose the first parameter as name" do
|
|
27
|
+
Micronaut::Behaviour.describe("my favorite pony") { }.name.should == 'my favorite pony'
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should call to_s on the first parameter in case it is a constant" do
|
|
31
|
+
Micronaut::Behaviour.describe(Foo) { }.name.should == 'Foo'
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
describe '#described_type' do
|
|
37
|
+
|
|
38
|
+
it "should be the first parameter when it is a constant" do
|
|
39
|
+
Micronaut::Behaviour.describe(Foo) { }.described_type.should == Foo
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should be nil when the first parameter is a string" do
|
|
43
|
+
Micronaut::Behaviour.describe("i'm a computer") { }.described_type.should be_nil
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
describe '#description' do
|
|
49
|
+
|
|
50
|
+
it "should expose the second parameter as description" do
|
|
51
|
+
Micronaut::Behaviour.describe(Foo, "my desc") { }.description.should == 'my desc'
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
it "should allow the second parameter to be nil" do
|
|
55
|
+
Micronaut::Behaviour.describe(Foo, nil) { }.description.size.should == 0
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe '#options' do
|
|
61
|
+
|
|
62
|
+
it "should expose the third parameter as options" do
|
|
63
|
+
Micronaut::Behaviour.describe(Foo, nil, 'foo' => 'bar') { }.options.should == { "foo" => 'bar' }
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "should be an empty hash if no options are supplied" do
|
|
67
|
+
Micronaut::Behaviour.describe(Foo, nil) { }.options.should == {}
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
describe "adding before and after hooks" do
|
|
73
|
+
|
|
74
|
+
it "should expose the before each blocks at before_eachs" do
|
|
75
|
+
group = empty_behaviour_group
|
|
76
|
+
group.before(:each) { 'foo' }
|
|
77
|
+
group.should have(1).before_eachs
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "should maintain the before each block order" do
|
|
81
|
+
group = empty_behaviour_group
|
|
82
|
+
group.before(:each) { 15 }
|
|
83
|
+
group.before(:each) { 'A' }
|
|
84
|
+
group.before(:each) { 33.5 }
|
|
85
|
+
|
|
86
|
+
group.before_eachs[0].last.call.should == 15
|
|
87
|
+
group.before_eachs[1].last.call.should == 'A'
|
|
88
|
+
group.before_eachs[2].last.call.should == 33.5
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
it "should expose the before all blocks at before_alls" do
|
|
92
|
+
group = empty_behaviour_group
|
|
93
|
+
group.before(:all) { 'foo' }
|
|
94
|
+
group.should have(1).before_alls
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
it "should maintain the before all block order" do
|
|
98
|
+
group = empty_behaviour_group
|
|
99
|
+
group.before(:all) { 15 }
|
|
100
|
+
group.before(:all) { 'A' }
|
|
101
|
+
group.before(:all) { 33.5 }
|
|
102
|
+
|
|
103
|
+
group.before_alls[0].last.call.should == 15
|
|
104
|
+
group.before_alls[1].last.call.should == 'A'
|
|
105
|
+
group.before_alls[2].last.call.should == 33.5
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
it "should expose the after each blocks at after_eachs" do
|
|
109
|
+
group = empty_behaviour_group
|
|
110
|
+
group.after(:each) { 'foo' }
|
|
111
|
+
group.should have(1).after_eachs
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "should maintain the after each block order" do
|
|
115
|
+
group = empty_behaviour_group
|
|
116
|
+
group.after(:each) { 15 }
|
|
117
|
+
group.after(:each) { 'A' }
|
|
118
|
+
group.after(:each) { 33.5 }
|
|
119
|
+
|
|
120
|
+
group.after_eachs[0].last.call.should == 15
|
|
121
|
+
group.after_eachs[1].last.call.should == 'A'
|
|
122
|
+
group.after_eachs[2].last.call.should == 33.5
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
it "should expose the after all blocks at after_alls" do
|
|
126
|
+
group = empty_behaviour_group
|
|
127
|
+
group.after(:all) { 'foo' }
|
|
128
|
+
group.should have(1).after_alls
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it "should maintain the after each block order" do
|
|
132
|
+
group = empty_behaviour_group
|
|
133
|
+
group.after(:all) { 15 }
|
|
134
|
+
group.after(:all) { 'A' }
|
|
135
|
+
group.after(:all) { 33.5 }
|
|
136
|
+
|
|
137
|
+
group.after_alls[0].last.call.should == 15
|
|
138
|
+
group.after_alls[1].last.call.should == 'A'
|
|
139
|
+
group.after_alls[2].last.call.should == 33.5
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
describe "adding examples" do
|
|
145
|
+
|
|
146
|
+
it "should allow adding an example using 'it'" do
|
|
147
|
+
group = empty_behaviour_group
|
|
148
|
+
group.it("should do something") { }
|
|
149
|
+
group.examples.size.should == 1
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
it "should expose all examples at examples" do
|
|
153
|
+
group = empty_behaviour_group
|
|
154
|
+
group.it("should do something 1") { }
|
|
155
|
+
group.it("should do something 2") { }
|
|
156
|
+
group.it("should do something 3") { }
|
|
157
|
+
group.examples.size.should == 3
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "should maintain the example order" do
|
|
161
|
+
group = empty_behaviour_group
|
|
162
|
+
group.it("should 1") { }
|
|
163
|
+
group.it("should 2") { }
|
|
164
|
+
group.it("should 3") { }
|
|
165
|
+
group.examples[0].description.should == 'should 1'
|
|
166
|
+
group.examples[1].description.should == 'should 2'
|
|
167
|
+
group.examples[2].description.should == 'should 3'
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
before { @wee = 1 }
|
|
175
|
+
|
|
176
|
+
describe "nested describes" do
|
|
177
|
+
|
|
178
|
+
before { @wee += 5 }
|
|
179
|
+
|
|
180
|
+
it "should set the described type to the parent described type (if it is not given)"
|
|
181
|
+
|
|
182
|
+
it "should have all of the parent before blocks" do
|
|
183
|
+
@wee.should == 6
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
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 include the mocha adapter when called with :mocha" do
|
|
8
|
+
Micronaut::Behaviour.expects(:send).with(:include, Micronaut::Mocking::WithMocha)
|
|
9
|
+
Micronaut::Configuration.new.mock_with :mocha
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should include the do absolutely nothing mocking adapter for all other cases" do
|
|
13
|
+
Micronaut::Behaviour.expects(:send).with(:include, Micronaut::Mocking::WithAbsolutelyNothing)
|
|
14
|
+
Micronaut::Configuration.new.mock_with
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe "#include" do
|
|
20
|
+
|
|
21
|
+
module InstanceLevelMethods
|
|
22
|
+
def you_call_this_a_blt?
|
|
23
|
+
"egad man, where's the mayo?!?!?"
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should include the given module into each behaviour group" do
|
|
28
|
+
Micronaut.configuration.include(InstanceLevelMethods)
|
|
29
|
+
group = Micronaut::Behaviour.describe(Object, 'does like, stuff and junk') { }
|
|
30
|
+
group.should_not respond_to(:you_call_this_a_blt?)
|
|
31
|
+
remove_last_describe_from_world
|
|
32
|
+
|
|
33
|
+
group.new.you_call_this_a_blt?.should == "egad man, where's the mayo?!?!?"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "#extend" do
|
|
39
|
+
|
|
40
|
+
module FocusedSupport
|
|
41
|
+
|
|
42
|
+
def fit(desc, options={}, &block)
|
|
43
|
+
it(desc, options.update(:focused => true), &block)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should extend the given module into each behaviour group" do
|
|
49
|
+
Micronaut.configuration.extend(FocusedSupport)
|
|
50
|
+
group = Micronaut::Behaviour.describe(FocusedSupport, 'the focused support ') { }
|
|
51
|
+
group.should respond_to(:fit)
|
|
52
|
+
remove_last_describe_from_world
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
describe "#run_all_when_everything_filtered" do
|
|
58
|
+
|
|
59
|
+
it "defaults to true" do
|
|
60
|
+
Micronaut::Configuration.new.run_all_when_everything_filtered.should == true
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "can be queried with question method" do
|
|
64
|
+
config = Micronaut::Configuration.new
|
|
65
|
+
config.run_all_when_everything_filtered = false
|
|
66
|
+
config.run_all_when_everything_filtered?.should == false
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../example_helper")
|
|
2
|
+
|
|
3
|
+
describe Micronaut::Example do
|
|
4
|
+
|
|
5
|
+
before do
|
|
6
|
+
behaviour = stub('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 options" do
|
|
21
|
+
@example.should respond_to(:options)
|
|
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
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
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,31 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../../../example_helper")
|
|
2
|
+
|
|
3
|
+
describe Micronaut::Matchers do
|
|
4
|
+
|
|
5
|
+
describe "wrap_expectation" do
|
|
6
|
+
|
|
7
|
+
def stub_matcher
|
|
8
|
+
@_stub_matcher ||= simple_matcher do
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def failing_matcher
|
|
13
|
+
@_failing_matcher ||= simple_matcher do
|
|
14
|
+
1.should == 2
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should return true if there is no error" do
|
|
19
|
+
wrap_expectation stub_matcher do
|
|
20
|
+
end.should be_true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
it "should return false if there is an error" do
|
|
24
|
+
wrap_expectation failing_matcher do
|
|
25
|
+
raise "error"
|
|
26
|
+
end.should be_false
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
end
|