rspec 1.1.11 → 1.1.12
Sign up to get free protection for your applications and to get access to all the features.
- data/.autotest +4 -0
- data/History.txt +55 -0
- data/Manifest.txt +102 -122
- data/README.txt +30 -12
- data/Rakefile +10 -10
- data/TODO.txt +10 -2
- data/{failing_examples → examples/failing}/README.txt +0 -0
- data/{failing_examples → examples/failing}/diffing_spec.rb +0 -0
- data/{failing_examples → examples/failing}/failing_autogenerated_docstrings_example.rb +0 -0
- data/{failing_examples/failure_in_teardown.rb → examples/failing/failure_in_after.rb} +1 -1
- data/{failing_examples/failure_in_setup.rb → examples/failing/failure_in_before.rb} +1 -1
- data/{failing_examples → examples/failing}/mocking_example.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_flexmock.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_mocha.rb +0 -0
- data/{failing_examples → examples/failing}/mocking_with_rr.rb +0 -0
- data/{failing_examples → examples/failing}/partial_mock_example.rb +0 -0
- data/{failing_examples → examples/failing}/predicate_example.rb +5 -0
- data/{failing_examples → examples/failing}/raising_example.rb +0 -0
- data/{failing_examples → examples/failing}/spec_helper.rb +1 -1
- data/{failing_examples → examples/failing}/syntax_error_example.rb +0 -0
- data/{failing_examples → examples/failing}/team_spec.rb +0 -0
- data/{failing_examples → examples/failing}/timeout_behaviour.rb +0 -0
- 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/multi_threaded_behaviour_runner.rb → passing/multi_threaded_example_group_runner.rb} +1 -3
- 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/passing/simple_matcher_example.rb +31 -0
- 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/examples/ruby1.9.compatibility/access_to_constants_spec.rb +86 -0
- data/features/before_and_after_blocks/before_and_after_blocks.feature +168 -0
- data/{stories/example_groups/autogenerated_docstrings → features/example_groups/autogenerated_docstrings.feature} +5 -5
- data/{stories/example_groups/example_group_with_should_methods → features/example_groups/example_group_with_should_methods.feature} +3 -3
- data/{stories/example_groups/nested_groups → features/example_groups/nested_groups.feature} +4 -4
- data/{stories/example_groups/output → features/example_groups/output.feature} +3 -8
- data/{stories/interop/examples_and_tests_together → features/interop/examples_and_tests_together.feature} +5 -4
- data/features/interop/test_but_not_test_unit.feature +14 -0
- data/{stories/interop/test_case_with_should_methods → features/interop/test_case_with_should_methods.feature} +2 -2
- data/{stories/mock_framework_integration/use_flexmock.story → features/mock_framework_integration/use_flexmock.feature} +1 -1
- data/features/step_definitions/running_rspec.rb +54 -0
- data/features/support/env.rb +26 -0
- data/{stories/resources → features/support}/helpers/cmdline.rb +0 -0
- data/{stories/resources → features/support}/helpers/story_helper.rb +1 -1
- data/{stories/resources → features/support}/matchers/smart_match.rb +0 -0
- data/{plugins → lib/adapters}/mock_frameworks/flexmock.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/mocha.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/rr.rb +1 -1
- data/{plugins → lib/adapters}/mock_frameworks/rspec.rb +2 -2
- data/lib/autotest/rspec.rb +4 -3
- data/lib/spec.rb +2 -27
- data/lib/spec/dsl.rb +1 -0
- data/lib/spec/{extensions → dsl}/main.rb +10 -10
- data/lib/spec/example.rb +175 -1
- data/lib/spec/example/before_and_after_hooks.rb +30 -24
- data/lib/spec/example/example_group.rb +1 -0
- data/lib/spec/example/example_group_factory.rb +26 -9
- data/lib/spec/example/example_group_methods.rb +138 -113
- data/lib/spec/example/example_methods.rb +88 -25
- data/lib/spec/example/shared_example_group.rb +28 -21
- data/lib/spec/expectations.rb +22 -18
- data/lib/spec/expectations/handler.rb +16 -36
- data/lib/spec/interop/test/unit/testcase.rb +19 -17
- data/lib/spec/interop/test/unit/testresult.rb +1 -1
- data/lib/spec/interop/test/unit/testsuite_adapter.rb +1 -1
- data/lib/spec/matchers.rb +7 -28
- data/lib/spec/matchers/be.rb +103 -116
- data/lib/spec/matchers/be_close.rb +6 -22
- data/lib/spec/matchers/eql.rb +7 -25
- data/lib/spec/matchers/equal.rb +7 -25
- data/lib/spec/matchers/errors.rb +5 -0
- data/lib/spec/matchers/exist.rb +8 -14
- data/lib/spec/matchers/generated_descriptions.rb +48 -0
- data/lib/spec/matchers/has.rb +12 -28
- data/lib/spec/matchers/include.rb +12 -9
- data/lib/spec/matchers/match.rb +8 -27
- data/lib/spec/matchers/match_array.rb +79 -0
- data/lib/spec/matchers/method_missing.rb +9 -0
- data/lib/spec/matchers/operator_matcher.rb +39 -48
- data/lib/spec/matchers/raise_error.rb +4 -8
- data/lib/spec/matchers/respond_to.rb +33 -8
- data/lib/spec/matchers/throw_symbol.rb +49 -17
- data/lib/spec/matchers/wrap_expectation.rb +55 -0
- data/lib/spec/mocks/argument_constraints.rb +77 -5
- data/lib/spec/mocks/message_expectation.rb +7 -7
- data/lib/spec/mocks/proxy.rb +14 -12
- data/lib/spec/rake/spectask.rb +4 -6
- data/lib/spec/ruby.rb +9 -0
- data/lib/spec/runner.rb +37 -162
- data/lib/spec/runner/backtrace_tweaker.rb +5 -3
- data/lib/spec/runner/class_and_arguments_parser.rb +7 -9
- data/lib/spec/runner/command_line.rb +6 -8
- data/lib/spec/{example → runner}/configuration.rb +46 -47
- data/lib/spec/runner/example_group_runner.rb +15 -4
- data/lib/spec/runner/formatter/base_text_formatter.rb +4 -3
- data/lib/spec/runner/formatter/html_formatter.rb +14 -11
- data/lib/spec/runner/formatter/nested_text_formatter.rb +2 -2
- data/lib/spec/runner/heckle_runner.rb +58 -56
- data/lib/spec/runner/option_parser.rb +8 -4
- data/lib/spec/runner/options.rb +29 -14
- data/lib/spec/runner/reporter.rb +1 -1
- data/lib/spec/runner/spec_parser.rb +11 -9
- data/lib/spec/story/runner.rb +40 -42
- data/lib/spec/story/runner/story_runner.rb +10 -6
- data/lib/spec/story/world.rb +66 -70
- data/lib/spec/version.rb +4 -2
- data/{rake_tasks → resources/rake}/examples.rake +0 -0
- data/{rake_tasks → resources/rake}/examples_with_rcov.rake +0 -0
- data/{rake_tasks → resources/rake}/failing_examples_with_html.rake +0 -0
- data/{rake_tasks → resources/rake}/verify_rcov.rake +0 -0
- data/{stories/resources → resources}/spec/example_group_with_should_methods.rb +1 -1
- data/{stories/resources → resources}/spec/simple_spec.rb +1 -1
- data/resources/spec/spec_with_flexmock.rb +19 -0
- data/{stories/resources → resources}/test/spec_and_test_together.rb +1 -1
- data/resources/test/spec_including_test_but_not_unit.rb +11 -0
- data/{stories/resources → resources}/test/test_case_with_should_methods.rb +2 -2
- data/rspec.gemspec +16 -6
- data/spec/autotest/autotest_helper.rb +2 -2
- data/spec/autotest/discover_spec.rb +4 -15
- data/spec/autotest/failed_results_re_spec.rb +24 -0
- data/spec/autotest/rspec_spec.rb +2 -38
- data/spec/spec/dsl/main_spec.rb +88 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +6 -2
- data/spec/spec/example/example_group_factory_spec.rb +50 -10
- data/spec/spec/example/example_group_methods_spec.rb +210 -160
- data/spec/spec/example/example_group_spec.rb +44 -52
- data/spec/spec/example/example_matcher_spec.rb +6 -23
- data/spec/spec/example/example_methods_spec.rb +176 -54
- data/spec/spec/example/helper_method_spec.rb +24 -0
- data/spec/spec/example/pending_module_spec.rb +2 -8
- data/spec/spec/example/shared_example_group_spec.rb +56 -80
- data/spec/spec/expectations/extensions/object_spec.rb +0 -50
- data/spec/spec/expectations/wrap_expectation_spec.rb +30 -0
- data/spec/spec/interop/test/unit/spec_spec.rb +1 -5
- data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +4 -0
- data/spec/spec/matchers/be_close_spec.rb +12 -10
- data/spec/spec/matchers/be_spec.rb +62 -7
- data/spec/spec/matchers/description_generation_spec.rb +19 -0
- data/spec/spec/matchers/eql_spec.rb +7 -6
- data/spec/spec/matchers/equal_spec.rb +7 -6
- data/spec/spec/matchers/handler_spec.rb +4 -43
- data/spec/spec/matchers/has_spec.rb +1 -1
- data/spec/spec/matchers/have_spec.rb +23 -18
- data/spec/spec/matchers/include_spec.rb +24 -0
- data/spec/spec/matchers/match_array_spec.rb +83 -0
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -13
- data/spec/spec/matchers/raise_error_spec.rb +18 -0
- data/spec/spec/matchers/respond_to_spec.rb +71 -9
- data/spec/spec/matchers/throw_symbol_spec.rb +85 -43
- data/spec/spec/mocks/bug_report_11545_spec.rb +4 -5
- data/spec/spec/mocks/bug_report_496.rb +11 -9
- data/spec/spec/mocks/bug_report_600_spec.rb +22 -0
- data/spec/spec/mocks/hash_including_matcher_spec.rb +39 -2
- data/spec/spec/mocks/hash_not_including_matcher_spec.rb +67 -0
- data/spec/spec/mocks/mock_spec.rb +5 -6
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +2 -2
- data/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +18 -3
- data/spec/spec/mocks/stub_spec.rb +6 -0
- data/spec/spec/mocks/stubbed_message_expectations_spec.rb +14 -0
- data/spec/spec/runner/command_line_spec.rb +4 -4
- data/spec/spec/runner/configuration_spec.rb +301 -0
- data/spec/spec/runner/drb_command_line_spec.rb +4 -4
- data/spec/spec/runner/example_group_runner_spec.rb +33 -0
- data/spec/spec/runner/formatter/base_formatter_spec.rb +13 -102
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +23 -0
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +3 -3
- 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 +39 -30
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +379 -0
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +379 -0
- data/spec/spec/runner/formatter/html_formatter_spec.rb +14 -13
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +5 -5
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +7 -17
- data/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +18 -17
- data/spec/spec/runner/formatter/specdoc_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 +33 -30
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +373 -0
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +373 -0
- data/spec/spec/runner/heckler_spec.rb +16 -9
- data/spec/spec/runner/option_parser_spec.rb +3 -18
- data/spec/spec/runner/options_spec.rb +27 -8
- data/spec/spec/runner/reporter_spec.rb +5 -5
- data/spec/spec/runner/resources/custom_example_group_runner.rb +14 -0
- data/spec/spec/runner/resources/utf8_encoded.rb +7 -0
- data/spec/spec/runner/spec_parser_spec.rb +85 -79
- data/spec/spec/spec_spec.rb +21 -0
- data/spec/spec_helper.rb +9 -1
- data/story_server/prototype/javascripts/prototype.js +1 -1
- metadata +119 -131
- 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.rb +0 -3
- 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/helper.rb +0 -9
- data/examples/stories/steps/addition_steps.rb +0 -18
- data/lib/spec/adapters.rb +0 -1
- data/lib/spec/adapters/ruby_engine.rb +0 -26
- data/lib/spec/adapters/ruby_engine/mri.rb +0 -8
- data/lib/spec/adapters/ruby_engine/rubinius.rb +0 -8
- data/lib/spec/extensions.rb +0 -4
- data/lib/spec/extensions/class.rb +0 -24
- data/lib/spec/extensions/metaclass.rb +0 -7
- data/lib/spec/extensions/object.rb +0 -6
- data/spec/spec/adapters/ruby_engine_spec.rb +0 -16
- data/spec/spec/example/configuration_spec.rb +0 -296
- data/spec/spec/example/example_runner_spec.rb +0 -194
- data/spec/spec/extensions/main_spec.rb +0 -71
- data/stories/all.rb +0 -5
- data/stories/configuration/before_blocks.story +0 -21
- data/stories/configuration/stories.rb +0 -7
- data/stories/example_groups/stories.rb +0 -7
- data/stories/helper.rb +0 -6
- data/stories/interop/stories.rb +0 -7
- data/stories/mock_framework_integration/stories.rb +0 -7
- data/stories/pending_stories/README +0 -3
- data/stories/resources/spec/before_blocks_example.rb +0 -32
- data/stories/resources/spec/spec_with_flexmock.rb +0 -18
- data/stories/resources/steps/running_rspec.rb +0 -50
- data/stories/resources/stories/failing_story.rb +0 -15
- data/stories/stories/multiline_steps.story +0 -23
- data/stories/stories/steps/multiline_steps.rb +0 -13
- data/stories/stories/stories.rb +0 -6
@@ -9,9 +9,11 @@ module Spec
|
|
9
9
|
class NoisyBacktraceTweaker < BacktraceTweaker
|
10
10
|
def tweak_backtrace(error)
|
11
11
|
return if error.backtrace.nil?
|
12
|
-
error.backtrace.
|
12
|
+
tweaked = error.backtrace.collect do |line|
|
13
13
|
clean_up_double_slashes(line)
|
14
|
+
line
|
14
15
|
end
|
16
|
+
error.set_backtrace(tweaked)
|
15
17
|
end
|
16
18
|
end
|
17
19
|
|
@@ -40,7 +42,7 @@ module Spec
|
|
40
42
|
|
41
43
|
def tweak_backtrace(error)
|
42
44
|
return if error.backtrace.nil?
|
43
|
-
error.backtrace.collect
|
45
|
+
tweaked = error.backtrace.collect do |message|
|
44
46
|
clean_up_double_slashes(message)
|
45
47
|
kept_lines = message.split("\n").select do |line|
|
46
48
|
IGNORE_PATTERNS.each do |ignore|
|
@@ -49,7 +51,7 @@ module Spec
|
|
49
51
|
end
|
50
52
|
kept_lines.empty?? nil : kept_lines.join("\n")
|
51
53
|
end
|
52
|
-
error.
|
54
|
+
error.set_backtrace(tweaked.select {|line| line})
|
53
55
|
end
|
54
56
|
end
|
55
57
|
end
|
@@ -1,16 +1,14 @@
|
|
1
1
|
module Spec
|
2
2
|
module Runner
|
3
3
|
class ClassAndArgumentsParser
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
raise "Couldn't parse #{s.inspect}"
|
11
|
-
end
|
4
|
+
def self.parse(s)
|
5
|
+
if s =~ /([a-zA-Z_]+(?:::[a-zA-Z_]+)*):?(.*)/
|
6
|
+
arg = $2 == "" ? nil : $2
|
7
|
+
[$1, arg]
|
8
|
+
else
|
9
|
+
raise "Couldn't parse #{s.inspect}"
|
12
10
|
end
|
13
11
|
end
|
14
12
|
end
|
15
13
|
end
|
16
|
-
end
|
14
|
+
end
|
@@ -3,14 +3,12 @@ require 'spec/runner/option_parser'
|
|
3
3
|
module Spec
|
4
4
|
module Runner
|
5
5
|
class CommandLine
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Spec::Runner.use orig_options
|
13
|
-
end
|
6
|
+
def self.run(tmp_options=Spec::Runner.options)
|
7
|
+
orig_options = Spec::Runner.options
|
8
|
+
Spec::Runner.use tmp_options
|
9
|
+
tmp_options.run_examples
|
10
|
+
ensure
|
11
|
+
Spec::Runner.use orig_options
|
14
12
|
end
|
15
13
|
end
|
16
14
|
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module Spec
|
2
|
-
module
|
2
|
+
module Runner
|
3
3
|
class Configuration
|
4
4
|
# Chooses what mock framework to use. Example:
|
5
5
|
#
|
@@ -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,39 @@ 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(action, *args)
|
142
|
+
modules, options = Spec::Example.args_and_options(*args)
|
143
|
+
[get_type_from_options(options)].flatten.each do |required_example_group|
|
144
|
+
required_example_group = required_example_group.to_sym if required_example_group
|
145
|
+
modules.each do |mod|
|
146
|
+
Spec::Example::ExampleGroupFactory.get(required_example_group).__send__(action, mod)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
152
150
|
|
153
|
-
def
|
154
|
-
|
155
|
-
|
151
|
+
def add_callback(sym, *args, &proc)
|
152
|
+
scope, options = Spec::Example.scope_and_options(*args)
|
153
|
+
example_group = Spec::Example::ExampleGroupFactory.get(get_type_from_options(options))
|
154
|
+
example_group.__send__(sym, scope, &proc)
|
156
155
|
end
|
157
156
|
|
158
157
|
def get_type_from_options(options)
|
@@ -160,7 +159,7 @@ module Spec
|
|
160
159
|
end
|
161
160
|
|
162
161
|
def mock_framework_path(framework_name)
|
163
|
-
File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "
|
162
|
+
File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "adapters", "mock_frameworks", framework_name))
|
164
163
|
end
|
165
164
|
end
|
166
165
|
end
|
@@ -10,6 +10,7 @@ module Spec
|
|
10
10
|
# responsibility of the ExampleGroupRunner. Some implementations (like)
|
11
11
|
# the one using DRb may choose *not* to load files, but instead tell
|
12
12
|
# someone else to do it over the wire.
|
13
|
+
$KCODE = 'u' if RUBY_VERSION < '1.9'
|
13
14
|
files.each do |file|
|
14
15
|
load file
|
15
16
|
end
|
@@ -19,7 +20,7 @@ module Spec
|
|
19
20
|
prepare
|
20
21
|
success = true
|
21
22
|
example_groups.each do |example_group|
|
22
|
-
success = success & example_group.run
|
23
|
+
success = success & example_group.run(@options)
|
23
24
|
end
|
24
25
|
return success
|
25
26
|
ensure
|
@@ -53,7 +54,17 @@ module Spec
|
|
53
54
|
@options.number_of_examples
|
54
55
|
end
|
55
56
|
end
|
56
|
-
|
57
|
-
BehaviourRunner
|
57
|
+
|
58
|
+
class BehaviourRunner < ExampleGroupRunner
|
59
|
+
def initialize(options)
|
60
|
+
Kernel.warn <<-WARNING
|
61
|
+
DEPRECATED: The BeheviourRunner class is deprecated and will
|
62
|
+
be removed from rspec-1.2.
|
63
|
+
|
64
|
+
Use ExampleGroupRunner instead.
|
65
|
+
WARNING
|
66
|
+
super
|
67
|
+
end
|
68
|
+
end
|
58
69
|
end
|
59
|
-
end
|
70
|
+
end
|
@@ -14,6 +14,7 @@ module Spec
|
|
14
14
|
def initialize(options, where)
|
15
15
|
super
|
16
16
|
if where.is_a?(String)
|
17
|
+
FileUtils.mkdir_p(File.dirname(where))
|
17
18
|
@output = File.open(where, 'w')
|
18
19
|
else
|
19
20
|
@output = where
|
@@ -22,7 +23,7 @@ module Spec
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def example_pending(example, message, pending_caller)
|
25
|
-
@pending_examples << [example.
|
26
|
+
@pending_examples << [example.full_description, message, pending_caller]
|
26
27
|
end
|
27
28
|
|
28
29
|
def dump_failure(counter, failure)
|
@@ -69,8 +70,8 @@ module Spec
|
|
69
70
|
@output.puts
|
70
71
|
@output.puts "Pending:"
|
71
72
|
@pending_examples.each do |pending_example|
|
72
|
-
@output.puts "#{pending_example[0]} (#{pending_example[1]})"
|
73
|
-
@output.puts "
|
73
|
+
@output.puts "\n#{pending_example[0]} (#{pending_example[1]})"
|
74
|
+
@output.puts "#{pending_example[2]}\n"
|
74
75
|
end
|
75
76
|
end
|
76
77
|
@output.flush
|
@@ -154,14 +154,6 @@ module Spec
|
|
154
154
|
font-size: 80%;
|
155
155
|
}
|
156
156
|
</style>
|
157
|
-
</head>
|
158
|
-
<body>
|
159
|
-
EOF
|
160
|
-
end
|
161
|
-
|
162
|
-
def report_header
|
163
|
-
<<-EOF
|
164
|
-
<div class="rspec-report">
|
165
157
|
<script type="text/javascript">
|
166
158
|
// <![CDATA[
|
167
159
|
#{global_scripts}
|
@@ -170,9 +162,19 @@ EOF
|
|
170
162
|
<style type="text/css">
|
171
163
|
#{global_styles}
|
172
164
|
</style>
|
165
|
+
</head>
|
166
|
+
<body>
|
167
|
+
EOF
|
168
|
+
end
|
169
|
+
|
170
|
+
def report_header
|
171
|
+
<<-EOF
|
172
|
+
<div class="rspec-report">
|
173
173
|
|
174
174
|
<div id="rspec-header">
|
175
|
-
<
|
175
|
+
<div id="label">
|
176
|
+
<h1>RSpec Results</h1>
|
177
|
+
</div>
|
176
178
|
|
177
179
|
<div id="summary">
|
178
180
|
<p id="totals"> </p>
|
@@ -212,7 +214,7 @@ EOF
|
|
212
214
|
def global_styles
|
213
215
|
<<-EOF
|
214
216
|
#rspec-header {
|
215
|
-
background: #65C400; color: #fff;
|
217
|
+
background: #65C400; color: #fff; height: 42px;
|
216
218
|
}
|
217
219
|
|
218
220
|
.rspec-report h1 {
|
@@ -220,15 +222,16 @@ EOF
|
|
220
222
|
padding: 10px;
|
221
223
|
font-family: "Lucida Grande", Helvetica, sans-serif;
|
222
224
|
font-size: 1.8em;
|
225
|
+
float: left;
|
223
226
|
}
|
224
227
|
|
225
228
|
#summary {
|
226
229
|
margin: 0; padding: 5px 10px;
|
227
230
|
font-family: "Lucida Grande", Helvetica, sans-serif;
|
228
231
|
text-align: right;
|
229
|
-
position: absolute;
|
230
232
|
top: 0px;
|
231
233
|
right: 0px;
|
234
|
+
float:right;
|
232
235
|
}
|
233
236
|
|
234
237
|
#summary p {
|
@@ -16,7 +16,7 @@ module Spec
|
|
16
16
|
current_nested_example_groups = described_example_group_chain
|
17
17
|
current_nested_example_groups.each_with_index do |nested_example_group, i|
|
18
18
|
unless nested_example_group == previous_nested_example_groups[i]
|
19
|
-
output.puts "#{' ' * i}#{nested_example_group.description_args}"
|
19
|
+
output.puts "#{' ' * i}#{nested_example_group.description_args.join}"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -52,7 +52,7 @@ module Spec
|
|
52
52
|
|
53
53
|
def described_example_group_chain
|
54
54
|
example_group_chain = []
|
55
|
-
example_group.__send__(:
|
55
|
+
example_group.__send__(:example_group_hierarchy).each do |example_group_class|
|
56
56
|
unless example_group_class.description_args.empty?
|
57
57
|
example_group_chain << example_group_class
|
58
58
|
end
|
@@ -1,72 +1,74 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
unless Spec::Ruby.version.to_f == 1.9
|
2
|
+
begin
|
3
|
+
require 'rubygems'
|
4
|
+
require 'heckle'
|
5
|
+
rescue LoadError ; raise "You must gem install heckle to use --heckle" ; end
|
5
6
|
|
6
|
-
module Spec
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
# Runs all the example groups held by +rspec_options+ once for each of the
|
17
|
-
# methods in the matched classes.
|
18
|
-
def heckle_with
|
19
|
-
if @filter =~ /(.*)[#\.](.*)/
|
20
|
-
heckle_method($1, $2)
|
21
|
-
else
|
22
|
-
heckle_class_or_module(@filter)
|
7
|
+
module Spec
|
8
|
+
module Runner
|
9
|
+
# Creates a new Heckler configured to heckle all methods in the classes
|
10
|
+
# whose name matches +filter+
|
11
|
+
class HeckleRunner
|
12
|
+
def initialize(filter, heckle_class=Heckler)
|
13
|
+
@filter = filter
|
14
|
+
@heckle_class = heckle_class
|
23
15
|
end
|
24
|
-
end
|
25
16
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
17
|
+
# Runs all the example groups held by +rspec_options+ once for each of the
|
18
|
+
# methods in the matched classes.
|
19
|
+
def heckle_with
|
20
|
+
if @filter =~ /(.*)[#\.](.*)/
|
21
|
+
heckle_method($1, $2)
|
22
|
+
else
|
23
|
+
heckle_class_or_module(@filter)
|
24
|
+
end
|
25
|
+
end
|
31
26
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
ObjectSpace.each_object(Class) do |klass|
|
37
|
-
classes << klass if klass.name =~ pattern
|
27
|
+
def heckle_method(class_name, method_name)
|
28
|
+
verify_constant(class_name)
|
29
|
+
heckle = @heckle_class.new(class_name, method_name, Spec::Runner.options)
|
30
|
+
heckle.validate
|
38
31
|
end
|
32
|
+
|
33
|
+
def heckle_class_or_module(class_or_module_name)
|
34
|
+
verify_constant(class_or_module_name)
|
35
|
+
pattern = /^#{class_or_module_name}/
|
36
|
+
classes = []
|
37
|
+
ObjectSpace.each_object(Class) do |klass|
|
38
|
+
classes << klass if klass.name =~ pattern
|
39
|
+
end
|
39
40
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
classes.each do |klass|
|
42
|
+
klass.instance_methods(false).each do |method_name|
|
43
|
+
heckle = @heckle_class.new(klass.name, method_name, Spec::Runner.options)
|
44
|
+
heckle.validate
|
45
|
+
end
|
44
46
|
end
|
45
47
|
end
|
46
|
-
end
|
47
48
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
def verify_constant(name)
|
50
|
+
begin
|
51
|
+
# This is defined in Heckle
|
52
|
+
name.to_class
|
53
|
+
rescue
|
54
|
+
raise "Heckling failed - \"#{name}\" is not a known class or module"
|
55
|
+
end
|
54
56
|
end
|
55
57
|
end
|
56
|
-
end
|
57
58
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
59
|
+
#Supports Heckle 1.2 and prior (earlier versions used Heckle::Base)
|
60
|
+
class Heckler < (Heckle.const_defined?(:Base) ? Heckle::Base : Heckle)
|
61
|
+
def initialize(klass_name, method_name, rspec_options)
|
62
|
+
super(klass_name, method_name)
|
63
|
+
@rspec_options = rspec_options
|
64
|
+
end
|
64
65
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
66
|
+
def tests_pass?
|
67
|
+
success = @rspec_options.run_examples
|
68
|
+
success
|
69
|
+
end
|
69
70
|
|
71
|
+
end
|
70
72
|
end
|
71
73
|
end
|
72
|
-
end
|
74
|
+
end
|