rspec 1.2.8 → 1.2.9
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.rdoc +41 -2
- data/Manifest.txt +11 -10
- data/Rakefile +47 -22
- data/Ruby1.9.rdoc +1 -2
- data/Upgrade.rdoc +56 -7
- data/bin/spec +2 -1
- data/cucumber.yml +3 -1
- data/examples/failing/README.txt +7 -3
- data/examples/failing/failing_implicit_docstrings_example.rb +0 -2
- data/examples/failing/mocking_example.rb +0 -2
- data/examples/failing/partial_mock_example.rb +0 -2
- data/examples/failing/pending_example.rb +0 -2
- data/examples/failing/predicate_example.rb +0 -2
- data/examples/failing/team_spec.rb +0 -3
- data/examples/failing/timeout_behaviour.rb +0 -2
- data/examples/passing/custom_formatter.rb +0 -1
- data/examples/passing/dynamic_spec.rb +0 -2
- data/examples/passing/file_accessor.rb +1 -2
- data/examples/passing/file_accessor_spec.rb +1 -2
- data/examples/passing/filtered_formatter.rb +0 -1
- data/examples/passing/greeter_spec.rb +0 -1
- data/examples/passing/helper_method_example.rb +0 -2
- data/examples/passing/implicit_docstrings_example.rb +0 -2
- data/examples/passing/io_processor_spec.rb +1 -2
- data/examples/passing/mocking_example.rb +0 -2
- data/examples/passing/nested_classes_example.rb +1 -2
- data/examples/passing/options_example.rb +0 -2
- data/examples/passing/partial_mock_example.rb +0 -2
- data/examples/passing/pending_example.rb +0 -2
- data/examples/passing/predicate_example.rb +0 -2
- data/examples/passing/shared_example_group_example.rb +0 -2
- data/examples/passing/simple_matcher_example.rb +0 -2
- data/examples/passing/stack_spec.rb +2 -3
- data/examples/passing/stack_spec_with_nested_example_groups.rb +2 -3
- data/examples/passing/stubbing_example.rb +0 -2
- data/examples/passing/yielding_example.rb +0 -2
- data/features/before_and_after_blocks/before_and_after_blocks.feature +4 -4
- data/features/command_line/line_number_option.feature +14 -14
- data/features/command_line/line_number_option_with_example_with_no_name.feature +2 -2
- data/features/example_groups/define_example_attribute.feature +41 -0
- data/features/example_groups/example_group_with_should_methods.feature +1 -1
- data/features/example_groups/implicit_docstrings.feature +7 -7
- data/features/example_groups/nested_groups.feature +2 -2
- data/features/expectations/customized_message.feature +4 -4
- data/features/expectations/expect_change.feature +4 -4
- data/features/expectations/expect_error.feature +4 -4
- data/features/extensions/custom_example_group.feature +10 -10
- data/features/formatters/custom_formatter.feature +3 -3
- data/features/interop/examples_and_tests_together.feature +10 -6
- data/features/interop/rspec_output.feature +1 -1
- data/features/interop/test_case_with_should_methods.feature +1 -1
- data/features/load_paths/add_lib_to_load_path.feature +20 -0
- data/features/load_paths/add_spec_to_load_path.feature +20 -0
- data/features/matchers/define_diffable_matcher.feature +2 -2
- data/features/matchers/define_matcher.feature +19 -19
- data/features/matchers/define_matcher_outside_rspec.feature +2 -3
- data/features/matchers/define_matcher_with_fluent_interface.feature +2 -2
- data/features/matchers/define_wrapped_matcher.feature +29 -0
- data/features/mock_framework_integration/use_flexmock.feature +1 -1
- data/features/mock_framework_integration/use_mocha.feature +1 -1
- data/features/mock_framework_integration/use_rr.feature +1 -1
- data/features/mocks/mix_stubs_and_mocks.feature +2 -2
- data/features/mocks/stub_implementation.feature +1 -1
- data/features/pending/pending_examples.feature +16 -16
- data/features/runner/specify_line_number.feature +4 -4
- data/features/spec_helper/spec_helper.feature +25 -0
- data/features/step_definitions/running_rspec_steps.rb +4 -2
- data/features/subject/explicit_subject.feature +2 -2
- data/features/subject/implicit_subject.feature +14 -2
- data/features/support/env.rb +6 -3
- data/lib/spec/adapters/mock_frameworks/mocha.rb +6 -1
- data/lib/spec/example/example_group_methods.rb +7 -0
- data/lib/spec/example/example_methods.rb +1 -1
- data/lib/spec/example/subject.rb +8 -0
- data/lib/spec/interop/test.rb +27 -1
- data/lib/spec/interop/test/unit/testcase.rb +1 -1
- data/lib/spec/matchers/exist.rb +2 -2
- data/lib/spec/matchers/extensions/instance_exec.rb +28 -20
- data/lib/spec/matchers/matcher.rb +21 -20
- data/lib/spec/mocks/argument_matchers.rb +17 -13
- data/lib/spec/mocks/error_generator.rb +14 -3
- data/lib/spec/mocks/{spec_methods.rb → example_methods.rb} +25 -11
- data/lib/spec/mocks/framework.rb +1 -1
- data/lib/spec/mocks/methods.rb +15 -0
- data/lib/spec/mocks/mock.rb +16 -10
- data/lib/spec/mocks/proxy.rb +1 -1
- data/lib/spec/rake/spectask.rb +3 -3
- data/lib/spec/runner/backtrace_tweaker.rb +41 -22
- data/lib/spec/runner/configuration.rb +18 -1
- data/lib/spec/runner/differs/default.rb +1 -1
- data/lib/spec/runner/drb_command_line.rb +5 -2
- data/lib/spec/runner/formatter/base_text_formatter.rb +8 -3
- data/lib/spec/runner/option_parser.rb +21 -15
- data/lib/spec/runner/options.rb +54 -23
- data/lib/spec/version.rb +3 -3
- data/resources/helpers/cmdline.rb +0 -1
- data/spec/autotest/autotest_helper.rb +4 -6
- data/spec/autotest/discover_spec.rb +2 -2
- data/spec/autotest/failed_results_re_spec.rb +1 -1
- data/spec/autotest/rspec_spec.rb +1 -1
- data/spec/spec/dsl/main_spec.rb +1 -1
- data/spec/spec/example/example_group_class_definition_spec.rb +1 -1
- data/spec/spec/example/example_group_factory_spec.rb +1 -1
- data/spec/spec/example/example_group_methods_spec.rb +21 -1
- data/spec/spec/example/example_group_proxy_spec.rb +1 -1
- data/spec/spec/example/example_group_spec.rb +1 -1
- data/spec/spec/example/example_matcher_spec.rb +1 -1
- data/spec/spec/example/example_methods_spec.rb +1 -1
- data/spec/spec/example/example_proxy_spec.rb +1 -1
- data/spec/spec/example/helper_method_spec.rb +1 -1
- data/spec/spec/example/nested_example_group_spec.rb +1 -1
- data/spec/spec/example/predicate_matcher_spec.rb +1 -1
- data/spec/spec/example/shared_example_group_spec.rb +1 -1
- data/spec/spec/example/subclassing_example_group_spec.rb +1 -1
- data/spec/spec/example/subject_spec.rb +17 -1
- data/spec/spec/expectations/differs/default_spec.rb +16 -3
- data/spec/spec/expectations/extensions/kernel_spec.rb +1 -1
- data/spec/spec/expectations/fail_with_spec.rb +1 -1
- data/spec/spec/expectations/handler_spec.rb +1 -1
- data/spec/spec/expectations/wrap_expectation_spec.rb +1 -1
- data/spec/spec/interop/test/unit/resources/test_case_with_various_names.rb +22 -0
- data/spec/spec/interop/test/unit/spec_spec.rb +1 -1
- data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +2 -2
- data/spec/spec/interop/test/unit/testcase_spec.rb +7 -2
- data/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +1 -1
- data/spec/spec/matchers/be_close_spec.rb +1 -1
- data/spec/spec/matchers/be_instance_of_spec.rb +1 -1
- data/spec/spec/matchers/be_kind_of_spec.rb +1 -1
- data/spec/spec/matchers/be_spec.rb +13 -1
- data/spec/spec/matchers/change_spec.rb +1 -1
- data/spec/spec/matchers/compatibility_spec.rb +1 -1
- data/spec/spec/matchers/description_generation_spec.rb +1 -1
- data/spec/spec/matchers/dsl_spec.rb +1 -1
- data/spec/spec/matchers/eql_spec.rb +1 -1
- data/spec/spec/matchers/equal_spec.rb +1 -1
- data/spec/spec/matchers/exist_spec.rb +6 -2
- data/spec/spec/matchers/has_spec.rb +19 -1
- data/spec/spec/matchers/have_spec.rb +1 -1
- data/spec/spec/matchers/include_spec.rb +1 -1
- data/spec/spec/matchers/match_array_spec.rb +1 -1
- data/spec/spec/matchers/match_spec.rb +1 -1
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -1
- data/spec/spec/matchers/matcher_spec.rb +55 -28
- data/spec/spec/matchers/matchers_spec.rb +1 -1
- data/spec/spec/matchers/operator_matcher_spec.rb +1 -1
- data/spec/spec/matchers/raise_error_spec.rb +1 -1
- data/spec/spec/matchers/respond_to_spec.rb +1 -1
- data/spec/spec/matchers/satisfy_spec.rb +1 -1
- data/spec/spec/matchers/simple_matcher_spec.rb +1 -1
- data/spec/spec/matchers/throw_symbol_spec.rb +1 -1
- data/spec/spec/mocks/any_number_of_times_spec.rb +1 -1
- data/spec/spec/mocks/argument_expectation_spec.rb +1 -1
- data/spec/spec/mocks/argument_matchers_spec.rb +19 -0
- data/spec/spec/mocks/at_least_spec.rb +1 -1
- data/spec/spec/mocks/at_most_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_10260_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_10263_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_11545_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_15719_spec.rb +3 -3
- data/spec/spec/mocks/bug_report_496_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_600_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_7611_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_7805_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_8165_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_8302_spec.rb +1 -1
- data/spec/spec/mocks/bug_report_830_spec.rb +1 -1
- data/spec/spec/mocks/double_spec.rb +12 -0
- data/spec/spec/mocks/failing_argument_matchers_spec.rb +6 -6
- data/spec/spec/mocks/hash_including_matcher_spec.rb +1 -1
- data/spec/spec/mocks/hash_not_including_matcher_spec.rb +1 -1
- data/spec/spec/mocks/mock_ordering_spec.rb +4 -4
- data/spec/spec/mocks/mock_space_spec.rb +1 -1
- data/spec/spec/mocks/mock_spec.rb +20 -24
- data/spec/spec/mocks/multiple_return_value_spec.rb +8 -8
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
- data/spec/spec/mocks/null_object_mock_spec.rb +1 -1
- data/spec/spec/mocks/once_counts_spec.rb +1 -1
- data/spec/spec/mocks/options_hash_spec.rb +1 -1
- data/spec/spec/mocks/partial_mock_spec.rb +1 -1
- data/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +1 -1
- data/spec/spec/mocks/passing_argument_matchers_spec.rb +1 -1
- data/spec/spec/mocks/precise_counts_spec.rb +1 -1
- data/spec/spec/mocks/record_messages_spec.rb +1 -1
- data/spec/spec/mocks/stub_chain_spec.rb +1 -1
- data/spec/spec/mocks/stub_implementation_spec.rb +1 -1
- data/spec/spec/mocks/stub_spec.rb +14 -9
- data/spec/spec/mocks/stubbed_message_expectations_spec.rb +2 -2
- data/spec/spec/mocks/twice_counts_spec.rb +1 -1
- data/spec/spec/mocks/unstub_spec.rb +1 -1
- data/spec/spec/package/bin_spec_spec.rb +4 -10
- data/spec/spec/rake/spectask_spec.rb +2 -2
- data/spec/spec/runner/class_and_argument_parser_spec.rb +1 -1
- data/spec/spec/runner/command_line_spec.rb +1 -1
- data/spec/spec/runner/configuration_spec.rb +15 -6
- data/spec/spec/runner/drb_command_line_spec.rb +1 -1
- data/spec/spec/runner/example_group_runner_spec.rb +1 -1
- data/spec/spec/runner/formatter/base_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +10 -1
- data/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +72 -76
- data/spec/spec/runner/formatter/html_formatted-1.8.6.html +50 -50
- data/spec/spec/runner/formatter/html_formatted-1.8.7.html +50 -50
- data/spec/spec/runner/formatter/html_formatted-1.9.1.html +61 -69
- data/spec/spec/runner/formatter/html_formatter_spec.rb +26 -26
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/profile_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +13 -9
- data/spec/spec/runner/formatter/snippet_extractor_spec.rb +1 -1
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/{text_mate_formatted-1.8.4.html → text_mate_formatted-1.8.6-jruby.html} +64 -59
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +46 -46
- data/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +46 -46
- data/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +55 -63
- data/spec/spec/runner/formatter/text_mate_formatter_spec.rb +3 -3
- data/spec/spec/runner/heckle_runner_spec.rb +1 -1
- data/spec/spec/runner/heckler_spec.rb +1 -1
- data/spec/spec/runner/line_number_query/line_number_query_fixture.rb +1 -1
- data/spec/spec/runner/line_number_query_spec.rb +10 -1
- data/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +22 -16
- data/spec/spec/runner/option_parser_spec.rb +48 -14
- data/spec/spec/runner/options_spec.rb +16 -2
- data/spec/spec/runner/output_one_time_fixture.rb +1 -1
- data/spec/spec/runner/output_one_time_fixture_runner.rb +2 -3
- data/spec/spec/runner/output_one_time_spec.rb +6 -7
- data/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +65 -22
- data/spec/spec/runner/reporter_spec.rb +1 -1
- data/spec/spec/runner_spec.rb +1 -1
- data/spec/spec_helper.rb +5 -7
- data/spec/{spec → support}/spec_classes.rb +0 -0
- metadata +58 -17
- data/examples/failing/spec_helper.rb +0 -3
- data/examples/passing/spec_helper.rb +0 -3
- data/features/heckle/heckle.feature +0 -56
- data/spec/rspec_suite.rb +0 -6
- data/spec/spec/runner/formatter/html_formatted-1.8.4.html +0 -366
- data/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +0 -387
- data/spec/spec/runner/formatter/html_formatted-1.8.5.html +0 -372
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe "double" do
|
|
4
|
+
it "is an alias for stub and mock" do
|
|
5
|
+
double().should be_a(Spec::Mocks::Mock)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "uses 'Double' in failure messages" do
|
|
9
|
+
double = double('name')
|
|
10
|
+
expect {double.foo}.to raise_error(/Double "name" received/)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spec
|
|
4
4
|
module Mocks
|
|
@@ -52,35 +52,35 @@ module Spec
|
|
|
52
52
|
@mock.should_receive(:random_call).with(:a => "b", :c => "d")
|
|
53
53
|
lambda do
|
|
54
54
|
@mock.random_call(:a => "b", :c => "e")
|
|
55
|
-
end.should raise_error(MockExpectationError, /Mock
|
|
55
|
+
end.should raise_error(MockExpectationError, /Mock "test mock" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
it "should fail for a hash w/ wrong keys" do
|
|
59
59
|
@mock.should_receive(:random_call).with(:a => "b", :c => "d")
|
|
60
60
|
lambda do
|
|
61
61
|
@mock.random_call("a" => "b", "c" => "d")
|
|
62
|
-
end.should raise_error(MockExpectationError, /Mock
|
|
62
|
+
end.should raise_error(MockExpectationError, /Mock "test mock" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/)
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
it "should match against a Matcher" do
|
|
66
66
|
lambda do
|
|
67
67
|
@mock.should_receive(:msg).with(equal(3))
|
|
68
68
|
@mock.msg(37)
|
|
69
|
-
end.should raise_error(MockExpectationError, "Mock
|
|
69
|
+
end.should raise_error(MockExpectationError, "Mock \"test mock\" received :msg with unexpected arguments\n expected: (equal 3)\n got: (37)")
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it "should fail no_args with one arg" do
|
|
73
73
|
lambda do
|
|
74
74
|
@mock.should_receive(:msg).with(no_args)
|
|
75
75
|
@mock.msg(37)
|
|
76
|
-
end.should raise_error(MockExpectationError, "Mock
|
|
76
|
+
end.should raise_error(MockExpectationError, "Mock \"test mock\" received :msg with unexpected arguments\n expected: (no args)\n got: (37)")
|
|
77
77
|
end
|
|
78
78
|
|
|
79
79
|
it "should fail hash_including with missing key" do
|
|
80
80
|
lambda do
|
|
81
81
|
@mock.should_receive(:msg).with(hash_including(:a => 1))
|
|
82
82
|
@mock.msg({})
|
|
83
|
-
end.should raise_error(MockExpectationError, "Mock
|
|
83
|
+
end.should raise_error(MockExpectationError, "Mock \"test mock\" received :msg with unexpected arguments\n expected: (hash_including(:a=>1))\n got: ({})")
|
|
84
84
|
end
|
|
85
85
|
|
|
86
86
|
it "should fail with block matchers" do
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spec
|
|
4
4
|
module Mocks
|
|
@@ -36,7 +36,7 @@ module Spec
|
|
|
36
36
|
@mock.should_receive(:two).ordered
|
|
37
37
|
lambda do
|
|
38
38
|
@mock.two
|
|
39
|
-
end.should raise_error(MockExpectationError, "Mock
|
|
39
|
+
end.should raise_error(MockExpectationError, "Mock \"test mock\" received :two out of order")
|
|
40
40
|
end
|
|
41
41
|
|
|
42
42
|
it "should fail if third call comes first" do
|
|
@@ -46,7 +46,7 @@ module Spec
|
|
|
46
46
|
@mock.one
|
|
47
47
|
lambda do
|
|
48
48
|
@mock.three
|
|
49
|
-
end.should raise_error(MockExpectationError, "Mock
|
|
49
|
+
end.should raise_error(MockExpectationError, "Mock \"test mock\" received :three out of order")
|
|
50
50
|
end
|
|
51
51
|
|
|
52
52
|
it "should fail if third call comes second" do
|
|
@@ -56,7 +56,7 @@ module Spec
|
|
|
56
56
|
@mock.one
|
|
57
57
|
lambda do
|
|
58
58
|
@mock.three
|
|
59
|
-
end.should raise_error(MockExpectationError, "Mock
|
|
59
|
+
end.should raise_error(MockExpectationError, "Mock \"test mock\" received :three out of order")
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
it "should ignore order of non ordered calls" do
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spec
|
|
4
4
|
module Mocks
|
|
@@ -68,7 +68,7 @@ module Spec
|
|
|
68
68
|
lambda {
|
|
69
69
|
@mock.not_expected
|
|
70
70
|
violated
|
|
71
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
71
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once")
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
it "should fail when receiving message specified as not to be received with args" do
|
|
@@ -76,7 +76,7 @@ module Spec
|
|
|
76
76
|
lambda {
|
|
77
77
|
@mock.not_expected("unexpected text")
|
|
78
78
|
violated
|
|
79
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
79
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (\"unexpected text\") 0 times, but received it once")
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
it "should pass when receiving message specified as not to be received with wrong args" do
|
|
@@ -108,7 +108,7 @@ module Spec
|
|
|
108
108
|
lambda {
|
|
109
109
|
@mock.something("a","d","c")
|
|
110
110
|
violated
|
|
111
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
111
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: (\"a\", \"d\", \"c\")")
|
|
112
112
|
end
|
|
113
113
|
|
|
114
114
|
it "should raise exception if args don't match when method called even when the method is stubbed" do
|
|
@@ -117,7 +117,7 @@ module Spec
|
|
|
117
117
|
lambda {
|
|
118
118
|
@mock.something("a","d","c")
|
|
119
119
|
@mock.rspec_verify
|
|
120
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
120
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: ([\"a\", \"d\", \"c\"])")
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
it "should raise exception if args don't match when method called even when using null_object" do
|
|
@@ -126,14 +126,14 @@ module Spec
|
|
|
126
126
|
lambda {
|
|
127
127
|
@mock.something("a","d","c")
|
|
128
128
|
@mock.rspec_verify
|
|
129
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
129
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: ([\"a\", \"d\", \"c\"])")
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
it "should fail if unexpected method called" do
|
|
133
133
|
lambda {
|
|
134
134
|
@mock.something("a","b","c")
|
|
135
135
|
violated
|
|
136
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
136
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" received unexpected message :something with (\"a\", \"b\", \"c\")")
|
|
137
137
|
end
|
|
138
138
|
|
|
139
139
|
it "should use block for expectation if provided" do
|
|
@@ -150,21 +150,21 @@ module Spec
|
|
|
150
150
|
@mock.should_receive(:something) {| bool | bool.should be_true}
|
|
151
151
|
lambda {
|
|
152
152
|
@mock.something false
|
|
153
|
-
}.should raise_error(MockExpectationError, /Mock
|
|
153
|
+
}.should raise_error(MockExpectationError, /Mock "test mock" received :something but passed block failed with: expected true, got false/)
|
|
154
154
|
end
|
|
155
155
|
|
|
156
156
|
it "should fail right away when method defined as never is received" do
|
|
157
157
|
@mock.should_receive(:not_expected).never
|
|
158
158
|
lambda {
|
|
159
159
|
@mock.not_expected
|
|
160
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
160
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once")
|
|
161
161
|
end
|
|
162
162
|
|
|
163
163
|
it "should eventually fail when method defined as never is received" do
|
|
164
164
|
@mock.should_receive(:not_expected).never
|
|
165
165
|
lambda {
|
|
166
166
|
@mock.not_expected
|
|
167
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
167
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once")
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
it "should raise when told to" do
|
|
@@ -224,14 +224,14 @@ module Spec
|
|
|
224
224
|
@mock.should_receive(:something).with(no_args())
|
|
225
225
|
lambda {
|
|
226
226
|
@mock.something 1
|
|
227
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
227
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (no args)\n got: (1)")
|
|
228
228
|
end
|
|
229
229
|
|
|
230
230
|
it "should fail when args are expected but none are received" do
|
|
231
231
|
@mock.should_receive(:something).with(1)
|
|
232
232
|
lambda {
|
|
233
233
|
@mock.something
|
|
234
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
234
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (1)\n got: (no args)")
|
|
235
235
|
end
|
|
236
236
|
|
|
237
237
|
it "should return value from block by default" do
|
|
@@ -339,7 +339,7 @@ module Spec
|
|
|
339
339
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
|
|
340
340
|
lambda {
|
|
341
341
|
@mock.yield_back {|a|}
|
|
342
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
342
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" yielded |\"wha\", \"zup\"| to block with arity of 1")
|
|
343
343
|
end
|
|
344
344
|
|
|
345
345
|
it "should fail when calling yielding method consecutively with wrong arity" do
|
|
@@ -350,14 +350,14 @@ module Spec
|
|
|
350
350
|
a, b = nil
|
|
351
351
|
c = []
|
|
352
352
|
@mock.yield_back {|a,b| c << [a, b]}
|
|
353
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
353
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" yielded |\"down\"| to block with arity of 2")
|
|
354
354
|
end
|
|
355
355
|
|
|
356
356
|
it "should fail when calling yielding method without block" do
|
|
357
357
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
|
|
358
358
|
lambda {
|
|
359
359
|
@mock.yield_back
|
|
360
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
360
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" asked to yield |[\"wha\", \"zup\"]| but no block was passed")
|
|
361
361
|
end
|
|
362
362
|
|
|
363
363
|
it "should be able to mock send" do
|
|
@@ -384,7 +384,7 @@ module Spec
|
|
|
384
384
|
@mock.rspec_verify
|
|
385
385
|
lambda {
|
|
386
386
|
@mock.foobar
|
|
387
|
-
}.should raise_error(MockExpectationError, "Mock
|
|
387
|
+
}.should raise_error(MockExpectationError, "Mock \"test mock\" received unexpected message :foobar with (no args)")
|
|
388
388
|
end
|
|
389
389
|
|
|
390
390
|
it "should restore objects to their original state on rspec_reset" do
|
|
@@ -569,15 +569,11 @@ module Spec
|
|
|
569
569
|
end
|
|
570
570
|
|
|
571
571
|
describe "mock created with no name" do
|
|
572
|
-
it "should name
|
|
573
|
-
mock
|
|
572
|
+
it "should not use a name in a failure message" do
|
|
573
|
+
mock = mock()
|
|
574
|
+
expect {mock.foo}.to raise_error(/Mock received/)
|
|
574
575
|
end
|
|
575
|
-
|
|
576
|
-
it "should name itself after initially stubbed methods" do
|
|
577
|
-
string = mock(:foo => "woo", :bar => "car").to_s
|
|
578
|
-
string.should include('foo: \"woo\"', 'bar: \"car\"')
|
|
579
|
-
end
|
|
580
|
-
|
|
576
|
+
|
|
581
577
|
it "should respond to initially stubbed methods" do
|
|
582
578
|
mock = mock(:foo => "woo", :bar => "car")
|
|
583
579
|
mock.foo.should == "woo"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spec
|
|
4
4
|
module Mocks
|
|
@@ -20,7 +20,7 @@ module Spec
|
|
|
20
20
|
third = Object.new
|
|
21
21
|
@mock.message.should == @return_values[0]
|
|
22
22
|
@mock.message.should == @return_values[1]
|
|
23
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock
|
|
23
|
+
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it twice")
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
it "should complain when there are too many calls" do
|
|
@@ -29,7 +29,7 @@ module Spec
|
|
|
29
29
|
@mock.message.should == @return_values[1]
|
|
30
30
|
@mock.message.should == @return_values[2]
|
|
31
31
|
@mock.message.should == @return_values[2]
|
|
32
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock
|
|
32
|
+
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times")
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
@@ -51,7 +51,7 @@ module Spec
|
|
|
51
51
|
third = Object.new
|
|
52
52
|
@mock.message.should == @return_values[0]
|
|
53
53
|
@mock.message.should == @return_values[1]
|
|
54
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock
|
|
54
|
+
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it twice")
|
|
55
55
|
end
|
|
56
56
|
|
|
57
57
|
it "should complain when there are too many calls" do
|
|
@@ -60,7 +60,7 @@ module Spec
|
|
|
60
60
|
@mock.message.should == @return_values[1]
|
|
61
61
|
@mock.message.should == @return_values[2]
|
|
62
62
|
@mock.message.should == @return_values[2]
|
|
63
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock
|
|
63
|
+
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times")
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
@@ -79,7 +79,7 @@ module Spec
|
|
|
79
79
|
|
|
80
80
|
it "should fail when called less than the specified number" do
|
|
81
81
|
@mock.message.should equal(11)
|
|
82
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock
|
|
82
|
+
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (no args) twice, but received it once")
|
|
83
83
|
end
|
|
84
84
|
end
|
|
85
85
|
describe "a Mock expectation with multiple return values with a specified count larger than the number of values" do
|
|
@@ -97,7 +97,7 @@ module Spec
|
|
|
97
97
|
|
|
98
98
|
it "should fail when called less than the specified number" do
|
|
99
99
|
@mock.message.should equal(11)
|
|
100
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock
|
|
100
|
+
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it once")
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
it "should fail when called greater than the specified number" do
|
|
@@ -105,7 +105,7 @@ module Spec
|
|
|
105
105
|
@mock.message.should equal(22)
|
|
106
106
|
@mock.message.should equal(22)
|
|
107
107
|
@mock.message.should equal(22)
|
|
108
|
-
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock
|
|
108
|
+
lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times")
|
|
109
109
|
end
|
|
110
110
|
end
|
|
111
111
|
end
|