rspec 1.1.12 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/spec/runner/reporter.rb
CHANGED
@@ -32,15 +32,14 @@ module Spec
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def
|
35
|
+
def example_failed(example, error)
|
36
36
|
backtrace_tweaker.tweak_backtrace(error)
|
37
|
-
failure = Failure.new(example, error)
|
37
|
+
failure = Failure.new(example_groups.empty? ? "" : example_groups.last.description, example, error)
|
38
38
|
@failures << failure
|
39
39
|
formatters.each do |f|
|
40
40
|
f.example_failed(example, @failures.length, failure)
|
41
41
|
end
|
42
42
|
end
|
43
|
-
alias_method :example_failed, :failure
|
44
43
|
|
45
44
|
def start(number_of_examples)
|
46
45
|
clear
|
@@ -134,11 +133,10 @@ module Spec
|
|
134
133
|
class Failure
|
135
134
|
attr_reader :example, :exception
|
136
135
|
|
137
|
-
def initialize(example, exception)
|
138
|
-
@example = example
|
139
|
-
@exception = exception
|
136
|
+
def initialize(group, example, exception)
|
137
|
+
@group, @example, @exception = group, example, exception
|
140
138
|
end
|
141
|
-
|
139
|
+
|
142
140
|
def header
|
143
141
|
if expectation_not_met?
|
144
142
|
"'#{example_name}' FAILED"
|
@@ -157,9 +155,10 @@ module Spec
|
|
157
155
|
@exception.is_a?(Spec::Expectations::ExpectationNotMetError)
|
158
156
|
end
|
159
157
|
|
160
|
-
|
158
|
+
protected
|
159
|
+
|
161
160
|
def example_name
|
162
|
-
@example.
|
161
|
+
"#{@group} #{@example.description}"
|
163
162
|
end
|
164
163
|
end
|
165
164
|
end
|
data/lib/spec/version.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
$:.push File.join(File.dirname(__FILE__), *%w[.. ..
|
1
|
+
$:.push File.join(File.dirname(__FILE__), *%w[.. .. lib])
|
2
2
|
require 'spec'
|
3
3
|
|
4
|
-
# Uncommenting next line will break the output
|
4
|
+
# Uncommenting next line will break the output feature (no output!!)
|
5
5
|
# rspec_options
|
6
6
|
options = Spec::Runner::OptionParser.parse(
|
7
7
|
ARGV, $stderr, $stdout
|
@@ -1,7 +1,6 @@
|
|
1
1
|
$:.push File.join(File.dirname(__FILE__), *%w[.. .. lib])
|
2
|
-
require 'spec'
|
3
|
-
|
4
|
-
require 'spec/interop/test'
|
2
|
+
require 'spec/autorun'
|
3
|
+
require 'spec/test/unit'
|
5
4
|
|
6
5
|
describe "An Example" do
|
7
6
|
it "should pass with assert" do
|
data/spec/autotest/rspec_spec.rb
CHANGED
@@ -1,114 +1,111 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/autotest_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
@rspec_autotest = Rspec.new
|
9
|
-
end
|
3
|
+
describe Autotest::Rspec do
|
4
|
+
describe "adding spec.opts --options" do
|
5
|
+
before(:each) do
|
6
|
+
@rspec_autotest = Autotest::Rspec.new
|
7
|
+
end
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
it "should return the command line option to add spec.opts if the options file exists" do
|
10
|
+
File.stub!(:exist?).and_return true
|
11
|
+
@rspec_autotest.add_options_if_present.should == "-O spec/spec.opts "
|
12
|
+
end
|
15
13
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
@ruby = @rspec_autotest.ruby
|
29
|
-
@spec_cmd = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec'))
|
30
|
-
@options = @rspec_autotest.add_options_if_present
|
31
|
-
@files_to_test = {
|
32
|
-
:spec => ["file_one", "file_two"]
|
33
|
-
}
|
34
|
-
# this is not the inner representation of Autotest!
|
35
|
-
@rspec_autotest.stub!(:files_to_test).and_return @files_to_test
|
36
|
-
@files_to_test.stub!(:keys).and_return @files_to_test[:spec]
|
37
|
-
@to_test = @files_to_test.keys.flatten.join ' '
|
38
|
-
end
|
14
|
+
it "should return an empty string if no spec.opts exists" do
|
15
|
+
File.stub!(:exist?).and_return false
|
16
|
+
Autotest::Rspec.new.add_options_if_present.should == ""
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "commands" do
|
21
|
+
before(:each) do
|
22
|
+
@rspec_autotest = Autotest::Rspec.new
|
23
|
+
@rspec_autotest.stub!(:ruby).and_return "ruby"
|
24
|
+
@rspec_autotest.stub!(:add_options_if_present).and_return "-O spec/spec.opts"
|
39
25
|
|
40
|
-
|
41
|
-
|
42
|
-
|
26
|
+
@ruby = @rspec_autotest.ruby
|
27
|
+
@spec_cmd = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec'))
|
28
|
+
@options = @rspec_autotest.add_options_if_present
|
29
|
+
@files_to_test = {
|
30
|
+
:spec => ["file_one", "file_two"]
|
31
|
+
}
|
32
|
+
# this is not the inner representation of Autotest!
|
33
|
+
@rspec_autotest.stub!(:files_to_test).and_return @files_to_test
|
34
|
+
@files_to_test.stub!(:keys).and_return @files_to_test[:spec]
|
35
|
+
@to_test = @files_to_test.keys.flatten.join ' '
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should make the appropriate test command" do
|
39
|
+
@rspec_autotest.make_test_cmd(@files_to_test).should == "#{@ruby} #{@spec_cmd} --autospec #{@to_test} #{@options}"
|
40
|
+
end
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
end
|
42
|
+
it "should return a blank command for no files" do
|
43
|
+
@rspec_autotest.make_test_cmd({}).should == ''
|
47
44
|
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "mappings" do
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
@rspec_autotest = Rspec.new
|
55
|
-
@rspec_autotest.hook :initialize
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should find the spec file for a given lib file" do
|
59
|
-
@rspec_autotest.should map_specs([@spec_file]).to(@lib_file)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should find the spec file if given a spec file" do
|
63
|
-
@rspec_autotest.should map_specs([@spec_file]).to(@spec_file)
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should ignore files in spec dir that aren't specs" do
|
67
|
-
@rspec_autotest.should map_specs([]).to("spec/spec_helper.rb")
|
68
|
-
end
|
69
|
-
|
70
|
-
it "should ignore untracked files (in @file)" do
|
71
|
-
@rspec_autotest.should map_specs([]).to("lib/untracked_file")
|
72
|
-
end
|
49
|
+
before(:each) do
|
50
|
+
@lib_file = "lib/something.rb"
|
51
|
+
@spec_file = "spec/something_spec.rb"
|
52
|
+
@rspec_autotest = Autotest::Rspec.new
|
53
|
+
@rspec_autotest.hook :initialize
|
73
54
|
end
|
74
55
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
56
|
+
it "should find the spec file for a given lib file" do
|
57
|
+
@rspec_autotest.should map_specs([@spec_file]).to(@lib_file)
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should find the spec file if given a spec file" do
|
61
|
+
@rspec_autotest.should map_specs([@spec_file]).to(@spec_file)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should ignore files in spec dir that aren't specs" do
|
65
|
+
@rspec_autotest.should map_specs([]).to("spec/spec_helper.rb")
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should ignore untracked files (in @file)" do
|
69
|
+
@rspec_autotest.should map_specs([]).to("lib/untracked_file")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "consolidating failures" do
|
74
|
+
before(:each) do
|
75
|
+
@rspec_autotest = Autotest::Rspec.new
|
87
76
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
77
|
+
@spec_file = "spec/autotest/some_spec.rb"
|
78
|
+
@rspec_autotest.instance_variable_set("@files", {@spec_file => Time.now})
|
79
|
+
@rspec_autotest.stub!(:find_files_to_test).and_return true
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should return no failures if no failures were given in the output" do
|
83
|
+
@rspec_autotest.consolidate_failures([[]]).should == {}
|
84
|
+
end
|
85
|
+
|
86
|
+
it "should return a hash with the spec filename => spec name for each failure or error" do
|
87
|
+
@rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb"
|
88
|
+
failures = [
|
89
|
+
[
|
90
|
+
"false should be false",
|
91
|
+
"expected: true,\n got: false (using ==)\n#{@spec_file}:203:"
|
95
92
|
]
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
93
|
+
]
|
94
|
+
@rspec_autotest.consolidate_failures(failures).should == {
|
95
|
+
@spec_file => ["false should be false"]
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should not include the subject file" do
|
100
|
+
subject_file = "lib/autotest/some.rb"
|
101
|
+
@rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb"
|
102
|
+
failures = [
|
103
|
+
[
|
104
|
+
"false should be false",
|
105
|
+
"expected: true,\n got: false (using ==)\n#{subject_file}:143:\n#{@spec_file}:203:"
|
109
106
|
]
|
110
|
-
|
111
|
-
|
107
|
+
]
|
108
|
+
@rspec_autotest.consolidate_failures(failures).keys.should_not include(subject_file)
|
112
109
|
end
|
113
110
|
end
|
114
111
|
end
|
data/spec/spec/dsl/main_spec.rb
CHANGED
@@ -10,7 +10,7 @@ module Spec
|
|
10
10
|
[:describe, :context].each do |method|
|
11
11
|
describe "##{method}" do
|
12
12
|
it "should delegate to Spec::Example::ExampleGroupFactory.create_example_group" do
|
13
|
-
block = lambda {}
|
13
|
+
block = lambda {|a,b|}
|
14
14
|
Spec::Example::ExampleGroupFactory.should_receive(:create_example_group).with(
|
15
15
|
"The ExampleGroup", hash_including(:spec_path), &block
|
16
16
|
)
|
@@ -22,7 +22,7 @@ module Spec
|
|
22
22
|
[:share_examples_for, :shared_examples_for].each do |method|
|
23
23
|
describe "##{method}" do
|
24
24
|
it "should create a shared ExampleGroup" do
|
25
|
-
block = lambda {}
|
25
|
+
block = lambda {|a,b|}
|
26
26
|
Spec::Example::ExampleGroupFactory.should_receive(:create_shared_example_group).with(
|
27
27
|
"shared group", hash_including(:spec_path), &block
|
28
28
|
)
|
@@ -63,7 +63,7 @@ module Spec
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "registers a shared ExampleGroup" do
|
66
|
-
block = lambda {}
|
66
|
+
block = lambda {|a,b|}
|
67
67
|
Spec::Example::ExampleGroupFactory.should_receive(:create_shared_example_group).with(
|
68
68
|
group_name, hash_including(:spec_path), &block
|
69
69
|
)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module DSL
|
5
|
+
module Matchers
|
6
|
+
describe "#create" do
|
7
|
+
it "creates a method that initializes a new matcher with the submitted name and expected arg" do
|
8
|
+
# FIXME - this expects new to be called, but we need something
|
9
|
+
# more robust - that expects new to be called with a specific
|
10
|
+
# block (lambda, proc, whatever)
|
11
|
+
mod = Module.new
|
12
|
+
mod.extend Spec::DSL::Matchers
|
13
|
+
mod.create(:foo)
|
14
|
+
|
15
|
+
obj = Object.new
|
16
|
+
obj.extend mod
|
17
|
+
|
18
|
+
Spec::Matchers::Matcher.should_receive(:new).with(:foo, 3)
|
19
|
+
|
20
|
+
obj.foo(3)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -3,18 +3,14 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Example
|
5
5
|
class ExampleGroupSubclass < ExampleGroup
|
6
|
-
|
7
|
-
|
8
|
-
end
|
9
|
-
|
10
|
-
def self.examples_ran=(examples_ran)
|
11
|
-
@examples_ran = examples_ran
|
6
|
+
class << self
|
7
|
+
attr_accessor :examples_ran
|
12
8
|
end
|
13
9
|
|
14
10
|
@@class_variable = :class_variable
|
15
11
|
CONSTANT = :constant
|
16
12
|
|
17
|
-
before do
|
13
|
+
before(:each) do
|
18
14
|
@instance_variable = :instance_variable
|
19
15
|
end
|
20
16
|
|
@@ -22,25 +18,28 @@ module Spec
|
|
22
18
|
self.class.examples_ran = true
|
23
19
|
end
|
24
20
|
|
25
|
-
|
21
|
+
def a_method
|
22
|
+
22
|
23
|
+
end
|
24
|
+
|
25
|
+
it "can access instance variables defined before(:each)" do
|
26
26
|
@instance_variable.should == :instance_variable
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
30
|
-
|
29
|
+
it "can access class variables (Ruby 1.8 only)" do
|
30
|
+
with_ruby 1.8 do
|
31
|
+
@@class_variable.should == :class_variable
|
32
|
+
end
|
31
33
|
end
|
32
34
|
|
33
|
-
it "
|
35
|
+
it "can access constants" do
|
34
36
|
CONSTANT.should == :constant
|
35
37
|
end
|
36
38
|
|
37
|
-
it "
|
39
|
+
it "can access methods defined in the Example Group" do
|
38
40
|
a_method.should == 22
|
39
41
|
end
|
40
42
|
|
41
|
-
def a_method
|
42
|
-
22
|
43
|
-
end
|
44
43
|
end
|
45
44
|
|
46
45
|
describe ExampleGroupSubclass do
|