dchelimsky-rspec 1.1.11.1 → 1.1.11.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +11 -3
- data/Manifest.txt +35 -46
- data/README.txt +30 -12
- data/Rakefile +9 -9
- data/{stories/configuration/before_blocks.story → features/configuration/before_blocks.feature} +2 -2
- data/{stories/example_groups/autogenerated_docstrings → features/example_groups/autogenerated_docstrings.feature} +1 -1
- data/{stories/example_groups/example_group_with_should_methods → features/example_groups/example_group_with_should_methods.feature} +3 -3
- data/{stories/example_groups/nested_groups → features/example_groups/nested_groups.feature} +1 -1
- data/{stories/example_groups/output → features/example_groups/output.feature} +3 -8
- data/{stories/interop/examples_and_tests_together → features/interop/examples_and_tests_together.feature} +5 -4
- data/{stories/interop/test_but_not_test_unit → features/interop/test_but_not_test_unit.feature} +2 -2
- data/{stories/interop/test_case_with_should_methods → features/interop/test_case_with_should_methods.feature} +2 -2
- data/{stories/mock_framework_integration/use_flexmock.story → features/mock_framework_integration/use_flexmock.feature} +1 -1
- data/features/step_definitions/running_rspec.rb +48 -0
- data/features/support/env.rb +25 -0
- data/{stories/resources → features/support}/helpers/cmdline.rb +0 -0
- data/{stories/resources → features/support}/helpers/story_helper.rb +0 -0
- data/{stories/resources → features/support}/matchers/smart_match.rb +0 -0
- data/{plugins → lib/adapters}/mock_frameworks/flexmock.rb +0 -0
- data/{plugins → lib/adapters}/mock_frameworks/mocha.rb +0 -0
- data/{plugins → lib/adapters}/mock_frameworks/rr.rb +0 -0
- data/{plugins → lib/adapters}/mock_frameworks/rspec.rb +1 -1
- data/lib/autotest/rspec.rb +3 -2
- data/lib/spec/dsl/main.rb +8 -4
- data/lib/spec/example/configuration.rb +1 -1
- data/lib/spec/example/example_group_factory.rb +6 -2
- data/lib/spec/example/example_group_methods.rb +47 -54
- data/lib/spec/example/shared_example_group.rb +2 -2
- data/lib/spec/example.rb +163 -14
- data/lib/spec/interop/test/unit/testresult.rb +1 -1
- data/lib/spec/interop/test/unit/testsuite_adapter.rb +1 -1
- data/lib/spec/matchers/match_array.rb +75 -0
- data/lib/spec/matchers/operator_matcher.rb +34 -7
- data/lib/spec/matchers.rb +2 -1
- data/lib/spec/mocks/argument_constraints.rb +43 -5
- data/lib/spec/runner/example_group_runner.rb +2 -2
- data/lib/spec/runner/option_parser.rb +12 -6
- data/lib/spec/runner/options.rb +9 -9
- data/lib/spec/runner/spec_parser.rb +3 -2
- data/lib/spec/runner.rb +54 -188
- data/lib/spec/version.rb +1 -1
- data/lib/spec.rb +0 -29
- data/{rake_tasks → resources/rake}/examples.rake +0 -0
- data/{rake_tasks → resources/rake}/examples_with_rcov.rake +0 -0
- data/{rake_tasks → resources/rake}/failing_examples_with_html.rake +0 -0
- data/{rake_tasks → resources/rake}/verify_rcov.rake +0 -0
- data/{stories/resources → resources}/spec/before_blocks_example.rb +1 -1
- data/{stories/resources → resources}/spec/example_group_with_should_methods.rb +1 -1
- data/{stories/resources → resources}/spec/simple_spec.rb +1 -1
- data/resources/spec/spec_with_flexmock.rb +19 -0
- data/{stories/resources → resources}/test/spec_and_test_together.rb +1 -1
- data/{stories/resources → resources}/test/spec_including_test_but_not_unit.rb +1 -1
- data/{stories/resources → resources}/test/test_case_with_should_methods.rb +2 -2
- data/rspec.gemspec +5 -4
- data/spec/autotest/rspec_spec.rb +2 -1
- data/spec/spec/dsl/main_spec.rb +8 -5
- data/spec/spec/example/configuration_spec.rb +9 -9
- data/spec/spec/example/example_group_factory_spec.rb +22 -3
- data/spec/spec/example/example_group_methods_spec.rb +19 -15
- data/spec/spec/example/example_group_spec.rb +41 -41
- data/spec/spec/example/example_methods_spec.rb +5 -5
- data/spec/spec/example/helper_method_spec.rb +24 -0
- data/spec/spec/example/pending_module_spec.rb +2 -8
- data/spec/spec/example/shared_example_group_spec.rb +5 -5
- data/spec/spec/matchers/description_generation_spec.rb +5 -0
- data/spec/spec/matchers/handler_spec.rb +7 -7
- data/spec/spec/matchers/match_array_spec.rb +83 -0
- data/spec/spec/matchers/raise_error_spec.rb +18 -0
- data/spec/spec/mocks/hash_including_matcher_spec.rb +39 -2
- data/spec/spec/mocks/hash_not_including_matcher_spec.rb +67 -0
- data/spec/spec/mocks/mock_spec.rb +5 -6
- data/spec/spec/mocks/nil_expectation_warning_spec.rb +1 -1
- data/spec/spec/runner/formatter/base_text_formatter_spec.rb +22 -0
- data/spec/spec/runner/option_parser_spec.rb +4 -17
- data/spec/spec/runner/options_spec.rb +19 -5
- data/spec/spec/runner/resources/custom_example_group_runner.rb +14 -0
- data/spec/spec/runner/spec_parser_spec.rb +10 -0
- data/spec/spec/spec_spec.rb +21 -0
- metadata +39 -49
- data/lib/spec/adapters/ruby_engine/mri.rb +0 -8
- data/lib/spec/adapters/ruby_engine/rubinius.rb +0 -8
- data/lib/spec/adapters/ruby_engine.rb +0 -26
- data/lib/spec/adapters.rb +0 -1
- data/lib/spec/extensions/class.rb +0 -24
- data/lib/spec/extensions.rb +0 -1
- data/spec/spec/adapters/ruby_engine_spec.rb +0 -16
- data/stories/all.rb +0 -5
- data/stories/configuration/stories.rb +0 -7
- data/stories/example_groups/stories.rb +0 -7
- data/stories/helper.rb +0 -6
- data/stories/interop/stories.rb +0 -7
- data/stories/mock_framework_integration/stories.rb +0 -7
- data/stories/pending_stories/README +0 -3
- data/stories/resources/spec/spec_with_flexmock.rb +0 -18
- data/stories/resources/steps/running_rspec.rb +0 -50
- data/stories/resources/stories/failing_story.rb +0 -15
- data/stories/stories/multiline_steps.story +0 -23
- data/stories/stories/steps/multiline_steps.rb +0 -13
- data/stories/stories/stories.rb +0 -6
@@ -4,14 +4,12 @@ module Spec
|
|
4
4
|
|
5
5
|
it 'should raise an ExamplePendingError if no block is supplied' do
|
6
6
|
lambda {
|
7
|
-
include Pending
|
8
7
|
pending "TODO"
|
9
8
|
}.should raise_error(ExamplePendingError, /TODO/)
|
10
9
|
end
|
11
10
|
|
12
11
|
it 'should raise an ExamplePendingError if a supplied block fails as expected' do
|
13
12
|
lambda {
|
14
|
-
include Pending
|
15
13
|
pending "TODO" do
|
16
14
|
raise "oops"
|
17
15
|
end
|
@@ -20,7 +18,6 @@ module Spec
|
|
20
18
|
|
21
19
|
it 'should raise an ExamplePendingError if a supplied block fails as expected with a mock' do
|
22
20
|
lambda {
|
23
|
-
include Pending
|
24
21
|
pending "TODO" do
|
25
22
|
m = mock('thing')
|
26
23
|
m.should_receive(:foo)
|
@@ -31,7 +28,6 @@ module Spec
|
|
31
28
|
|
32
29
|
it 'should raise a PendingExampleFixedError if a supplied block starts working' do
|
33
30
|
lambda {
|
34
|
-
include Pending
|
35
31
|
pending "TODO" do
|
36
32
|
# success!
|
37
33
|
end
|
@@ -40,9 +36,8 @@ module Spec
|
|
40
36
|
|
41
37
|
it "should have the correct file and line number for pending given with a block which fails" do
|
42
38
|
file = __FILE__
|
43
|
-
line_number = __LINE__ +
|
39
|
+
line_number = __LINE__ + 2
|
44
40
|
begin
|
45
|
-
include Pending
|
46
41
|
pending do
|
47
42
|
raise
|
48
43
|
end
|
@@ -53,9 +48,8 @@ module Spec
|
|
53
48
|
|
54
49
|
it "should have the correct file and line number for pending given with no block" do
|
55
50
|
file = __FILE__
|
56
|
-
line_number = __LINE__ +
|
51
|
+
line_number = __LINE__ + 2
|
57
52
|
begin
|
58
|
-
include Pending
|
59
53
|
pending("TODO")
|
60
54
|
rescue => error
|
61
55
|
error.pending_caller.should == "#{file}:#{line_number}"
|
@@ -151,7 +151,7 @@ module Spec
|
|
151
151
|
|
152
152
|
example_group.it_should_behave_like("shared example_group")
|
153
153
|
example_group.it("example") {example_ran = true}
|
154
|
-
example_group.run
|
154
|
+
example_group.run(options)
|
155
155
|
example_ran.should be_true
|
156
156
|
shared_example_ran.should be_true
|
157
157
|
end
|
@@ -169,7 +169,7 @@ module Spec
|
|
169
169
|
|
170
170
|
example_group.it_should_behave_like("shared example_group")
|
171
171
|
example_group.it("example") {example_ran = true}
|
172
|
-
example_group.run
|
172
|
+
example_group.run(options)
|
173
173
|
example_ran.should be_true
|
174
174
|
shared_setup_ran.should be_true
|
175
175
|
shared_teardown_ran.should be_true
|
@@ -188,7 +188,7 @@ module Spec
|
|
188
188
|
|
189
189
|
example_group.it_should_behave_like("shared example_group")
|
190
190
|
example_group.it("example") {example_ran = true}
|
191
|
-
example_group.run
|
191
|
+
example_group.run(options)
|
192
192
|
example_ran.should be_true
|
193
193
|
shared_before_all_run_count.should == 1
|
194
194
|
shared_after_all_run_count.should == 1
|
@@ -224,7 +224,7 @@ module Spec
|
|
224
224
|
mod1_method
|
225
225
|
mod2_method
|
226
226
|
end
|
227
|
-
example_group.run
|
227
|
+
example_group.run(options)
|
228
228
|
mod1_method_called.should be_true
|
229
229
|
mod2_method_called.should be_true
|
230
230
|
end
|
@@ -241,7 +241,7 @@ module Spec
|
|
241
241
|
a_shared_helper_method
|
242
242
|
success = true
|
243
243
|
end
|
244
|
-
example_group.run
|
244
|
+
example_group.run(options)
|
245
245
|
success.should be_true
|
246
246
|
end
|
247
247
|
|
@@ -107,6 +107,11 @@ describe "Matchers should be able to generate their own descriptions" do
|
|
107
107
|
[1,2,3].should include(3)
|
108
108
|
Spec::Matchers.generated_description.should == "should include 3"
|
109
109
|
end
|
110
|
+
|
111
|
+
it "array.should =~ [1,2,3]" do
|
112
|
+
[1,2,3].should =~ [1,2,3]
|
113
|
+
Spec::Matchers.generated_description.should == "should contain exactly 1, 2 and 3"
|
114
|
+
end
|
110
115
|
|
111
116
|
it "should match" do
|
112
117
|
"this string".should match(/this string/)
|
@@ -54,14 +54,14 @@ module Spec
|
|
54
54
|
matcher = mock("matcher")
|
55
55
|
actual = Object.new
|
56
56
|
matcher.should_receive(:matches?).with(actual).and_return(true)
|
57
|
-
ExpectationMatcherHandler.handle_matcher(actual, matcher)
|
57
|
+
Spec::Expectations::ExpectationMatcherHandler.handle_matcher(actual, matcher)
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should explain when the matcher parameter is not a matcher" do
|
61
61
|
begin
|
62
62
|
nonmatcher = mock("nonmatcher")
|
63
63
|
actual = Object.new
|
64
|
-
ExpectationMatcherHandler.handle_matcher(actual, nonmatcher)
|
64
|
+
Spec::Expectations::ExpectationMatcherHandler.handle_matcher(actual, nonmatcher)
|
65
65
|
rescue Spec::Expectations::InvalidMatcherError => e
|
66
66
|
end
|
67
67
|
|
@@ -72,7 +72,7 @@ module Spec
|
|
72
72
|
matcher = mock("matcher")
|
73
73
|
actual = Object.new
|
74
74
|
matcher.should_receive(:matches?).with(actual).and_return(:this_value)
|
75
|
-
ExpectationMatcherHandler.handle_matcher(actual, matcher).should == :this_value
|
75
|
+
Spec::Expectations::ExpectationMatcherHandler.handle_matcher(actual, matcher).should == :this_value
|
76
76
|
end
|
77
77
|
end
|
78
78
|
end
|
@@ -84,7 +84,7 @@ module Spec
|
|
84
84
|
matcher.stub!(:matches?)
|
85
85
|
actual = Object.new
|
86
86
|
lambda {
|
87
|
-
NegativeExpectationMatcherHandler.handle_matcher(actual, matcher)
|
87
|
+
Spec::Expectations::NegativeExpectationMatcherHandler.handle_matcher(actual, matcher)
|
88
88
|
}.should fail_with(/Matcher does not support should_not.\n/)
|
89
89
|
end
|
90
90
|
|
@@ -93,14 +93,14 @@ module Spec
|
|
93
93
|
actual = Object.new
|
94
94
|
matcher.stub!(:negative_failure_message)
|
95
95
|
matcher.should_receive(:matches?).with(actual).and_return(false)
|
96
|
-
NegativeExpectationMatcherHandler.handle_matcher(actual, matcher)
|
96
|
+
Spec::Expectations::NegativeExpectationMatcherHandler.handle_matcher(actual, matcher)
|
97
97
|
end
|
98
98
|
|
99
99
|
it "should explain when the matcher parameter is not a matcher" do
|
100
100
|
begin
|
101
101
|
nonmatcher = mock("nonmatcher")
|
102
102
|
actual = Object.new
|
103
|
-
NegativeExpectationMatcherHandler.handle_matcher(actual, nonmatcher)
|
103
|
+
Spec::Expectations::NegativeExpectationMatcherHandler.handle_matcher(actual, nonmatcher)
|
104
104
|
rescue Spec::Expectations::InvalidMatcherError => e
|
105
105
|
end
|
106
106
|
|
@@ -113,7 +113,7 @@ module Spec
|
|
113
113
|
actual = Object.new
|
114
114
|
matcher.should_receive(:matches?).with(actual).and_return(false)
|
115
115
|
matcher.stub!(:negative_failure_message).and_return("ignore")
|
116
|
-
NegativeExpectationMatcherHandler.handle_matcher(actual, matcher).should be_false
|
116
|
+
Spec::Expectations::NegativeExpectationMatcherHandler.handle_matcher(actual, matcher).should be_false
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
describe "array.should =~ other_array" do
|
4
|
+
it "should pass if target contains all items" do
|
5
|
+
[1,2,3].should =~ [1,2,3]
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should pass if target contains all items out of order" do
|
9
|
+
[1,3,2].should =~ [1,2,3]
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should fail if target includes extra items" do
|
13
|
+
lambda {
|
14
|
+
[1,2,3,4].should =~ [1,2,3]
|
15
|
+
}.should fail_with(<<-MESSAGE)
|
16
|
+
expected collection contained: [1, 2, 3]
|
17
|
+
actual collection contained: [1, 2, 3, 4]
|
18
|
+
the extra elements were: [4]
|
19
|
+
MESSAGE
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should fail if target is missing items" do
|
23
|
+
lambda {
|
24
|
+
[1,2].should =~ [1,2,3]
|
25
|
+
}.should fail_with(<<-MESSAGE)
|
26
|
+
expected collection contained: [1, 2, 3]
|
27
|
+
actual collection contained: [1, 2]
|
28
|
+
the missing elements were: [3]
|
29
|
+
MESSAGE
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should fail if target is missing items and has extra items" do
|
33
|
+
|
34
|
+
lambda {
|
35
|
+
[1,2,4].should =~ [1,2,3]
|
36
|
+
}.should fail_with(<<-MESSAGE)
|
37
|
+
expected collection contained: [1, 2, 3]
|
38
|
+
actual collection contained: [1, 2, 4]
|
39
|
+
the missing elements were: [3]
|
40
|
+
the extra elements were: [4]
|
41
|
+
MESSAGE
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should sort items in the error message" do
|
45
|
+
lambda {
|
46
|
+
[6,2,1,5].should =~ [4,1,2,3]
|
47
|
+
}.should fail_with(<<-MESSAGE)
|
48
|
+
expected collection contained: [1, 2, 3, 4]
|
49
|
+
actual collection contained: [1, 2, 5, 6]
|
50
|
+
the missing elements were: [3, 4]
|
51
|
+
the extra elements were: [5, 6]
|
52
|
+
MESSAGE
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should accurately report extra elements when there are duplicates" do
|
56
|
+
lambda {
|
57
|
+
[1,1,1,5].should =~ [1,5]
|
58
|
+
}.should fail_with(<<-MESSAGE)
|
59
|
+
expected collection contained: [1, 5]
|
60
|
+
actual collection contained: [1, 1, 1, 5]
|
61
|
+
the extra elements were: [1, 1]
|
62
|
+
MESSAGE
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should accurately report missing elements when there are duplicates" do
|
66
|
+
lambda {
|
67
|
+
[1,5].should =~ [1,1,5]
|
68
|
+
}.should fail_with(<<-MESSAGE)
|
69
|
+
expected collection contained: [1, 1, 5]
|
70
|
+
actual collection contained: [1, 5]
|
71
|
+
the missing elements were: [1]
|
72
|
+
MESSAGE
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "should_not =~ [:with, :multiple, :args]" do
|
78
|
+
it "should not be supported" do
|
79
|
+
lambda {
|
80
|
+
[1,2,3].should_not =~ [1,2,3]
|
81
|
+
}.should fail_with(/Matcher does not support should_not/)
|
82
|
+
end
|
83
|
+
end
|
@@ -12,6 +12,24 @@ describe "should raise_error" do
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
describe "should raise_error {|err| ... }" do
|
16
|
+
it "passes if there is an error" do
|
17
|
+
ran = false
|
18
|
+
lambda { non_existent_method }.should raise_error {|e|
|
19
|
+
ran = true
|
20
|
+
}
|
21
|
+
ran.should be_true
|
22
|
+
end
|
23
|
+
|
24
|
+
it "passes the error to the block" do
|
25
|
+
error = nil
|
26
|
+
lambda { non_existent_method }.should raise_error {|e|
|
27
|
+
error = e
|
28
|
+
}
|
29
|
+
error.should be_an_instance_of(NameError)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
15
33
|
describe "should_not raise_error" do
|
16
34
|
it "should pass if nothing is raised" do
|
17
35
|
lambda {}.should_not raise_error
|
@@ -27,6 +27,32 @@ module Spec
|
|
27
27
|
hash_including(:a => anything, :b => 2).should == {:a => "1", :b => 2}
|
28
28
|
end
|
29
29
|
end
|
30
|
+
|
31
|
+
describe "when passed only keys or keys mixed with key/value pairs" do
|
32
|
+
it "should match if the key is present" do
|
33
|
+
hash_including(:a).should == {:a => 1, :b => 2}
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should match if more keys are present" do
|
37
|
+
hash_including(:a, :b).should == {:a => 1, :b => 2, :c => 3}
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should match a string against a given key" do
|
41
|
+
hash_including(:a).should == {:a => "1", :b => 2}
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should match if passed one key and one key/value pair" do
|
45
|
+
hash_including(:a, :b => 2).should == {:a => 1, :b => 2}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should match if passed many keys and one key/value pair" do
|
49
|
+
hash_including(:a, :b, :c => 3).should == {:a => 1, :b => 2, :c => 3, :d => 4}
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should match if passed many keys and many key/value pairs" do
|
53
|
+
hash_including(:a, :b, :c => 3, :e => 5).should == {:a => 1, :b => 2, :c => 3, :d => 4, :e => 5}
|
54
|
+
end
|
55
|
+
end
|
30
56
|
end
|
31
57
|
|
32
58
|
describe "failing" do
|
@@ -34,11 +60,22 @@ module Spec
|
|
34
60
|
hash_including(:a => 1).should_not == 1
|
35
61
|
end
|
36
62
|
|
37
|
-
|
38
63
|
it "should not match a hash with a missing key" do
|
39
64
|
hash_including(:a => 1).should_not == {:b => 2}
|
40
65
|
end
|
41
|
-
|
66
|
+
|
67
|
+
it "should not match a hash with a missing key" do
|
68
|
+
hash_including(:a).should_not == {:b => 2}
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should not match an empty hash with a given key" do
|
72
|
+
hash_including(:a).should_not == {}
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should not match a hash with a missing key when one pair is matching" do
|
76
|
+
hash_including(:a, :b => 2).should_not == {:b => 2}
|
77
|
+
end
|
78
|
+
|
42
79
|
it "should not match a hash with an incorrect value" do
|
43
80
|
hash_including(:a => 1, :b => 2).should_not == {:a => 1, :b => 3}
|
44
81
|
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Mocks
|
5
|
+
module ArgumentConstraints
|
6
|
+
describe HashNotIncludingConstraint do
|
7
|
+
|
8
|
+
it "should describe itself properly" do
|
9
|
+
HashNotIncludingConstraint.new(:a => 5).description.should == "hash_not_including(:a=>5)"
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "passing" do
|
13
|
+
it "should match a hash without the specified key" do
|
14
|
+
hash_not_including(:c).should == {:a => 1, :b => 2}
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should match a hash with the specified key, but different value" do
|
18
|
+
hash_not_including(:b => 3).should == {:a => 1, :b => 2}
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should match a hash without the specified key, given as anything()" do
|
22
|
+
hash_not_including(:c => anything).should == {:a => 1, :b => 2}
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should match an empty hash" do
|
26
|
+
hash_not_including(:a).should == {}
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should match a hash without any of the specified keys" do
|
30
|
+
hash_not_including(:a, :b, :c).should == { :d => 7}
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "failing" do
|
36
|
+
it "should not match a non-hash" do
|
37
|
+
hash_not_including(:a => 1).should_not == 1
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should not match a hash with a specified key" do
|
41
|
+
hash_not_including(:b).should_not == {:b => 2}
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should not match a hash with the specified key/value pair" do
|
45
|
+
hash_not_including(:b => 2).should_not == {:a => 1, :b => 2}
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should not match a hash with the specified key" do
|
49
|
+
hash_not_including(:a, :b => 3).should_not == {:a => 1, :b => 2}
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should not match a hash with one of the specified keys" do
|
53
|
+
hash_not_including(:a, :b).should_not == {:b => 2}
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should not match a hash with some of the specified keys" do
|
57
|
+
hash_not_including(:a, :b, :c).should_not == {:a => 1, :b => 2}
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should not match a hash with one key/value pair included" do
|
61
|
+
hash_not_including(:a, :b, :c, :d => 7).should_not == { :d => 7}
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -3,7 +3,6 @@ require File.dirname(__FILE__) + '/../../spec_helper'
|
|
3
3
|
module Spec
|
4
4
|
module Mocks
|
5
5
|
describe Mock do
|
6
|
-
|
7
6
|
before(:each) do
|
8
7
|
@mock = mock("test mock")
|
9
8
|
end
|
@@ -227,7 +226,7 @@ module Spec
|
|
227
226
|
it "should yield 0 args to blocks that take a variable number of arguments" do
|
228
227
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield
|
229
228
|
a = nil
|
230
|
-
@mock.yield_back {|*a
|
229
|
+
@mock.yield_back {|*x| a = x}
|
231
230
|
a.should == []
|
232
231
|
@mock.rspec_verify
|
233
232
|
end
|
@@ -245,7 +244,7 @@ module Spec
|
|
245
244
|
it "should yield one arg to blocks that take a variable number of arguments" do
|
246
245
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield(99)
|
247
246
|
a = nil
|
248
|
-
@mock.yield_back {|*a
|
247
|
+
@mock.yield_back {|*x| a = x}
|
249
248
|
a.should == [99]
|
250
249
|
@mock.rspec_verify
|
251
250
|
end
|
@@ -264,7 +263,7 @@ module Spec
|
|
264
263
|
it "should yield many args to blocks that take a variable number of arguments" do
|
265
264
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield(99, 27, "go")
|
266
265
|
a = nil
|
267
|
-
@mock.yield_back {|*a
|
266
|
+
@mock.yield_back {|*x| a = x}
|
268
267
|
a.should == [99, 27, "go"]
|
269
268
|
@mock.rspec_verify
|
270
269
|
end
|
@@ -283,7 +282,7 @@ module Spec
|
|
283
282
|
it "should yield single value" do
|
284
283
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield(99)
|
285
284
|
a = nil
|
286
|
-
@mock.yield_back {|a
|
285
|
+
@mock.yield_back {|x| a = x}
|
287
286
|
a.should == 99
|
288
287
|
@mock.rspec_verify
|
289
288
|
end
|
@@ -302,7 +301,7 @@ module Spec
|
|
302
301
|
it "should yield two values" do
|
303
302
|
@mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup')
|
304
303
|
a, b = nil
|
305
|
-
@mock.yield_back {|a
|
304
|
+
@mock.yield_back {|x,y| a=x; b=y}
|
306
305
|
a.should == 'wha'
|
307
306
|
b.should == 'zup'
|
308
307
|
@mock.rspec_verify
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../../spec_helper'
|
2
|
+
require 'spec/runner/formatter/base_text_formatter'
|
3
|
+
|
4
|
+
module Spec
|
5
|
+
module Runner
|
6
|
+
module Formatter
|
7
|
+
describe BaseTextFormatter do
|
8
|
+
|
9
|
+
before :all do
|
10
|
+
@sandbox = "spec/sandbox"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should create the directory contained in WHERE if it does not exist" do
|
14
|
+
FileUtils.should_receive(:mkdir_p).with(@sandbox)
|
15
|
+
File.stub!(:open)
|
16
|
+
BaseTextFormatter.new({},"#{@sandbox}/temp.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,20 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
-
require '
|
3
|
-
|
4
|
-
module Custom
|
5
|
-
class ExampleGroupRunner
|
6
|
-
attr_reader :options, :arg
|
7
|
-
def initialize(options, arg)
|
8
|
-
@options, @arg = options, arg
|
9
|
-
end
|
10
|
-
|
11
|
-
def load_files(files)
|
12
|
-
end
|
2
|
+
require File.dirname(__FILE__) + '/resources/custom_example_group_runner'
|
13
3
|
|
14
|
-
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
4
|
+
require 'fileutils'
|
18
5
|
|
19
6
|
describe "OptionParser" do
|
20
7
|
before(:each) do
|
@@ -73,14 +60,14 @@ describe "OptionParser" do
|
|
73
60
|
end
|
74
61
|
|
75
62
|
it "should print help to stdout if no args and spec_comand?" do
|
76
|
-
Spec.stub!(:spec_command?).and_return(true)
|
63
|
+
Spec::Runner::OptionParser.stub!(:spec_command?).and_return(true)
|
77
64
|
options = parse([])
|
78
65
|
@out.rewind
|
79
66
|
@out.read.should match(/Usage: spec \(FILE\|DIRECTORY\|GLOB\)\+ \[options\]/m)
|
80
67
|
end
|
81
68
|
|
82
69
|
it "should not print help to stdout if no args and NOT spec_command?" do
|
83
|
-
Spec.stub!(:spec_command?).and_return(false)
|
70
|
+
Spec::Runner::OptionParser.stub!(:spec_command?).and_return(false)
|
84
71
|
options = parse([])
|
85
72
|
@out.rewind
|
86
73
|
@out.read.should == ""
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/resources/custom_example_group_runner'
|
2
3
|
|
3
4
|
module Spec
|
4
5
|
module Runner
|
@@ -223,9 +224,24 @@ module Spec
|
|
223
224
|
@options.reporter.options.should === @options
|
224
225
|
end
|
225
226
|
end
|
227
|
+
|
228
|
+
describe "#number_of_examples" do
|
229
|
+
context "when --example is parsed" do
|
230
|
+
it "provides the number of examples parsed instead of the total number of examples collected" do
|
231
|
+
@example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
|
232
|
+
it "uses this example_group 1" do; end
|
233
|
+
it "uses this example_group 2" do; end
|
234
|
+
it "uses this example_group 3" do; end
|
235
|
+
end
|
236
|
+
@options.add_example_group @example_group
|
237
|
+
@options.parse_example("an example")
|
238
|
+
@options.number_of_examples.should == 1
|
239
|
+
end
|
240
|
+
end
|
241
|
+
end
|
226
242
|
|
227
243
|
describe "#add_example_group affecting passed in example_group" do
|
228
|
-
it "runs all examples when options.examples is
|
244
|
+
it "runs all examples when options.examples is empty" do
|
229
245
|
example_1_has_run = false
|
230
246
|
example_2_has_run = false
|
231
247
|
@example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do
|
@@ -237,7 +253,7 @@ module Spec
|
|
237
253
|
end
|
238
254
|
end
|
239
255
|
|
240
|
-
@options.examples
|
256
|
+
@options.examples.clear
|
241
257
|
|
242
258
|
@options.add_example_group @example_group
|
243
259
|
@options.run_examples
|
@@ -257,8 +273,6 @@ module Spec
|
|
257
273
|
end
|
258
274
|
end
|
259
275
|
|
260
|
-
@options.examples = []
|
261
|
-
|
262
276
|
@options.add_example_group @example_group
|
263
277
|
@options.run_examples
|
264
278
|
example_1_has_run.should be_true
|
@@ -77,5 +77,15 @@ describe "SpecParser" do
|
|
77
77
|
it "should find nested example" do
|
78
78
|
parser.spec_name_for(file, 63).should == "e f 11"
|
79
79
|
end
|
80
|
+
|
81
|
+
it "should handle paths which contain colons" do
|
82
|
+
fixture =
|
83
|
+
{ "c:/somepath/somefile.rb:999:in 'method'" => "c:/somepath/somefile.rb",
|
84
|
+
"./somepath/somefile:999" => "./somepath/somefile" }
|
85
|
+
fixture.each_pair do |input, expected|
|
86
|
+
parser.send(:parse_backtrace, input ).should == [[expected, 999]]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
80
90
|
end
|
81
91
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper.rb'
|
2
|
+
|
3
|
+
describe Spec::Runner, "#exit?" do
|
4
|
+
describe "when ::Test is absent during loading but present when running exit?" do
|
5
|
+
# believe it or not, this can happen when ActiveSupport is loaded after RSpec is,
|
6
|
+
# since it loads active_support/core_ext/test/unit/assertions.rb which defines
|
7
|
+
# Test::Unit but doesn't actually load test/unit
|
8
|
+
|
9
|
+
before(:each) do
|
10
|
+
Object.const_set(:Test, Module.new)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "does not attempt to access the non-loaded test/unit library" do
|
14
|
+
lambda { Spec::Runner.exit? }.should_not raise_error
|
15
|
+
end
|
16
|
+
|
17
|
+
after(:each) do
|
18
|
+
Object.send(:remove_const, :Test)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|