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
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
class Substance
|
|
4
4
|
def initialize exists, description
|
|
5
5
|
@exists = exists
|
|
6
6
|
@description = description
|
|
7
7
|
end
|
|
8
|
-
def exist?
|
|
8
|
+
def exist?(arg=nil)
|
|
9
9
|
@exists
|
|
10
10
|
end
|
|
11
11
|
def inspect
|
|
@@ -36,6 +36,10 @@ describe "should exist" do
|
|
|
36
36
|
@real.should exist
|
|
37
37
|
end
|
|
38
38
|
|
|
39
|
+
it "passes if target exists with args" do
|
|
40
|
+
@real.should exist('this arg')
|
|
41
|
+
end
|
|
42
|
+
|
|
39
43
|
it "fails if target does not exist" do
|
|
40
44
|
lambda { @imaginary.should exist }.should fail
|
|
41
45
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
describe "should have_sym(*args)" do
|
|
4
4
|
it "should pass if #has_sym?(*args) returns true" do
|
|
@@ -11,6 +11,16 @@ describe "should have_sym(*args)" do
|
|
|
11
11
|
}.should fail_with("expected #has_key?(:a) to return true, got false")
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
+
it "should fail if #has_sym?(*args) returns nil" do
|
|
15
|
+
klass = Class.new do
|
|
16
|
+
def has_foo?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
lambda {
|
|
20
|
+
klass.new.should have_foo
|
|
21
|
+
}.should fail_with("expected #has_foo?(nil) to return true, got false")
|
|
22
|
+
end
|
|
23
|
+
|
|
14
24
|
it "should fail if target does not respond to #has_sym?" do
|
|
15
25
|
lambda {
|
|
16
26
|
Object.new.should have_key(:a)
|
|
@@ -31,6 +41,14 @@ describe "should_not have_sym(*args)" do
|
|
|
31
41
|
{:a => "A"}.should_not have_key(:b)
|
|
32
42
|
end
|
|
33
43
|
|
|
44
|
+
it "should pass if #has_sym?(*args) returns nil" do
|
|
45
|
+
klass = Class.new do
|
|
46
|
+
def has_foo?
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
klass.new.should_not have_foo
|
|
50
|
+
end
|
|
51
|
+
|
|
34
52
|
it "should fail if #has_sym?(*args) returns true" do
|
|
35
53
|
lambda {
|
|
36
54
|
{:a => "A"}.should_not have_key(:a)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spec
|
|
4
4
|
module Matchers
|
|
5
|
-
describe
|
|
5
|
+
describe Matcher do
|
|
6
6
|
context "without overrides" do
|
|
7
7
|
before(:each) do
|
|
8
8
|
@matcher = Spec::Matchers::Matcher.new(:be_a_multiple_of, 3) do |multiple|
|
|
@@ -11,7 +11,7 @@ module Spec
|
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
13
|
end
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
it "provides a default description" do
|
|
16
16
|
@matcher.description.should == "be a multiple of 3"
|
|
17
17
|
end
|
|
@@ -26,32 +26,32 @@ module Spec
|
|
|
26
26
|
@matcher.failure_message_for_should_not.should == "expected 9 not to be a multiple of 3"
|
|
27
27
|
end
|
|
28
28
|
end
|
|
29
|
-
|
|
29
|
+
|
|
30
30
|
it "is not diffable by default" do
|
|
31
31
|
matcher = Spec::Matchers::Matcher.new(:name) {}
|
|
32
32
|
matcher.should_not be_diffable
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
it "is diffable when told to be" do
|
|
36
36
|
matcher = Spec::Matchers::Matcher.new(:name) { diffable }
|
|
37
37
|
matcher.should be_diffable
|
|
38
38
|
end
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
it "provides expected" do
|
|
41
41
|
matcher = Spec::Matchers::Matcher.new(:name, 'expected string') {}
|
|
42
42
|
matcher.expected.should == ['expected string']
|
|
43
43
|
end
|
|
44
|
-
|
|
44
|
+
|
|
45
45
|
it "provides actual" do
|
|
46
46
|
matcher = Spec::Matchers::Matcher.new(:name, 'expected string') do
|
|
47
47
|
match {|actual|}
|
|
48
48
|
end
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
matcher.matches?('actual string')
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
matcher.actual.should == 'actual string'
|
|
53
53
|
end
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
context "with overrides" do
|
|
56
56
|
before(:each) do
|
|
57
57
|
@matcher = Spec::Matchers::Matcher.new(:be_boolean, true) do |boolean|
|
|
@@ -86,16 +86,16 @@ module Spec
|
|
|
86
86
|
@matcher.matches?(false)
|
|
87
87
|
@matcher.failure_message_for_should.should == "expected false to be the boolean true"
|
|
88
88
|
end
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
it "overrides the failure message for #should_not" do
|
|
91
91
|
@matcher.matches?(true)
|
|
92
92
|
@matcher.failure_message_for_should_not.should == "expected true not to be the boolean true"
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
|
-
|
|
95
|
+
|
|
96
96
|
context "#new" do
|
|
97
97
|
it "passes matches? arg to match block" do
|
|
98
|
-
matcher = Spec::Matchers::Matcher.new(:ignore) do
|
|
98
|
+
matcher = Spec::Matchers::Matcher.new(:ignore) do
|
|
99
99
|
match do |actual|
|
|
100
100
|
actual == 5
|
|
101
101
|
end
|
|
@@ -115,22 +115,22 @@ module Spec
|
|
|
115
115
|
|
|
116
116
|
context "with no args" do
|
|
117
117
|
before(:each) do
|
|
118
|
-
@matcher = Spec::Matchers::Matcher.new(:matcher_name) do
|
|
118
|
+
@matcher = Spec::Matchers::Matcher.new(:matcher_name) do
|
|
119
119
|
match do |actual|
|
|
120
120
|
actual == 5
|
|
121
121
|
end
|
|
122
|
-
end
|
|
122
|
+
end
|
|
123
123
|
end
|
|
124
|
-
|
|
124
|
+
|
|
125
125
|
it "matches" do
|
|
126
126
|
@matcher.matches?(5).should be_true
|
|
127
127
|
end
|
|
128
|
-
|
|
128
|
+
|
|
129
129
|
it "describes" do
|
|
130
130
|
@matcher.description.should == "matcher name"
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
context "with 1 arg" do
|
|
135
135
|
before(:each) do
|
|
136
136
|
@matcher = Spec::Matchers::Matcher.new(:matcher_name, 1) do |expected|
|
|
@@ -139,16 +139,16 @@ module Spec
|
|
|
139
139
|
end
|
|
140
140
|
end
|
|
141
141
|
end
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
it "matches" do
|
|
144
144
|
@matcher.matches?(5).should be_true
|
|
145
145
|
end
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
it "describes" do
|
|
148
148
|
@matcher.description.should == "matcher name 1"
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
|
-
|
|
151
|
+
|
|
152
152
|
context "with multiple args" do
|
|
153
153
|
before(:each) do
|
|
154
154
|
@matcher = Spec::Matchers::Matcher.new(:matcher_name, 1, 2, 3, 4) do |a,b,c,d|
|
|
@@ -157,16 +157,16 @@ module Spec
|
|
|
157
157
|
end
|
|
158
158
|
end
|
|
159
159
|
end
|
|
160
|
-
|
|
160
|
+
|
|
161
161
|
it "matches" do
|
|
162
162
|
@matcher.matches?(10).should be_true
|
|
163
163
|
end
|
|
164
|
-
|
|
164
|
+
|
|
165
165
|
it "describes" do
|
|
166
166
|
@matcher.description.should == "matcher name 1, 2, 3, and 4"
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
it "supports helper methods" do
|
|
171
171
|
matcher = Spec::Matchers::Matcher.new(:be_similar_to, [1,2,3]) do |sample|
|
|
172
172
|
match do |actual|
|
|
@@ -177,25 +177,52 @@ module Spec
|
|
|
177
177
|
a.sort == b.sort
|
|
178
178
|
end
|
|
179
179
|
end
|
|
180
|
-
|
|
180
|
+
|
|
181
181
|
matcher.matches?([2,3,1]).should be_true
|
|
182
182
|
end
|
|
183
|
-
|
|
183
|
+
|
|
184
184
|
it "supports fluent interface" do
|
|
185
185
|
matcher = Spec::Matchers::Matcher.new(:first_word) do
|
|
186
186
|
def second_word
|
|
187
187
|
self
|
|
188
188
|
end
|
|
189
189
|
end
|
|
190
|
-
|
|
190
|
+
|
|
191
191
|
matcher.second_word.should == matcher
|
|
192
192
|
end
|
|
193
|
-
|
|
193
|
+
|
|
194
194
|
it "treats method missing normally for undeclared methods" do
|
|
195
195
|
matcher = Spec::Matchers::Matcher.new(:ignore) { }
|
|
196
196
|
expect { matcher.non_existent_method }.to raise_error(NoMethodError)
|
|
197
197
|
end
|
|
198
198
|
|
|
199
|
+
it "has access to other matchers" do
|
|
200
|
+
matcher = Spec::Matchers::Matcher.new(:ignore, 3) do |expected|
|
|
201
|
+
match do |actual|
|
|
202
|
+
extend Spec::Matchers
|
|
203
|
+
actual.should eql(5 + expected)
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
matcher.matches?(8).should be_true
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
it "lets you override the actual() in messages" do
|
|
211
|
+
matcher = Spec::Matchers::Matcher.new(:be_foo) do
|
|
212
|
+
match do |actual|
|
|
213
|
+
@submitted = actual
|
|
214
|
+
false
|
|
215
|
+
end
|
|
216
|
+
|
|
217
|
+
def actual
|
|
218
|
+
"replaced"
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
matcher.matches?("foo")
|
|
223
|
+
matcher.failure_message_for_should.should =~ /replaced/
|
|
224
|
+
end
|
|
225
|
+
|
|
199
226
|
end
|
|
200
227
|
end
|
|
201
228
|
end
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
module Spec
|
|
4
|
+
module Mocks
|
|
5
|
+
module ArgumentMatchers
|
|
6
|
+
describe AnyArgsMatcher do
|
|
7
|
+
it "represents itself nicely for failure messages" do
|
|
8
|
+
AnyArgsMatcher.new.description.should == "any args"
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe AnyArgMatcher do
|
|
13
|
+
it "represents itself nicely for failure messages" do
|
|
14
|
+
AnyArgMatcher.new(nil).description.should == "anything"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -20,7 +20,7 @@ describe "Mock" do
|
|
|
20
20
|
begin
|
|
21
21
|
@mock.foobar
|
|
22
22
|
rescue Exception => e
|
|
23
|
-
e.message.should == "Mock
|
|
23
|
+
e.message.should == "Mock \"test mock\" received unexpected message :foobar with (no args)"
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Spec
|
|
4
4
|
module Mocks
|
|
@@ -9,7 +9,7 @@ module Spec
|
|
|
9
9
|
m.should_receive(:bar).with("message")
|
|
10
10
|
lambda {
|
|
11
11
|
m.bar("different message")
|
|
12
|
-
}.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock
|
|
12
|
+
}.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock "foo" received :bar with unexpected arguments\n expected: ("message")\n got: ("different message")})
|
|
13
13
|
m.bar("message") # allows the spec to pass
|
|
14
14
|
end
|
|
15
15
|
|
|
@@ -22,7 +22,7 @@ module Spec
|
|
|
22
22
|
m.should_receive(:bar).with("message")
|
|
23
23
|
lambda {
|
|
24
24
|
m.bar("different message")
|
|
25
|
-
}.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock
|
|
25
|
+
}.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock "foo" received :bar with unexpected arguments\n expected: ("message")\n got: ("different message")})
|
|
26
26
|
m.bar("message") # allows the spec to pass
|
|
27
27
|
end
|
|
28
28
|
end
|