rspec 1.1.12 → 1.2.0
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/.autotest +2 -1
- data/.document +7 -0
- data/History.txt +58 -0
- data/License.txt +1 -1
- data/Manifest.txt +45 -82
- data/README.txt +3 -6
- data/Rakefile +33 -13
- data/Ruby1.9.markdown +32 -0
- data/TODO.txt +10 -4
- data/Upgrade.markdown +63 -0
- data/bin/spec +1 -1
- data/cucumber.yml +3 -0
- data/examples/failing/{failing_autogenerated_docstrings_example.rb → failing_implicit_docstrings_example.rb} +0 -0
- data/examples/failing/pending_example.rb +9 -0
- data/examples/failing/spec_helper.rb +1 -1
- data/examples/passing/{custom_expectation_matchers.rb → custom_matchers.rb} +0 -0
- data/examples/passing/filtered_formatter.rb +18 -0
- data/examples/passing/filtered_formatter_example.rb +31 -0
- data/examples/passing/implicit_docstrings_example.rb +18 -0
- data/examples/passing/spec_helper.rb +1 -1
- data/examples/ruby1.9.compatibility/access_to_constants_spec.rb +17 -18
- data/features/before_and_after_blocks/before_and_after_blocks.feature +4 -4
- data/features/example_groups/example_group_with_should_methods.feature +1 -1
- data/features/example_groups/{autogenerated_docstrings.feature → implicit_docstrings.feature} +7 -9
- data/features/example_groups/nested_groups.feature +1 -1
- data/features/heckle/heckle.feature +56 -0
- data/features/interop/examples_and_tests_together.feature +1 -1
- data/features/interop/test_but_not_test_unit.feature +1 -1
- data/features/interop/test_case_with_should_methods.feature +1 -1
- data/features/matchers/create_matcher.feature +115 -0
- data/features/mock_framework_integration/use_flexmock.feature +22 -4
- data/features/mock_framework_integration/use_mocha.feature +27 -0
- data/features/mock_framework_integration/use_rr.feature +27 -0
- data/features/mocks/mix_stubs_and_mocks.feature +22 -0
- data/features/pending/pending_examples.feature +81 -0
- data/features/step_definitions/running_rspec.rb +5 -3
- data/features/support/env.rb +1 -1
- data/features/support/matchers/smart_match.rb +2 -2
- data/lib/autotest/rspec.rb +1 -1
- data/lib/spec.rb +1 -1
- data/lib/{adapters → spec/adapters}/mock_frameworks/flexmock.rb +0 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/mocha.rb +0 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/rr.rb +0 -0
- data/lib/{adapters → spec/adapters}/mock_frameworks/rspec.rb +0 -1
- data/lib/spec/autorun.rb +3 -0
- data/lib/spec/dsl.rb +3 -1
- data/lib/spec/dsl/matchers.rb +13 -0
- data/lib/spec/example.rb +4 -0
- data/lib/spec/example/before_and_after_hooks.rb +5 -20
- data/lib/spec/example/errors.rb +3 -3
- data/lib/spec/example/example_description.rb +15 -0
- data/lib/spec/example/example_group.rb +0 -15
- data/lib/spec/example/example_group_factory.rb +34 -46
- data/lib/spec/example/example_group_hierarchy.rb +53 -0
- data/lib/spec/example/example_group_methods.rb +101 -211
- data/lib/spec/example/example_methods.rb +61 -81
- data/lib/spec/example/module_reopening_fix.rb +23 -1
- data/lib/spec/example/pending.rb +3 -2
- data/lib/spec/example/predicate_matchers.rb +47 -0
- data/lib/spec/example/subject.rb +91 -0
- data/lib/spec/expectations.rb +1 -1
- data/lib/spec/expectations/differs/default.rb +0 -1
- data/lib/spec/expectations/extensions.rb +0 -1
- data/lib/spec/expectations/handler.rb +13 -6
- data/lib/spec/interop/test.rb +5 -0
- data/lib/spec/interop/test/unit/testcase.rb +5 -22
- data/lib/spec/matchers.rb +22 -8
- data/lib/spec/matchers/be.rb +4 -9
- data/lib/spec/matchers/be_close.rb +20 -5
- data/lib/spec/matchers/be_instance_of.rb +45 -0
- data/lib/spec/matchers/be_kind_of.rb +45 -0
- data/lib/spec/matchers/change.rb +8 -6
- data/lib/spec/matchers/compatibility.rb +14 -0
- data/lib/spec/matchers/eql.rb +24 -6
- data/lib/spec/matchers/equal.rb +24 -6
- data/lib/spec/matchers/exist.rb +21 -5
- data/lib/spec/matchers/extensions/instance_exec.rb +25 -0
- data/lib/spec/matchers/generated_descriptions.rb +2 -2
- data/lib/spec/matchers/has.rb +28 -11
- data/lib/spec/matchers/have.rb +2 -2
- data/lib/spec/matchers/include.rb +2 -2
- data/lib/spec/matchers/match.rb +25 -7
- data/lib/spec/matchers/match_array.rb +3 -3
- data/lib/spec/matchers/matcher.rb +51 -0
- data/lib/spec/matchers/method_missing.rb +2 -2
- data/lib/spec/matchers/operator_matcher.rb +12 -5
- data/lib/spec/matchers/raise_error.rb +3 -3
- data/lib/spec/matchers/respond_to.rb +3 -3
- data/lib/spec/matchers/satisfy.rb +7 -7
- data/lib/spec/matchers/throw_symbol.rb +3 -5
- data/lib/spec/mocks.rb +3 -3
- data/lib/spec/mocks/argument_expectation.rb +15 -15
- data/lib/spec/mocks/{argument_constraints.rb → argument_matchers.rb} +19 -23
- data/lib/spec/mocks/error_generator.rb +5 -8
- data/lib/spec/mocks/framework.rb +1 -1
- data/lib/spec/mocks/message_expectation.rb +5 -13
- data/lib/spec/mocks/mock.rb +4 -5
- data/lib/spec/mocks/proxy.rb +9 -5
- data/lib/spec/mocks/spec_methods.rb +10 -1
- data/lib/spec/rake/spectask.rb +0 -1
- data/lib/spec/runner.rb +6 -28
- data/lib/spec/runner/configuration.rb +3 -3
- data/lib/spec/runner/drb_command_line.rb +2 -1
- data/lib/spec/runner/example_group_runner.rb +3 -2
- data/lib/spec/runner/formatter/base_text_formatter.rb +34 -19
- data/lib/spec/runner/formatter/failing_example_groups_formatter.rb +3 -5
- data/lib/spec/runner/formatter/html_formatter.rb +2 -3
- data/lib/spec/runner/formatter/nested_text_formatter.rb +7 -25
- data/lib/spec/runner/formatter/progress_bar_formatter.rb +1 -1
- data/lib/spec/runner/formatter/snippet_extractor.rb +1 -1
- data/lib/spec/runner/formatter/specdoc_formatter.rb +1 -7
- data/lib/spec/runner/heckle_runner.rb +3 -6
- data/lib/spec/runner/heckle_runner_unsupported.rb +1 -1
- data/lib/spec/runner/option_parser.rb +19 -21
- data/lib/spec/runner/options.rb +32 -27
- data/lib/spec/runner/reporter.rb +8 -9
- data/lib/spec/test/unit.rb +10 -0
- data/lib/spec/version.rb +2 -2
- data/{features/support → resources}/helpers/cmdline.rb +2 -2
- data/resources/rake/verify_rcov.rake +1 -1
- data/resources/spec/example_group_with_should_methods.rb +1 -1
- data/resources/spec/simple_spec.rb +1 -1
- data/resources/test/spec_and_test_together.rb +2 -3
- data/resources/test/spec_including_test_but_not_unit.rb +1 -1
- data/resources/test/test_case_with_should_methods.rb +2 -3
- data/spec/autotest/autotest_helper.rb +0 -1
- data/spec/autotest/rspec_spec.rb +95 -98
- data/spec/spec/dsl/main_spec.rb +3 -3
- data/spec/spec/dsl/matchers_spec.rb +25 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +14 -15
- data/spec/spec/example/example_group_factory_spec.rb +31 -44
- data/spec/spec/example/example_group_methods_spec.rb +86 -52
- data/spec/spec/example/example_group_spec.rb +32 -79
- data/spec/spec/example/example_matcher_spec.rb +10 -10
- data/spec/spec/example/example_methods_spec.rb +108 -242
- data/spec/spec/example/nested_example_group_spec.rb +2 -2
- data/spec/spec/example/pending_module_spec.rb +66 -41
- data/spec/spec/example/shared_example_group_spec.rb +4 -4
- data/spec/spec/{matchers → expectations}/handler_spec.rb +52 -4
- data/spec/spec/interop/test/unit/resources/spec_that_fails.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_that_passes.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_with_errors.rb +2 -2
- data/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +2 -2
- data/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +2 -2
- data/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +2 -2
- data/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +2 -2
- data/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +2 -2
- data/spec/spec/interop/test/unit/testcase_spec.rb +0 -4
- data/spec/spec/matchers/be_close_spec.rb +1 -1
- data/spec/spec/matchers/be_instance_of_spec.rb +29 -0
- data/spec/spec/matchers/be_kind_of_spec.rb +29 -0
- data/spec/spec/matchers/change_spec.rb +20 -0
- data/spec/spec/matchers/compatibility_spec.rb +34 -0
- data/spec/spec/matchers/description_generation_spec.rb +0 -12
- data/spec/spec/matchers/eql_spec.rb +2 -2
- data/spec/spec/matchers/equal_spec.rb +2 -2
- data/spec/spec/matchers/exist_spec.rb +8 -4
- data/spec/spec/matchers/have_spec.rb +4 -4
- data/spec/spec/matchers/match_spec.rb +2 -2
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -1
- data/spec/spec/matchers/matcher_spec.rb +97 -0
- data/spec/spec/matchers/throw_symbol_spec.rb +8 -8
- data/spec/spec/mocks/{bug_report_496.rb → bug_report_496_spec.rb} +0 -0
- data/spec/spec/mocks/{failing_mock_argument_constraints_spec.rb → failing_argument_matchers_spec.rb} +2 -2
- data/spec/spec/mocks/hash_including_matcher_spec.rb +4 -4
- data/spec/spec/mocks/hash_not_including_matcher_spec.rb +3 -3
- data/spec/spec/mocks/mock_spec.rb +27 -2
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
- data/spec/spec/mocks/partial_mock_spec.rb +18 -3
- data/spec/spec/mocks/{passing_mock_argument_constraints_spec.rb → passing_argument_matchers_spec.rb} +6 -6
- data/spec/spec/mocks/stubbed_message_expectations_spec.rb +13 -1
- data/spec/spec/package/bin_spec_spec.rb +2 -2
- data/spec/spec/runner/configuration_spec.rb +12 -12
- data/spec/spec/runner/drb_command_line_spec.rb +71 -73
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +82 -1
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +8 -8
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +4 -4
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +8 -8
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +38 -26
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +61 -53
- data/spec/spec/runner/formatter/html_formatter_spec.rb +100 -48
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +20 -34
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +2 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +9 -6
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +6 -6
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +20 -20
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +38 -26
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +55 -47
- data/spec/spec/runner/formatter/{spec_mate_formatter_spec.rb → text_mate_formatter_spec.rb} +11 -9
- data/spec/spec/runner/heckle_runner_spec.rb +1 -1
- data/spec/spec/runner/heckler_spec.rb +1 -1
- data/spec/spec/runner/option_parser_spec.rb +28 -11
- data/spec/spec/runner/options_spec.rb +34 -0
- data/spec/spec/runner/reporter_spec.rb +66 -62
- data/spec/spec/runner/resources/utf8_encoded.rb +1 -0
- data/spec/spec/runner/spec_drb.opts +1 -0
- data/spec/spec/runner_spec.rb +7 -5
- data/spec/spec_helper.rb +24 -2
- metadata +49 -90
- data/examples/passing/autogenerated_docstrings_example.rb +0 -25
- data/examples/passing/before_and_after_example.rb +0 -40
- data/examples/passing/behave_as_example.rb +0 -45
- data/examples/passing/legacy_spec.rb +0 -11
- data/examples/passing/priority.txt +0 -1
- data/features/support/helpers/story_helper.rb +0 -16
- data/lib/spec/expectations/extensions/string_and_symbol.rb +0 -17
- data/lib/spec/runner/formatter/story/html_formatter.rb +0 -174
- data/lib/spec/runner/formatter/story/plain_text_formatter.rb +0 -194
- data/lib/spec/runner/formatter/story/progress_bar_formatter.rb +0 -42
- data/lib/spec/story.rb +0 -10
- data/lib/spec/story/extensions.rb +0 -3
- data/lib/spec/story/extensions/main.rb +0 -86
- data/lib/spec/story/extensions/regexp.rb +0 -9
- data/lib/spec/story/extensions/string.rb +0 -9
- data/lib/spec/story/given_scenario.rb +0 -14
- data/lib/spec/story/runner.rb +0 -57
- data/lib/spec/story/runner/plain_text_story_runner.rb +0 -48
- data/lib/spec/story/runner/scenario_collector.rb +0 -18
- data/lib/spec/story/runner/scenario_runner.rb +0 -54
- data/lib/spec/story/runner/story_mediator.rb +0 -137
- data/lib/spec/story/runner/story_parser.rb +0 -247
- data/lib/spec/story/runner/story_runner.rb +0 -74
- data/lib/spec/story/scenario.rb +0 -14
- data/lib/spec/story/step.rb +0 -70
- data/lib/spec/story/step_group.rb +0 -89
- data/lib/spec/story/step_mother.rb +0 -38
- data/lib/spec/story/story.rb +0 -39
- data/lib/spec/story/world.rb +0 -124
- data/resources/spec/spec_with_flexmock.rb +0 -19
- data/rspec.gemspec +0 -32
- data/spec/spec/matchers/mock_constraint_matchers_spec.rb +0 -24
- data/spec/spec/runner/formatter/story/html_formatter_spec.rb +0 -135
- data/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +0 -600
- data/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +0 -82
- data/spec/spec/spec_spec.rb +0 -21
- data/spec/spec/story/builders.rb +0 -46
- data/spec/spec/story/extensions/main_spec.rb +0 -161
- data/spec/spec/story/extensions_spec.rb +0 -14
- data/spec/spec/story/given_scenario_spec.rb +0 -27
- data/spec/spec/story/runner/plain_text_story_runner_spec.rb +0 -90
- data/spec/spec/story/runner/scenario_collector_spec.rb +0 -27
- data/spec/spec/story/runner/scenario_runner_spec.rb +0 -214
- data/spec/spec/story/runner/story_mediator_spec.rb +0 -143
- data/spec/spec/story/runner/story_parser_spec.rb +0 -401
- data/spec/spec/story/runner/story_runner_spec.rb +0 -294
- data/spec/spec/story/runner_spec.rb +0 -93
- data/spec/spec/story/scenario_spec.rb +0 -18
- data/spec/spec/story/step_group_spec.rb +0 -157
- data/spec/spec/story/step_mother_spec.rb +0 -84
- data/spec/spec/story/step_spec.rb +0 -272
- data/spec/spec/story/story_helper.rb +0 -2
- data/spec/spec/story/story_spec.rb +0 -84
- data/spec/spec/story/world_spec.rb +0 -423
- data/story_server/prototype/javascripts/builder.js +0 -136
- data/story_server/prototype/javascripts/controls.js +0 -972
- data/story_server/prototype/javascripts/dragdrop.js +0 -976
- data/story_server/prototype/javascripts/effects.js +0 -1117
- data/story_server/prototype/javascripts/prototype.js +0 -4140
- data/story_server/prototype/javascripts/rspec.js +0 -149
- data/story_server/prototype/javascripts/scriptaculous.js +0 -58
- data/story_server/prototype/javascripts/slider.js +0 -276
- data/story_server/prototype/javascripts/sound.js +0 -55
- data/story_server/prototype/javascripts/unittest.js +0 -568
- data/story_server/prototype/lib/server.rb +0 -24
- data/story_server/prototype/stories.html +0 -176
- data/story_server/prototype/stylesheets/rspec.css +0 -136
- data/story_server/prototype/stylesheets/test.css +0 -90
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'spec/runner/formatter/base_formatter'
|
2
|
+
require 'fileutils'
|
2
3
|
|
3
4
|
module Spec
|
4
5
|
module Runner
|
@@ -23,27 +24,31 @@ module Spec
|
|
23
24
|
end
|
24
25
|
|
25
26
|
def example_pending(example, message, pending_caller)
|
26
|
-
@pending_examples << [example.
|
27
|
+
@pending_examples << ["#{@example_group.description} #{example.description}", message, pending_caller]
|
27
28
|
end
|
28
29
|
|
29
30
|
def dump_failure(counter, failure)
|
30
31
|
@output.puts
|
31
32
|
@output.puts "#{counter.to_s})"
|
32
|
-
@output.puts
|
33
|
+
@output.puts colorize_failure("#{failure.header}\n#{failure.exception.message}", failure)
|
33
34
|
@output.puts format_backtrace(failure.exception.backtrace)
|
34
35
|
@output.flush
|
35
36
|
end
|
36
37
|
|
37
|
-
def
|
38
|
-
|
39
|
-
red(s)
|
40
|
-
elsif(failure.pending_fixed?)
|
41
|
-
blue(s)
|
42
|
-
else
|
43
|
-
magenta(s)
|
44
|
-
end
|
38
|
+
def colorize_failure(message, failure)
|
39
|
+
failure.pending_fixed? ? blue(message) : red(message)
|
45
40
|
end
|
46
|
-
|
41
|
+
|
42
|
+
def colourise(message, failure)
|
43
|
+
Kernel.warn <<-NOTICE
|
44
|
+
DEPRECATED: BaseTextFormatter#colourise is deprecated and will be
|
45
|
+
removed from a future version of RSpec.
|
46
|
+
|
47
|
+
Please use colorize_failure instead.
|
48
|
+
NOTICE
|
49
|
+
colorize_failure(message, failure)
|
50
|
+
end
|
51
|
+
|
47
52
|
def dump_summary(duration, example_count, failure_count, pending_count)
|
48
53
|
return if dry_run?
|
49
54
|
@output.puts
|
@@ -78,9 +83,7 @@ module Spec
|
|
78
83
|
end
|
79
84
|
|
80
85
|
def close
|
81
|
-
if IO === @output
|
82
|
-
@output.close
|
83
|
-
end
|
86
|
+
@output.close if (IO === @output) & (@output != $stdout)
|
84
87
|
end
|
85
88
|
|
86
89
|
def format_backtrace(backtrace)
|
@@ -91,11 +94,15 @@ module Spec
|
|
91
94
|
protected
|
92
95
|
|
93
96
|
def colour?
|
94
|
-
|
97
|
+
!!@options.colour
|
95
98
|
end
|
96
99
|
|
97
100
|
def dry_run?
|
98
|
-
|
101
|
+
!!@options.dry_run
|
102
|
+
end
|
103
|
+
|
104
|
+
def autospec?
|
105
|
+
!!@options.autospec
|
99
106
|
end
|
100
107
|
|
101
108
|
def backtrace_line(line)
|
@@ -103,7 +110,7 @@ module Spec
|
|
103
110
|
end
|
104
111
|
|
105
112
|
def colour(text, colour_code)
|
106
|
-
return text unless colour?
|
113
|
+
return text unless ENV['RSPEC_COLOR'] || (colour? & (autospec? || output_to_tty?))
|
107
114
|
"#{colour_code}#{text}\e[0m"
|
108
115
|
end
|
109
116
|
|
@@ -117,10 +124,18 @@ module Spec
|
|
117
124
|
|
118
125
|
def green(text); colour(text, "\e[32m"); end
|
119
126
|
def red(text); colour(text, "\e[31m"); end
|
120
|
-
def magenta(text); colour(text, "\e[35m"); end
|
121
127
|
def yellow(text); colour(text, "\e[33m"); end
|
122
128
|
def blue(text); colour(text, "\e[34m"); end
|
123
|
-
|
129
|
+
|
130
|
+
def magenta(text)
|
131
|
+
Kernel.warn <<-NOTICE
|
132
|
+
DEPRECATED: BaseTextFormatter#magenta is deprecated and will be
|
133
|
+
removed from a future version of RSpec.
|
134
|
+
|
135
|
+
Please use red instead (it is red/green/refactor after all).
|
136
|
+
NOTICE
|
137
|
+
red(text)
|
138
|
+
end
|
124
139
|
end
|
125
140
|
end
|
126
141
|
end
|
@@ -6,21 +6,19 @@ module Spec
|
|
6
6
|
class FailingExampleGroupsFormatter < BaseTextFormatter
|
7
7
|
def example_failed(example, counter, failure)
|
8
8
|
if @example_group
|
9
|
-
|
10
|
-
description =~ /(.*) \(druby.*\)$/ ? $1 : description
|
11
|
-
end
|
12
|
-
@output.puts ::Spec::Example::ExampleGroupMethods.description_text(*description_parts)
|
9
|
+
@output.puts @example_group.filtered_description(/(.*) \(druby.*\)$/)
|
13
10
|
|
14
11
|
@output.flush
|
15
12
|
@example_group = nil
|
16
13
|
end
|
17
14
|
end
|
18
|
-
|
15
|
+
|
19
16
|
def dump_failure(counter, failure)
|
20
17
|
end
|
21
18
|
|
22
19
|
def dump_summary(duration, example_count, failure_count, pending_count)
|
23
20
|
end
|
21
|
+
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
@@ -38,7 +38,6 @@ module Spec
|
|
38
38
|
def add_example_group(example_group)
|
39
39
|
super
|
40
40
|
@example_group_red = false
|
41
|
-
@example_group_red = false
|
42
41
|
@example_group_number += 1
|
43
42
|
unless example_group_number == 1
|
44
43
|
@output.puts " </dl>"
|
@@ -214,7 +213,7 @@ EOF
|
|
214
213
|
def global_styles
|
215
214
|
<<-EOF
|
216
215
|
#rspec-header {
|
217
|
-
background: #65C400; color: #fff; height:
|
216
|
+
background: #65C400; color: #fff; height: 4em;
|
218
217
|
}
|
219
218
|
|
220
219
|
.rspec-report h1 {
|
@@ -222,7 +221,7 @@ EOF
|
|
222
221
|
padding: 10px;
|
223
222
|
font-family: "Lucida Grande", Helvetica, sans-serif;
|
224
223
|
font-size: 1.8em;
|
225
|
-
|
224
|
+
position: absolute;
|
226
225
|
}
|
227
226
|
|
228
227
|
#summary {
|
@@ -4,33 +4,25 @@ module Spec
|
|
4
4
|
module Runner
|
5
5
|
module Formatter
|
6
6
|
class NestedTextFormatter < BaseTextFormatter
|
7
|
-
attr_reader :previous_nested_example_groups
|
8
7
|
def initialize(options, where)
|
9
8
|
super
|
10
|
-
@
|
9
|
+
@last_nested_descriptions = []
|
11
10
|
end
|
12
11
|
|
13
12
|
def add_example_group(example_group)
|
14
13
|
super
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
output.puts "#{' ' * i}#{nested_example_group.description_args.join}"
|
15
|
+
example_group.nested_descriptions.each_with_index do |nested_description, i|
|
16
|
+
unless nested_description == @last_nested_descriptions[i]
|
17
|
+
output.puts "#{' ' * i}#{nested_description}"
|
20
18
|
end
|
21
19
|
end
|
22
20
|
|
23
|
-
@
|
21
|
+
@last_nested_descriptions = example_group.nested_descriptions
|
24
22
|
end
|
25
23
|
|
26
24
|
def example_failed(example, counter, failure)
|
27
|
-
|
28
|
-
"#{current_indentation}#{example.description} (FAILED - #{counter})"
|
29
|
-
else
|
30
|
-
"#{current_indentation}#{example.description} (ERROR - #{counter})"
|
31
|
-
end
|
32
|
-
|
33
|
-
output.puts(failure.expectation_not_met? ? red(message) : magenta(message))
|
25
|
+
output.puts(red("#{current_indentation}#{example.description} (FAILED - #{counter})"))
|
34
26
|
output.flush
|
35
27
|
end
|
36
28
|
|
@@ -47,17 +39,7 @@ module Spec
|
|
47
39
|
end
|
48
40
|
|
49
41
|
def current_indentation
|
50
|
-
' ' *
|
51
|
-
end
|
52
|
-
|
53
|
-
def described_example_group_chain
|
54
|
-
example_group_chain = []
|
55
|
-
example_group.__send__(:example_group_hierarchy).each do |example_group_class|
|
56
|
-
unless example_group_class.description_args.empty?
|
57
|
-
example_group_chain << example_group_class
|
58
|
-
end
|
59
|
-
end
|
60
|
-
example_group_chain
|
42
|
+
' ' * @last_nested_descriptions.length
|
61
43
|
end
|
62
44
|
end
|
63
45
|
end
|
@@ -4,7 +4,7 @@ module Spec
|
|
4
4
|
# This class extracts code snippets by looking at the backtrace of the passed error
|
5
5
|
class SnippetExtractor #:nodoc:
|
6
6
|
class NullConverter; def convert(code, pre); code; end; end #:nodoc:
|
7
|
-
begin; require '
|
7
|
+
begin; require 'syntax/convertors/html'; @@converter = Syntax::Convertors::HTML.for_syntax "ruby"; rescue LoadError => e; @@converter = NullConverter.new; end
|
8
8
|
|
9
9
|
def snippet(error)
|
10
10
|
raw_code, line = snippet_for(error.backtrace[0])
|
@@ -12,13 +12,7 @@ module Spec
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def example_failed(example, counter, failure)
|
15
|
-
|
16
|
-
"- #{example.description} (FAILED - #{counter})"
|
17
|
-
else
|
18
|
-
"- #{example.description} (ERROR - #{counter})"
|
19
|
-
end
|
20
|
-
|
21
|
-
output.puts(failure.expectation_not_met? ? red(message) : magenta(message))
|
15
|
+
output.puts(red("- #{example.description} (FAILED - #{counter})"))
|
22
16
|
output.flush
|
23
17
|
end
|
24
18
|
|
@@ -1,6 +1,5 @@
|
|
1
|
-
|
1
|
+
if Spec::Ruby.version.to_f < 1.9
|
2
2
|
begin
|
3
|
-
require 'rubygems'
|
4
3
|
require 'heckle'
|
5
4
|
rescue LoadError ; raise "You must gem install heckle to use --heckle" ; end
|
6
5
|
|
@@ -56,16 +55,14 @@ unless Spec::Ruby.version.to_f == 1.9
|
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
|
60
|
-
class Heckler < (Heckle.const_defined?(:Base) ? Heckle::Base : Heckle)
|
58
|
+
class Heckler < Heckle
|
61
59
|
def initialize(klass_name, method_name, rspec_options)
|
62
60
|
super(klass_name, method_name)
|
63
61
|
@rspec_options = rspec_options
|
64
62
|
end
|
65
63
|
|
66
64
|
def tests_pass?
|
67
|
-
|
68
|
-
success
|
65
|
+
@rspec_options.run_examples
|
69
66
|
end
|
70
67
|
|
71
68
|
end
|
@@ -46,20 +46,15 @@ module Spec
|
|
46
46
|
"not specified. The --format option may be specified several times",
|
47
47
|
"if you want several outputs",
|
48
48
|
" ",
|
49
|
-
"Builtin formats
|
50
|
-
"progress|p : Text-based progress bar",
|
49
|
+
"Builtin formats:",
|
50
|
+
"silent|l : No output", "progress|p : Text-based progress bar",
|
51
51
|
"profile|o : Text-based progress bar with profiling of 10 slowest examples",
|
52
52
|
"specdoc|s : Code example doc strings",
|
53
|
-
"nested|n : Code example doc strings with nested groups
|
53
|
+
"nested|n : Code example doc strings with nested groups indented",
|
54
54
|
"html|h : A nice HTML report",
|
55
55
|
"failing_examples|e : Write all failing examples - input for --example",
|
56
56
|
"failing_example_groups|g : Write all failing example groups - input for --example",
|
57
57
|
" ",
|
58
|
-
"Builtin formats for stories:",
|
59
|
-
"plain|p : Plain Text",
|
60
|
-
"html|h : A nice HTML report",
|
61
|
-
"progress|r : Text progress",
|
62
|
-
" ",
|
63
58
|
"FORMAT can also be the name of a custom formatter class",
|
64
59
|
"(in which case you should also specify --require to load it)"],
|
65
60
|
:require => ["-r", "--require FILE", "Require FILE before running specs",
|
@@ -112,19 +107,24 @@ module Spec
|
|
112
107
|
on(*OPTIONS[:timeout]) {|timeout| @options.timeout = timeout.to_f}
|
113
108
|
on(*OPTIONS[:heckle]) {|heckle| @options.load_heckle_runner(heckle)}
|
114
109
|
on(*OPTIONS[:dry_run]) {@options.dry_run = true}
|
115
|
-
on(*OPTIONS[:options_file]) {|options_file|
|
110
|
+
on(*OPTIONS[:options_file]) {|options_file|}
|
116
111
|
on(*OPTIONS[:generate_options]) {|options_file|}
|
117
112
|
on(*OPTIONS[:runner]) {|runner| @options.user_input_for_runner = runner}
|
118
113
|
on(*OPTIONS[:drb]) {}
|
119
114
|
on(*OPTIONS[:version]) {parse_version}
|
115
|
+
on("--autospec") {@options.autospec = true}
|
120
116
|
on_tail(*OPTIONS[:help]) {parse_help}
|
121
117
|
end
|
122
118
|
|
123
119
|
def order!(argv, &blk)
|
124
120
|
@argv = argv.dup
|
125
|
-
@argv = (@argv.empty?
|
121
|
+
@argv = (@argv.empty? & self.class.spec_command?) ? ['--help'] : @argv
|
122
|
+
|
123
|
+
# Parse options file first
|
124
|
+
parse_file_options(:options_file, :parse_options_file)
|
125
|
+
|
126
126
|
@options.argv = @argv.dup
|
127
|
-
return if
|
127
|
+
return if parse_file_options(:generate_options, :write_generated_options)
|
128
128
|
return if parse_drb
|
129
129
|
|
130
130
|
super(@argv) do |file|
|
@@ -145,16 +145,14 @@ module Spec
|
|
145
145
|
def parse_options_file(options_file)
|
146
146
|
option_file_args = IO.readlines(options_file).map {|l| l.chomp.split " "}.flatten
|
147
147
|
@argv.push(*option_file_args)
|
148
|
-
# TODO - this is a brute force solution to http://rspec.lighthouseapp.com/projects/5645/tickets/293.
|
149
|
-
# Let's look for a cleaner way. Might not be one. But let's look. If not, perhaps
|
150
|
-
# this can be moved to a different method to indicate the special handling for drb?
|
151
|
-
parse_drb(@argv)
|
152
148
|
end
|
153
149
|
|
154
|
-
def
|
155
|
-
# Remove the
|
150
|
+
def parse_file_options(option_name, action)
|
151
|
+
# Remove the file option and the argument before handling the file
|
156
152
|
options_file = nil
|
157
|
-
[
|
153
|
+
options_list = OPTIONS[option_name][0..1]
|
154
|
+
options_list[1].gsub!(" PATH", "")
|
155
|
+
options_list.each do |option|
|
158
156
|
if index = @argv.index(option)
|
159
157
|
@argv.delete_at(index)
|
160
158
|
options_file = @argv.delete_at(index)
|
@@ -162,7 +160,7 @@ module Spec
|
|
162
160
|
end
|
163
161
|
|
164
162
|
if options_file
|
165
|
-
|
163
|
+
send(action, options_file)
|
166
164
|
return true
|
167
165
|
else
|
168
166
|
return false
|
@@ -178,8 +176,8 @@ module Spec
|
|
178
176
|
@options.examples_should_not_be_run
|
179
177
|
end
|
180
178
|
|
181
|
-
def parse_drb
|
182
|
-
argv
|
179
|
+
def parse_drb
|
180
|
+
argv = @options.argv
|
183
181
|
is_drb = false
|
184
182
|
is_drb ||= argv.delete(OPTIONS[:drb][0])
|
185
183
|
is_drb ||= argv.delete(OPTIONS[:drb][1])
|
data/lib/spec/runner/options.rb
CHANGED
@@ -6,6 +6,8 @@ module Spec
|
|
6
6
|
}
|
7
7
|
|
8
8
|
EXAMPLE_FORMATTERS = { # Load these lazily for better speed
|
9
|
+
'silent' => ['spec/runner/formatter/base_formatter', 'Formatter::BaseFormatter'],
|
10
|
+
'l' => ['spec/runner/formatter/base_formatter', 'Formatter::BaseFormatter'],
|
9
11
|
'specdoc' => ['spec/runner/formatter/specdoc_formatter', 'Formatter::SpecdocFormatter'],
|
10
12
|
's' => ['spec/runner/formatter/specdoc_formatter', 'Formatter::SpecdocFormatter'],
|
11
13
|
'nested' => ['spec/runner/formatter/nested_text_formatter', 'Formatter::NestedTextFormatter'],
|
@@ -23,17 +25,8 @@ module Spec
|
|
23
25
|
'textmate' => ['spec/runner/formatter/text_mate_formatter', 'Formatter::TextMateFormatter']
|
24
26
|
}
|
25
27
|
|
26
|
-
STORY_FORMATTERS = {
|
27
|
-
'plain' => ['spec/runner/formatter/story/plain_text_formatter', 'Formatter::Story::PlainTextFormatter'],
|
28
|
-
'p' => ['spec/runner/formatter/story/plain_text_formatter', 'Formatter::Story::PlainTextFormatter'],
|
29
|
-
'html' => ['spec/runner/formatter/story/html_formatter', 'Formatter::Story::HtmlFormatter'],
|
30
|
-
'h' => ['spec/runner/formatter/story/html_formatter', 'Formatter::Story::HtmlFormatter'],
|
31
|
-
'progress' => ['spec/runner/formatter/story/progress_bar_formatter', 'Formatter::Story::ProgressBarFormatter'],
|
32
|
-
'r' => ['spec/runner/formatter/story/progress_bar_formatter', 'Formatter::Story::ProgressBarFormatter']
|
33
|
-
|
34
|
-
}
|
35
|
-
|
36
28
|
attr_accessor(
|
29
|
+
:autospec, # hack to tell
|
37
30
|
:filename_pattern,
|
38
31
|
:backtrace_tweaker,
|
39
32
|
:context_lines,
|
@@ -94,11 +87,14 @@ module Spec
|
|
94
87
|
runner.load_files(files_to_load)
|
95
88
|
@files_loaded = true
|
96
89
|
end
|
90
|
+
|
91
|
+
define_predicate_matchers
|
92
|
+
plugin_mock_framework
|
97
93
|
|
98
94
|
# TODO - this has to happen after the files get loaded,
|
99
95
|
# otherwise the before_suite_parts are not populated
|
100
96
|
# from the configuration. There is no spec for this
|
101
|
-
# directly, but
|
97
|
+
# directly, but features/before_and_after_blocks/before_and_after_blocks.story
|
102
98
|
# will fail if this happens before the files are loaded.
|
103
99
|
before_suite_parts.each do |part|
|
104
100
|
part.call
|
@@ -115,7 +111,7 @@ module Spec
|
|
115
111
|
end
|
116
112
|
ensure
|
117
113
|
after_suite_parts.each do |part|
|
118
|
-
part.call(success)
|
114
|
+
part.arity < 1 ? part.call : part.call(success)
|
119
115
|
end
|
120
116
|
end
|
121
117
|
end
|
@@ -136,11 +132,6 @@ module Spec
|
|
136
132
|
@examples_should_be_run = false
|
137
133
|
end
|
138
134
|
|
139
|
-
def predicate_matchers
|
140
|
-
# TODO - don't like this dependency - perhaps store these in here instead?
|
141
|
-
Spec::Runner.configuration.predicate_matchers
|
142
|
-
end
|
143
|
-
|
144
135
|
def mock_framework
|
145
136
|
# TODO - don't like this dependency - perhaps store this in here instead?
|
146
137
|
Spec::Runner.configuration.mock_framework
|
@@ -151,7 +142,6 @@ module Spec
|
|
151
142
|
if @colour && RUBY_PLATFORM =~ /mswin|mingw/ ;\
|
152
143
|
begin ;\
|
153
144
|
replace_output = @output_stream.equal?($stdout) ;\
|
154
|
-
require 'rubygems' ;\
|
155
145
|
require 'Win32/Console/ANSI' ;\
|
156
146
|
@output_stream = $stdout if replace_output ;\
|
157
147
|
rescue LoadError ;\
|
@@ -199,11 +189,6 @@ module Spec
|
|
199
189
|
@formatters ||= load_formatters(@format_options, EXAMPLE_FORMATTERS)
|
200
190
|
end
|
201
191
|
|
202
|
-
def story_formatters
|
203
|
-
@format_options ||= [['plain', @output_stream]]
|
204
|
-
@formatters ||= load_formatters(@format_options, STORY_FORMATTERS)
|
205
|
-
end
|
206
|
-
|
207
192
|
def load_formatters(format_options, formatters)
|
208
193
|
format_options.map do |format, where|
|
209
194
|
formatter_type = if formatters[format]
|
@@ -217,9 +202,10 @@ module Spec
|
|
217
202
|
end
|
218
203
|
|
219
204
|
def load_heckle_runner(heckle)
|
220
|
-
|
205
|
+
@format_options ||= [['silent', @output_stream]]
|
206
|
+
suffix = ([/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} || Spec::Ruby.version.to_f == 1.9) ? '_unsupported' : ''
|
221
207
|
require "spec/runner/heckle_runner#{suffix}"
|
222
|
-
@heckle_runner = HeckleRunner.new(heckle)
|
208
|
+
@heckle_runner = ::Spec::Runner::HeckleRunner.new(heckle)
|
223
209
|
end
|
224
210
|
|
225
211
|
def number_of_examples
|
@@ -247,7 +233,26 @@ module Spec
|
|
247
233
|
@dry_run == true
|
248
234
|
end
|
249
235
|
|
250
|
-
|
236
|
+
protected
|
237
|
+
|
238
|
+
def define_predicate_matchers
|
239
|
+
Spec::Runner.configuration.predicate_matchers.each_pair do |matcher_method, method_on_object|
|
240
|
+
Spec::Example::ExampleMethods::__send__ :define_method, matcher_method do |*args|
|
241
|
+
eval("be_#{method_on_object.to_s.gsub('?','')}(*args)")
|
242
|
+
end
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def plugin_mock_framework
|
247
|
+
case mock_framework
|
248
|
+
when Module
|
249
|
+
Spec::Example::ExampleMethods.__send__ :include, mock_framework
|
250
|
+
else
|
251
|
+
require mock_framework
|
252
|
+
Spec::Example::ExampleMethods.__send__ :include, Spec::Adapters::MockFramework
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
251
256
|
def examples_should_be_run?
|
252
257
|
return @examples_should_be_run unless @examples_should_be_run.nil?
|
253
258
|
@examples_should_be_run = true
|
@@ -304,7 +309,7 @@ module Spec
|
|
304
309
|
|
305
310
|
def default_differ
|
306
311
|
require 'spec/expectations/differs/default'
|
307
|
-
self.differ_class = Spec::Expectations::Differs::Default
|
312
|
+
self.differ_class = ::Spec::Expectations::Differs::Default
|
308
313
|
end
|
309
314
|
|
310
315
|
def set_spec_from_line_number
|