dchelimsky-rspec 1.1.10 → 1.1.11
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 +17 -0
- data/Manifest.txt +53 -74
- data/Rakefile +0 -1
- data/examples/{pure → passing}/autogenerated_docstrings_example.rb +6 -0
- data/examples/{pure → passing}/before_and_after_example.rb +0 -0
- data/examples/{pure → passing}/behave_as_example.rb +0 -0
- data/examples/{pure → passing}/custom_expectation_matchers.rb +0 -0
- data/examples/{pure → passing}/custom_formatter.rb +1 -1
- data/examples/{pure → passing}/dynamic_spec.rb +2 -2
- data/examples/{pure → passing}/file_accessor.rb +0 -0
- data/examples/{pure → passing}/file_accessor_spec.rb +0 -0
- data/examples/{pure → passing}/greeter_spec.rb +0 -0
- data/examples/{pure → passing}/helper_method_example.rb +0 -0
- data/examples/{pure → passing}/io_processor.rb +0 -0
- data/examples/{pure → passing}/io_processor_spec.rb +0 -0
- data/examples/{pure → passing}/legacy_spec.rb +0 -0
- data/examples/{pure → passing}/mocking_example.rb +0 -0
- data/examples/{pure → passing}/multi_threaded_behaviour_runner.rb +0 -0
- data/examples/{pure → passing}/nested_classes_example.rb +0 -0
- data/examples/{pure → passing}/partial_mock_example.rb +0 -0
- data/examples/{pure → passing}/pending_example.rb +0 -0
- data/examples/{pure → passing}/predicate_example.rb +0 -0
- data/examples/{pure → passing}/priority.txt +0 -0
- data/examples/{pure → passing}/shared_example_group_example.rb +0 -0
- data/examples/{pure → passing}/shared_stack_examples.rb +1 -3
- data/examples/{pure → passing}/spec_helper.rb +0 -0
- data/examples/{pure → passing}/stack.rb +0 -0
- data/examples/{pure → passing}/stack_spec.rb +3 -2
- data/examples/{pure → passing}/stack_spec_with_nested_example_groups.rb +0 -0
- data/examples/{pure → passing}/stubbing_example.rb +0 -0
- data/examples/{pure → passing}/yielding_example.rb +0 -0
- data/lib/spec/example/before_and_after_hooks.rb +8 -21
- data/lib/spec/example/configuration.rb +45 -45
- data/lib/spec/example/example_group_factory.rb +10 -9
- data/lib/spec/example/example_group_methods.rb +31 -15
- data/lib/spec/example/example_methods.rb +74 -22
- data/lib/spec/example/shared_example_group.rb +27 -16
- data/lib/spec/example.rb +28 -0
- data/lib/spec/expectations.rb +1 -0
- data/lib/spec/extensions.rb +0 -2
- data/lib/spec/matchers/be.rb +96 -114
- data/lib/spec/matchers/operator_matcher.rb +2 -9
- data/lib/spec/matchers/throw_symbol.rb +41 -15
- data/lib/spec/matchers.rb +4 -27
- data/lib/spec/runner/formatter/base_text_formatter.rb +1 -1
- data/lib/spec/runner/option_parser.rb +2 -2
- data/lib/spec/runner/reporter.rb +1 -1
- data/lib/spec/runner.rb +1 -1
- data/lib/spec/version.rb +1 -1
- data/lib/spec.rb +1 -0
- data/rspec.gemspec +4 -24
- data/spec/spec/example/example_group_factory_spec.rb +29 -9
- data/spec/spec/example/example_group_methods_spec.rb +4 -6
- data/spec/spec/example/example_group_spec.rb +0 -6
- data/spec/spec/example/example_matcher_spec.rb +6 -23
- data/spec/spec/example/example_methods_spec.rb +117 -2
- data/spec/spec/example/shared_example_group_spec.rb +51 -75
- data/spec/spec/matchers/be_spec.rb +40 -7
- data/spec/spec/matchers/description_generation_spec.rb +14 -0
- data/spec/spec/matchers/throw_symbol_spec.rb +83 -41
- data/spec/spec/runner/command_line_spec.rb +4 -4
- data/spec/spec/runner/formatter/html_formatted-1.8.4.html +6 -6
- data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +9 -9
- data/spec/spec/runner/formatter/html_formatted-1.8.5.html +6 -6
- data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +10 -10
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +6 -6
- data/spec/spec/runner/formatter/html_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +6 -6
- data/spec/spec/runner/reporter_spec.rb +1 -1
- data/stories/example_groups/autogenerated_docstrings +4 -4
- data/stories/example_groups/nested_groups +2 -2
- metadata +33 -59
- data/examples/stories/adder.rb +0 -13
- data/examples/stories/addition +0 -34
- data/examples/stories/addition.rb +0 -9
- data/examples/stories/calculator.rb +0 -65
- data/examples/stories/game-of-life/.loadpath +0 -5
- data/examples/stories/game-of-life/README.txt +0 -21
- data/examples/stories/game-of-life/behaviour/everything.rb +0 -6
- data/examples/stories/game-of-life/behaviour/examples/examples.rb +0 -3
- data/examples/stories/game-of-life/behaviour/examples/game_behaviour.rb +0 -35
- data/examples/stories/game-of-life/behaviour/examples/grid_behaviour.rb +0 -66
- data/examples/stories/game-of-life/behaviour/stories/CellsWithLessThanTwoNeighboursDie.story +0 -21
- data/examples/stories/game-of-life/behaviour/stories/CellsWithMoreThanThreeNeighboursDie.story +0 -21
- data/examples/stories/game-of-life/behaviour/stories/EmptySpacesWithThreeNeighboursCreateACell.story +0 -42
- data/examples/stories/game-of-life/behaviour/stories/ICanCreateACell.story +0 -42
- data/examples/stories/game-of-life/behaviour/stories/ICanKillACell.story +0 -17
- data/examples/stories/game-of-life/behaviour/stories/TheGridWraps.story +0 -53
- data/examples/stories/game-of-life/behaviour/stories/create_a_cell.rb +0 -52
- data/examples/stories/game-of-life/behaviour/stories/helper.rb +0 -6
- data/examples/stories/game-of-life/behaviour/stories/kill_a_cell.rb +0 -26
- data/examples/stories/game-of-life/behaviour/stories/steps.rb +0 -5
- data/examples/stories/game-of-life/behaviour/stories/stories.rb +0 -3
- data/examples/stories/game-of-life/behaviour/stories/stories.txt +0 -22
- data/examples/stories/game-of-life/life/game.rb +0 -23
- data/examples/stories/game-of-life/life/grid.rb +0 -43
- data/examples/stories/game-of-life/life.rb +0 -3
- data/examples/stories/helper.rb +0 -9
- data/examples/stories/steps/addition_steps.rb +0 -18
- data/failing_examples/README.txt +0 -7
- data/failing_examples/diffing_spec.rb +0 -36
- data/failing_examples/failing_autogenerated_docstrings_example.rb +0 -19
- data/failing_examples/failure_in_setup.rb +0 -10
- data/failing_examples/failure_in_teardown.rb +0 -10
- data/failing_examples/mocking_example.rb +0 -40
- data/failing_examples/mocking_with_flexmock.rb +0 -26
- data/failing_examples/mocking_with_mocha.rb +0 -25
- data/failing_examples/mocking_with_rr.rb +0 -27
- data/failing_examples/partial_mock_example.rb +0 -20
- data/failing_examples/predicate_example.rb +0 -29
- data/failing_examples/raising_example.rb +0 -47
- data/failing_examples/spec_helper.rb +0 -3
- data/failing_examples/syntax_error_example.rb +0 -7
- data/failing_examples/team_spec.rb +0 -44
- data/failing_examples/timeout_behaviour.rb +0 -7
- data/lib/spec/extensions/main.rb +0 -87
- data/lib/spec/extensions/object.rb +0 -6
- data/spec/spec/extensions/main_spec.rb +0 -71
data/History.txt
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
=== Maintenance
|
2
|
+
|
3
|
+
* 2 major enhancements
|
4
|
+
|
5
|
+
* it { should matcher } - syntax support from Joe Ferris
|
6
|
+
* wrap_expectation (for wrapping multiple expectations and/or t/u assertions)
|
7
|
+
|
8
|
+
* 1 minor enhancement
|
9
|
+
|
10
|
+
* should throw_symbol accepts an optional argument: should throw_symbol(:sym, arg)
|
11
|
+
|
12
|
+
=== Version 1.1.11 / 2008-10-24
|
13
|
+
|
14
|
+
* 1 major enhancement
|
15
|
+
|
16
|
+
* eliminate ALL gem dependencies (as they were causing trouble for people on different platforms/environments)
|
17
|
+
|
1
18
|
=== Version 1.1.10 / 2008-10-24
|
2
19
|
|
3
20
|
* 1 minor enhancement
|
data/Manifest.txt
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
.autotest
|
1
2
|
History.txt
|
2
3
|
License.txt
|
3
4
|
Manifest.txt
|
@@ -6,77 +7,50 @@ Rakefile
|
|
6
7
|
TODO.txt
|
7
8
|
bin/autospec
|
8
9
|
bin/spec
|
9
|
-
examples/
|
10
|
-
examples/
|
11
|
-
examples/
|
12
|
-
examples/
|
13
|
-
examples/
|
14
|
-
examples/
|
15
|
-
examples/
|
16
|
-
examples/
|
17
|
-
examples/
|
18
|
-
examples/
|
19
|
-
examples/
|
20
|
-
examples/
|
21
|
-
examples/
|
22
|
-
examples/
|
23
|
-
examples/
|
24
|
-
examples/
|
25
|
-
examples/
|
26
|
-
examples/
|
27
|
-
examples/
|
28
|
-
examples/
|
29
|
-
examples/
|
30
|
-
examples/
|
31
|
-
examples/
|
32
|
-
examples/
|
33
|
-
examples/
|
34
|
-
examples/
|
35
|
-
examples/
|
36
|
-
examples/
|
37
|
-
examples/
|
38
|
-
examples/
|
39
|
-
examples/
|
40
|
-
examples/
|
41
|
-
examples/
|
42
|
-
examples/
|
43
|
-
examples/
|
44
|
-
examples/
|
45
|
-
examples/
|
46
|
-
examples/
|
47
|
-
examples/
|
48
|
-
examples/
|
49
|
-
examples/
|
50
|
-
examples/
|
51
|
-
examples/
|
52
|
-
examples/
|
53
|
-
examples/stories/game-of-life/behaviour/stories/create_a_cell.rb
|
54
|
-
examples/stories/game-of-life/behaviour/stories/helper.rb
|
55
|
-
examples/stories/game-of-life/behaviour/stories/kill_a_cell.rb
|
56
|
-
examples/stories/game-of-life/behaviour/stories/steps.rb
|
57
|
-
examples/stories/game-of-life/behaviour/stories/stories.rb
|
58
|
-
examples/stories/game-of-life/behaviour/stories/stories.txt
|
59
|
-
examples/stories/game-of-life/life.rb
|
60
|
-
examples/stories/game-of-life/life/game.rb
|
61
|
-
examples/stories/game-of-life/life/grid.rb
|
62
|
-
examples/stories/helper.rb
|
63
|
-
examples/stories/steps/addition_steps.rb
|
64
|
-
failing_examples/README.txt
|
65
|
-
failing_examples/diffing_spec.rb
|
66
|
-
failing_examples/failing_autogenerated_docstrings_example.rb
|
67
|
-
failing_examples/failure_in_setup.rb
|
68
|
-
failing_examples/failure_in_teardown.rb
|
69
|
-
failing_examples/mocking_example.rb
|
70
|
-
failing_examples/mocking_with_flexmock.rb
|
71
|
-
failing_examples/mocking_with_mocha.rb
|
72
|
-
failing_examples/mocking_with_rr.rb
|
73
|
-
failing_examples/partial_mock_example.rb
|
74
|
-
failing_examples/predicate_example.rb
|
75
|
-
failing_examples/raising_example.rb
|
76
|
-
failing_examples/spec_helper.rb
|
77
|
-
failing_examples/syntax_error_example.rb
|
78
|
-
failing_examples/team_spec.rb
|
79
|
-
failing_examples/timeout_behaviour.rb
|
10
|
+
examples/failing/README.txt
|
11
|
+
examples/failing/diffing_spec.rb
|
12
|
+
examples/failing/failing_autogenerated_docstrings_example.rb
|
13
|
+
examples/failing/failure_in_setup.rb
|
14
|
+
examples/failing/failure_in_teardown.rb
|
15
|
+
examples/failing/mocking_example.rb
|
16
|
+
examples/failing/mocking_with_flexmock.rb
|
17
|
+
examples/failing/mocking_with_mocha.rb
|
18
|
+
examples/failing/mocking_with_rr.rb
|
19
|
+
examples/failing/partial_mock_example.rb
|
20
|
+
examples/failing/predicate_example.rb
|
21
|
+
examples/failing/raising_example.rb
|
22
|
+
examples/failing/spec_helper.rb
|
23
|
+
examples/failing/syntax_error_example.rb
|
24
|
+
examples/failing/team_spec.rb
|
25
|
+
examples/failing/timeout_behaviour.rb
|
26
|
+
examples/passing/autogenerated_docstrings_example.rb
|
27
|
+
examples/passing/before_and_after_example.rb
|
28
|
+
examples/passing/behave_as_example.rb
|
29
|
+
examples/passing/custom_expectation_matchers.rb
|
30
|
+
examples/passing/custom_formatter.rb
|
31
|
+
examples/passing/dynamic_spec.rb
|
32
|
+
examples/passing/file_accessor.rb
|
33
|
+
examples/passing/file_accessor_spec.rb
|
34
|
+
examples/passing/greeter_spec.rb
|
35
|
+
examples/passing/helper_method_example.rb
|
36
|
+
examples/passing/io_processor.rb
|
37
|
+
examples/passing/io_processor_spec.rb
|
38
|
+
examples/passing/legacy_spec.rb
|
39
|
+
examples/passing/mocking_example.rb
|
40
|
+
examples/passing/multi_threaded_behaviour_runner.rb
|
41
|
+
examples/passing/nested_classes_example.rb
|
42
|
+
examples/passing/partial_mock_example.rb
|
43
|
+
examples/passing/pending_example.rb
|
44
|
+
examples/passing/predicate_example.rb
|
45
|
+
examples/passing/priority.txt
|
46
|
+
examples/passing/shared_example_group_example.rb
|
47
|
+
examples/passing/shared_stack_examples.rb
|
48
|
+
examples/passing/spec_helper.rb
|
49
|
+
examples/passing/stack.rb
|
50
|
+
examples/passing/stack_spec.rb
|
51
|
+
examples/passing/stack_spec_with_nested_example_groups.rb
|
52
|
+
examples/passing/stubbing_example.rb
|
53
|
+
examples/passing/yielding_example.rb
|
80
54
|
init.rb
|
81
55
|
lib/autotest/discover.rb
|
82
56
|
lib/autotest/rspec.rb
|
@@ -85,6 +59,8 @@ lib/spec/adapters.rb
|
|
85
59
|
lib/spec/adapters/ruby_engine.rb
|
86
60
|
lib/spec/adapters/ruby_engine/mri.rb
|
87
61
|
lib/spec/adapters/ruby_engine/rubinius.rb
|
62
|
+
lib/spec/dsl.rb
|
63
|
+
lib/spec/dsl/main.rb
|
88
64
|
lib/spec/example.rb
|
89
65
|
lib/spec/example/before_and_after_hooks.rb
|
90
66
|
lib/spec/example/configuration.rb
|
@@ -104,11 +80,10 @@ lib/spec/expectations/extensions.rb
|
|
104
80
|
lib/spec/expectations/extensions/object.rb
|
105
81
|
lib/spec/expectations/extensions/string_and_symbol.rb
|
106
82
|
lib/spec/expectations/handler.rb
|
83
|
+
lib/spec/expectations/wrap_expectation.rb
|
107
84
|
lib/spec/extensions.rb
|
108
85
|
lib/spec/extensions/class.rb
|
109
|
-
lib/spec/extensions/main.rb
|
110
86
|
lib/spec/extensions/metaclass.rb
|
111
|
-
lib/spec/extensions/object.rb
|
112
87
|
lib/spec/interop/test.rb
|
113
88
|
lib/spec/interop/test/unit/autorunner.rb
|
114
89
|
lib/spec/interop/test/unit/testcase.rb
|
@@ -121,11 +96,14 @@ lib/spec/matchers/be_close.rb
|
|
121
96
|
lib/spec/matchers/change.rb
|
122
97
|
lib/spec/matchers/eql.rb
|
123
98
|
lib/spec/matchers/equal.rb
|
99
|
+
lib/spec/matchers/errors.rb
|
124
100
|
lib/spec/matchers/exist.rb
|
101
|
+
lib/spec/matchers/generated_descriptions.rb
|
125
102
|
lib/spec/matchers/has.rb
|
126
103
|
lib/spec/matchers/have.rb
|
127
104
|
lib/spec/matchers/include.rb
|
128
105
|
lib/spec/matchers/match.rb
|
106
|
+
lib/spec/matchers/method_missing.rb
|
129
107
|
lib/spec/matchers/operator_matcher.rb
|
130
108
|
lib/spec/matchers/raise_error.rb
|
131
109
|
lib/spec/matchers/respond_to.rb
|
@@ -213,6 +191,7 @@ spec/rspec_suite.rb
|
|
213
191
|
spec/ruby_forker.rb
|
214
192
|
spec/spec.opts
|
215
193
|
spec/spec/adapters/ruby_engine_spec.rb
|
194
|
+
spec/spec/dsl/main_spec.rb
|
216
195
|
spec/spec/example/configuration_spec.rb
|
217
196
|
spec/spec/example/example_group_class_definition_spec.rb
|
218
197
|
spec/spec/example/example_group_factory_spec.rb
|
@@ -229,7 +208,7 @@ spec/spec/example/subclassing_example_group_spec.rb
|
|
229
208
|
spec/spec/expectations/differs/default_spec.rb
|
230
209
|
spec/spec/expectations/extensions/object_spec.rb
|
231
210
|
spec/spec/expectations/fail_with_spec.rb
|
232
|
-
spec/spec/
|
211
|
+
spec/spec/expectations/wrap_expectation_spec.rb
|
233
212
|
spec/spec/interop/test/unit/resources/spec_that_fails.rb
|
234
213
|
spec/spec/interop/test/unit/resources/spec_that_passes.rb
|
235
214
|
spec/spec/interop/test/unit/resources/spec_with_errors.rb
|
data/Rakefile
CHANGED
@@ -18,7 +18,6 @@ Hoe.new('rspec', Spec::VERSION::STRING) do |p|
|
|
18
18
|
p.url = 'http://rspec.info/'
|
19
19
|
p.description = "Behaviour Driven Development for Ruby."
|
20
20
|
p.rubyforge_name = 'rspec'
|
21
|
-
p.extra_dev_deps = ['diff-lcs','syntax']
|
22
21
|
p.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
|
23
22
|
p.remote_rdoc_dir = "rspec/#{Spec::VERSION::STRING}"
|
24
23
|
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,7 +2,7 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
require 'spec/runner/formatter/progress_bar_formatter'
|
3
3
|
|
4
4
|
# Example of a formatter with custom bactrace printing. Run me with:
|
5
|
-
# ruby bin/spec
|
5
|
+
# ruby bin/spec examples/failing -r examples/custom_formatter.rb -f CustomFormatter
|
6
6
|
class CustomFormatter < Spec::Runner::Formatter::ProgressBarFormatter
|
7
7
|
def backtrace_line(line)
|
8
8
|
line.gsub(/([^:]*\.rb):(\d*)/) do
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), *%w[spec_helper])
|
2
|
-
|
3
1
|
shared_examples_for "non-empty Stack" do
|
4
2
|
|
5
3
|
it { @stack.should_not be_empty }
|
@@ -7,7 +5,7 @@ shared_examples_for "non-empty Stack" do
|
|
7
5
|
it "should return the top item when sent #peek" do
|
8
6
|
@stack.peek.should == @last_item_added
|
9
7
|
end
|
10
|
-
|
8
|
+
|
11
9
|
it "should NOT remove the top item when sent #peek" do
|
12
10
|
@stack.peek.should == @last_item_added
|
13
11
|
@stack.peek.should == @last_item_added
|
File without changes
|
File without changes
|
@@ -7,8 +7,9 @@ describe Stack, " (empty)" do
|
|
7
7
|
@stack = Stack.new
|
8
8
|
end
|
9
9
|
|
10
|
-
#
|
11
|
-
|
10
|
+
# This uses @stack (because the described class is Stack) auto-generates the
|
11
|
+
# description "should be empty"
|
12
|
+
it { should be_empty }
|
12
13
|
|
13
14
|
it_should_behave_like "non-full Stack"
|
14
15
|
|
File without changes
|
File without changes
|
File without changes
|
@@ -4,35 +4,27 @@ module Spec
|
|
4
4
|
# Registers a block to be executed before each example.
|
5
5
|
# This method prepends +block+ to existing before blocks.
|
6
6
|
def prepend_before(*args, &block)
|
7
|
-
|
8
|
-
parts = before_parts_from_scope(scope)
|
9
|
-
parts.unshift(block)
|
7
|
+
before_parts(*args).unshift(block)
|
10
8
|
end
|
11
9
|
|
12
10
|
# Registers a block to be executed before each example.
|
13
11
|
# This method appends +block+ to existing before blocks.
|
14
12
|
def append_before(*args, &block)
|
15
|
-
|
16
|
-
parts = before_parts_from_scope(scope)
|
17
|
-
parts << block
|
13
|
+
before_parts(*args) << block
|
18
14
|
end
|
19
15
|
alias_method :before, :append_before
|
20
16
|
|
21
17
|
# Registers a block to be executed after each example.
|
22
18
|
# This method prepends +block+ to existing after blocks.
|
23
19
|
def prepend_after(*args, &block)
|
24
|
-
|
25
|
-
parts = after_parts_from_scope(scope)
|
26
|
-
parts.unshift(block)
|
20
|
+
after_parts(*args).unshift(block)
|
27
21
|
end
|
28
22
|
alias_method :after, :prepend_after
|
29
23
|
|
30
24
|
# Registers a block to be executed after each example.
|
31
25
|
# This method appends +block+ to existing after blocks.
|
32
26
|
def append_after(*args, &block)
|
33
|
-
|
34
|
-
parts = after_parts_from_scope(scope)
|
35
|
-
parts << block
|
27
|
+
after_parts(*args) << block
|
36
28
|
end
|
37
29
|
|
38
30
|
def remove_after(scope, &block)
|
@@ -67,21 +59,16 @@ module Spec
|
|
67
59
|
|
68
60
|
private
|
69
61
|
|
70
|
-
def
|
71
|
-
|
72
|
-
scope = (args[0] || :each), options
|
73
|
-
end
|
74
|
-
|
75
|
-
def before_parts_from_scope(scope)
|
76
|
-
case scope
|
62
|
+
def before_parts(*args)
|
63
|
+
case Spec::Example.scope_from(*args)
|
77
64
|
when :each; before_each_parts
|
78
65
|
when :all; before_all_parts
|
79
66
|
when :suite; Spec::Runner.options.before_suite_parts
|
80
67
|
end
|
81
68
|
end
|
82
69
|
|
83
|
-
def
|
84
|
-
case
|
70
|
+
def after_parts(*args)
|
71
|
+
case Spec::Example.scope_from(*args)
|
85
72
|
when :each; after_each_parts
|
86
73
|
when :all; after_all_parts
|
87
74
|
when :suite; Spec::Runner.options.after_suite_parts
|
@@ -47,44 +47,48 @@ module Spec
|
|
47
47
|
# include(My::Helpers, :type => :key)
|
48
48
|
#
|
49
49
|
# Declares modules to be included in multiple example groups
|
50
|
-
# (<tt>describe</tt> blocks). With no
|
51
|
-
# included in all example groups.
|
52
|
-
# a subset of example groups. The value assigned to :type should be a
|
53
|
-
# key that maps to a class that is either a subclass of
|
54
|
-
# Spec::Example::ExampleGroup or extends Spec::Example::ExampleGroupMethods
|
55
|
-
# and includes Spec::Example::ExampleMethods
|
50
|
+
# (<tt>describe</tt> blocks). With no <tt>:type</tt>, the modules listed
|
51
|
+
# will be included in all example groups.
|
56
52
|
#
|
57
|
-
#
|
53
|
+
# Use <tt>:type</tt> to restrict
|
54
|
+
# the inclusion to a subset of example groups. The value assigned to
|
55
|
+
# <tt>:type</tt> should be a key that maps to a class that is either a
|
56
|
+
# subclass of Spec::Example::ExampleGroup or extends
|
57
|
+
# Spec::Example::ExampleGroupMethods and includes
|
58
|
+
# Spec::Example::ExampleMethods.
|
59
|
+
#
|
60
|
+
# For example, the rspec-rails gem/plugin extends Test::Unit::TestCase
|
61
|
+
# with Spec::Example::ExampleGroupMethods and includes
|
62
|
+
# Spec::Example::ExampleMethods in it. So if you have a module of helper
|
63
|
+
# methods for controller examples, you could do this:
|
64
|
+
#
|
65
|
+
# config.include(ControllerExampleHelpers, :type => :controller)
|
58
66
|
#
|
59
67
|
# Only example groups that have that type will get the modules included:
|
60
68
|
#
|
61
|
-
# describe
|
62
|
-
# # Will *not*
|
69
|
+
# describe Account, :type => :model do
|
70
|
+
# # Will *not* include ControllerExampleHelpers
|
63
71
|
# end
|
64
72
|
#
|
65
|
-
# describe
|
66
|
-
# # *Will*
|
73
|
+
# describe AccountsController, :type => :controller do
|
74
|
+
# # *Will* include ControllerExampleHelpers
|
67
75
|
# end
|
68
76
|
#
|
69
77
|
def include(*args)
|
70
78
|
include_or_extend(:include, *args)
|
71
79
|
end
|
72
80
|
|
81
|
+
# :call-seq:
|
82
|
+
# extend(Some::Helpers)
|
83
|
+
# extend(Some::Helpers, More::Helpers)
|
84
|
+
# extend(My::Helpers, :type => :key)
|
85
|
+
#
|
86
|
+
# Works just like #include, but extends the example groups
|
87
|
+
# with the modules rather than including them.
|
73
88
|
def extend(*args)
|
74
89
|
include_or_extend(:extend, *args)
|
75
90
|
end
|
76
91
|
|
77
|
-
def include_or_extend(*args)
|
78
|
-
action = args.shift
|
79
|
-
args << {} unless Hash === args.last
|
80
|
-
modules, options = args_and_options(*args)
|
81
|
-
required_example_group = get_type_from_options(options)
|
82
|
-
required_example_group = required_example_group.to_sym if required_example_group
|
83
|
-
modules.each do |mod|
|
84
|
-
ExampleGroupFactory.get(required_example_group).send(action, mod)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
92
|
# Defines global predicate matchers. Example:
|
89
93
|
#
|
90
94
|
# config.predicate_matchers[:swim] = :can_swim?
|
@@ -100,11 +104,7 @@ module Spec
|
|
100
104
|
# Prepends a global <tt>before</tt> block to all example groups.
|
101
105
|
# See #append_before for filtering semantics.
|
102
106
|
def prepend_before(*args, &proc)
|
103
|
-
|
104
|
-
example_group = ExampleGroupFactory.get(
|
105
|
-
get_type_from_options(options)
|
106
|
-
)
|
107
|
-
example_group.prepend_before(scope, &proc)
|
107
|
+
add_callback(:prepend_before, *args, &proc)
|
108
108
|
end
|
109
109
|
|
110
110
|
# Appends a global <tt>before</tt> block to all example groups.
|
@@ -119,40 +119,40 @@ module Spec
|
|
119
119
|
# config.prepend_before(:type => :farm)
|
120
120
|
#
|
121
121
|
def append_before(*args, &proc)
|
122
|
-
|
123
|
-
example_group = ExampleGroupFactory.get(
|
124
|
-
get_type_from_options(options)
|
125
|
-
)
|
126
|
-
example_group.append_before(scope, &proc)
|
122
|
+
add_callback(:append_before, *args, &proc)
|
127
123
|
end
|
128
124
|
alias_method :before, :append_before
|
129
125
|
|
130
126
|
# Prepends a global <tt>after</tt> block to all example groups.
|
131
127
|
# See #append_before for filtering semantics.
|
132
128
|
def prepend_after(*args, &proc)
|
133
|
-
|
134
|
-
example_group = ExampleGroupFactory.get(
|
135
|
-
get_type_from_options(options)
|
136
|
-
)
|
137
|
-
example_group.prepend_after(scope, &proc)
|
129
|
+
add_callback(:prepend_after, *args, &proc)
|
138
130
|
end
|
139
131
|
alias_method :after, :prepend_after
|
140
132
|
|
141
133
|
# Appends a global <tt>after</tt> block to all example groups.
|
142
134
|
# See #append_before for filtering semantics.
|
143
135
|
def append_after(*args, &proc)
|
144
|
-
|
145
|
-
example_group = ExampleGroupFactory.get(
|
146
|
-
get_type_from_options(options)
|
147
|
-
)
|
148
|
-
example_group.append_after(scope, &proc)
|
136
|
+
add_callback(:append_after, *args, &proc)
|
149
137
|
end
|
150
138
|
|
151
139
|
private
|
140
|
+
|
141
|
+
def include_or_extend(*args)
|
142
|
+
action = args.shift
|
143
|
+
args << {} unless Hash === args.last
|
144
|
+
modules, options = Spec::Example.args_and_options(*args)
|
145
|
+
required_example_group = get_type_from_options(options)
|
146
|
+
required_example_group = required_example_group.to_sym if required_example_group
|
147
|
+
modules.each do |mod|
|
148
|
+
ExampleGroupFactory.get(required_example_group).send(action, mod)
|
149
|
+
end
|
150
|
+
end
|
152
151
|
|
153
|
-
def
|
154
|
-
|
155
|
-
|
152
|
+
def add_callback(sym, *args, &proc)
|
153
|
+
scope, options = Spec::Example.scope_and_options(*args)
|
154
|
+
example_group = ExampleGroupFactory.get(get_type_from_options(options))
|
155
|
+
example_group.__send__(sym, scope, &proc)
|
156
156
|
end
|
157
157
|
|
158
158
|
def get_type_from_options(options)
|
@@ -7,9 +7,11 @@ module Spec
|
|
7
7
|
default(ExampleGroup)
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def registered_or_ancestor_of_registered?(example_group_classes) # :nodoc:
|
11
11
|
example_group_classes.each do |example_group_class|
|
12
|
-
return false unless
|
12
|
+
return false unless registered_types.any? do |registered_type|
|
13
|
+
registered_type.ancestors.include? example_group_class
|
14
|
+
end
|
13
15
|
end
|
14
16
|
return true
|
15
17
|
end
|
@@ -48,11 +50,14 @@ module Spec
|
|
48
50
|
end
|
49
51
|
|
50
52
|
def create_example_group(*args, &block)
|
51
|
-
|
52
|
-
|
53
|
+
raise ArgumentError if args.empty?
|
54
|
+
raise ArgumentError unless block
|
55
|
+
args << {} unless Hash === args.last
|
56
|
+
args.last[:spec_path] ||= File.expand_path(caller(0)[2])
|
57
|
+
superclass = determine_superclass(args.last)
|
53
58
|
superclass.describe(*args, &block)
|
54
59
|
end
|
55
|
-
|
60
|
+
|
56
61
|
protected
|
57
62
|
|
58
63
|
def determine_superclass(opts)
|
@@ -66,10 +71,6 @@ module Spec
|
|
66
71
|
|
67
72
|
private
|
68
73
|
|
69
|
-
def registered_or_ancestor_of_registered? example_group_class
|
70
|
-
registered_types.any? {|registered_type| registered_type.ancestors.include? example_group_class}
|
71
|
-
end
|
72
|
-
|
73
74
|
def registered_types
|
74
75
|
@example_group_types.values
|
75
76
|
end
|