dchelimsky-rspec 1.1.11 → 1.1.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +4 -0
- data/History.txt +19 -3
- data/Manifest.txt +6 -1
- data/examples/failing/README.txt +7 -0
- data/examples/failing/diffing_spec.rb +36 -0
- data/examples/failing/failing_autogenerated_docstrings_example.rb +19 -0
- data/examples/failing/failure_in_setup.rb +10 -0
- data/examples/failing/failure_in_teardown.rb +10 -0
- data/examples/failing/mocking_example.rb +40 -0
- data/examples/failing/mocking_with_flexmock.rb +26 -0
- data/examples/failing/mocking_with_mocha.rb +25 -0
- data/examples/failing/mocking_with_rr.rb +27 -0
- data/examples/failing/partial_mock_example.rb +20 -0
- data/examples/failing/predicate_example.rb +34 -0
- data/examples/failing/raising_example.rb +47 -0
- data/examples/failing/spec_helper.rb +3 -0
- data/examples/failing/syntax_error_example.rb +7 -0
- data/examples/failing/team_spec.rb +44 -0
- data/examples/failing/timeout_behaviour.rb +7 -0
- data/examples/passing/custom_formatter.rb +1 -1
- data/examples/passing/simple_matcher_example.rb +31 -0
- data/lib/autotest/rspec.rb +1 -1
- data/lib/spec/dsl/main.rb +82 -0
- data/lib/spec/dsl.rb +1 -0
- data/lib/spec/example/before_and_after_hooks.rb +2 -1
- data/lib/spec/example/configuration.rb +1 -1
- data/lib/spec/example/example_group.rb +1 -0
- data/lib/spec/example/example_group_factory.rb +2 -1
- data/lib/spec/example/example_group_methods.rb +40 -25
- data/lib/spec/example/example_methods.rb +19 -8
- data/lib/spec/example.rb +15 -17
- data/lib/spec/expectations/handler.rb +23 -28
- data/lib/spec/expectations/wrap_expectation.rb +56 -0
- data/lib/spec/expectations.rb +22 -18
- data/lib/spec/extensions.rb +0 -1
- data/lib/spec/interop/test/unit/testcase.rb +19 -17
- data/lib/spec/matchers/be_close.rb +6 -22
- data/lib/spec/matchers/eql.rb +7 -25
- data/lib/spec/matchers/equal.rb +6 -24
- data/lib/spec/matchers/errors.rb +5 -0
- data/lib/spec/matchers/exist.rb +8 -14
- data/lib/spec/matchers/generated_descriptions.rb +48 -0
- data/lib/spec/matchers/has.rb +12 -28
- data/lib/spec/matchers/include.rb +12 -9
- data/lib/spec/matchers/match.rb +8 -27
- data/lib/spec/matchers/method_missing.rb +9 -0
- data/lib/spec/matchers/operator_matcher.rb +23 -46
- data/lib/spec/matchers/raise_error.rb +4 -8
- data/lib/spec/matchers/respond_to.rb +2 -1
- data/lib/spec/matchers/throw_symbol.rb +9 -3
- data/lib/spec/mocks/message_expectation.rb +0 -5
- data/lib/spec/mocks/proxy.rb +12 -10
- data/lib/spec/rake/spectask.rb +4 -6
- data/lib/spec/runner/class_and_arguments_parser.rb +7 -9
- data/lib/spec/runner/command_line.rb +6 -8
- data/lib/spec/runner/formatter/base_text_formatter.rb +3 -2
- data/lib/spec/runner/option_parser.rb +4 -6
- data/lib/spec/runner/spec_parser.rb +5 -5
- data/lib/spec/runner.rb +37 -39
- data/lib/spec/story/runner/story_runner.rb +10 -6
- data/lib/spec/story/runner.rb +40 -42
- data/lib/spec/story/world.rb +66 -70
- data/lib/spec/version.rb +3 -1
- data/lib/spec.rb +21 -19
- data/rspec.gemspec +15 -6
- data/spec/autotest/autotest_helper.rb +2 -2
- data/spec/autotest/discover_spec.rb +4 -15
- data/spec/autotest/failed_results_re_spec.rb +24 -0
- data/spec/autotest/rspec_spec.rb +0 -37
- data/spec/spec/dsl/main_spec.rb +65 -0
- data/spec/spec/example/example_group_class_definition_spec.rb +6 -2
- data/spec/spec/example/example_group_factory_spec.rb +2 -1
- data/spec/spec/example/example_group_methods_spec.rb +138 -141
- data/spec/spec/example/example_group_spec.rb +3 -5
- data/spec/spec/example/example_methods_spec.rb +60 -23
- data/spec/spec/expectations/wrap_expectation_spec.rb +30 -0
- data/spec/spec/interop/test/unit/spec_spec.rb +1 -5
- data/spec/spec/interop/test/unit/test_unit_spec_helper.rb +4 -0
- data/spec/spec/matchers/be_close_spec.rb +12 -10
- data/spec/spec/matchers/description_generation_spec.rb +1 -1
- data/spec/spec/matchers/eql_spec.rb +7 -6
- data/spec/spec/matchers/equal_spec.rb +7 -6
- data/spec/spec/matchers/has_spec.rb +1 -1
- data/spec/spec/matchers/have_spec.rb +23 -18
- data/spec/spec/matchers/include_spec.rb +24 -0
- data/spec/spec/matchers/matcher_methods_spec.rb +1 -13
- data/spec/spec/matchers/throw_symbol_spec.rb +3 -3
- data/spec/spec/mocks/bug_report_11545_spec.rb +4 -5
- data/spec/spec/mocks/bug_report_496.rb +11 -9
- data/spec/spec/mocks/bug_report_600_spec.rb +22 -0
- data/spec/spec/runner/formatter/nested_text_formatter_spec.rb +1 -1
- data/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +4 -14
- data/spec/spec/runner/formatter/specdoc_formatter_spec.rb +1 -1
- data/spec/spec/runner/options_spec.rb +1 -1
- data/spec/spec/runner/spec_parser_spec.rb +76 -80
- data/spec/spec_helper.rb +4 -0
- data/stories/example_groups/autogenerated_docstrings +4 -4
- data/stories/interop/test_but_not_test_unit +14 -0
- data/stories/resources/helpers/story_helper.rb +1 -1
- data/stories/resources/test/spec_including_test_but_not_unit.rb +11 -0
- data/story_server/prototype/javascripts/prototype.js +1 -1
- metadata +34 -53
- data/lib/spec/extensions/metaclass.rb +0 -7
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module Spec
|
4
|
+
module Matchers
|
5
|
+
describe "wrap_expectation" do
|
6
|
+
|
7
|
+
def stub_matcher
|
8
|
+
@_stub_matcher ||= simple_matcher do
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def failing_matcher
|
13
|
+
@_failing_matcher ||= simple_matcher do
|
14
|
+
1.should == 2
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return true if there is no error" do
|
19
|
+
wrap_expectation stub_matcher do
|
20
|
+
end.should be_true
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should return false if there is an error" do
|
24
|
+
wrap_expectation failing_matcher do
|
25
|
+
raise "error"
|
26
|
+
end.should be_false
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -2,11 +2,7 @@ require File.dirname(__FILE__) + '/test_unit_spec_helper'
|
|
2
2
|
|
3
3
|
describe "ExampleGroup with test/unit/interop" do
|
4
4
|
include TestUnitSpecHelper
|
5
|
-
|
6
|
-
def resources
|
7
|
-
File.dirname(__FILE__) + "/resources"
|
8
|
-
end
|
9
|
-
|
5
|
+
|
10
6
|
describe "with passing examples" do
|
11
7
|
it "should output 0 failures" do
|
12
8
|
output = ruby("#{resources}/spec_that_passes.rb")
|
@@ -1,38 +1,40 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
module Spec
|
3
3
|
module Matchers
|
4
|
-
describe
|
4
|
+
describe "be_close" do
|
5
5
|
it "should match when value == target" do
|
6
|
-
|
6
|
+
be_close(5.0, 0.5).matches?(5.0).should be_true
|
7
7
|
end
|
8
8
|
it "should match when value < (target + delta)" do
|
9
|
-
|
9
|
+
be_close(5.0, 0.5).matches?(5.49).should be_true
|
10
10
|
end
|
11
11
|
it "should match when value > (target - delta)" do
|
12
|
-
|
12
|
+
be_close(5.0, 0.5).matches?(4.51).should be_true
|
13
13
|
end
|
14
14
|
it "should not match when value == (target - delta)" do
|
15
|
-
|
15
|
+
be_close(5.0, 0.5).matches?(4.5).should be_false
|
16
16
|
end
|
17
17
|
it "should not match when value < (target - delta)" do
|
18
|
-
|
18
|
+
be_close(5.0, 0.5).matches?(4.49).should be_false
|
19
19
|
end
|
20
20
|
it "should not match when value == (target + delta)" do
|
21
|
-
|
21
|
+
be_close(5.0, 0.5).matches?(5.5).should be_false
|
22
22
|
end
|
23
23
|
it "should not match when value > (target + delta)" do
|
24
|
-
|
24
|
+
be_close(5.0, 0.5).matches?(5.51).should be_false
|
25
25
|
end
|
26
26
|
it "should provide a useful failure message" do
|
27
27
|
#given
|
28
|
-
matcher =
|
28
|
+
matcher = be_close(5.0, 0.5)
|
29
29
|
#when
|
30
30
|
matcher.matches?(5.51)
|
31
31
|
#then
|
32
32
|
matcher.failure_message.should == "expected 5.0 +/- (< 0.5), got 5.51"
|
33
33
|
end
|
34
34
|
it "should describe itself" do
|
35
|
-
|
35
|
+
matcher = be_close(5.0, 0.5)
|
36
|
+
matcher.matches?(5.1)
|
37
|
+
matcher.description.should == "be close to 5.0 (within +- 0.5)"
|
36
38
|
end
|
37
39
|
end
|
38
40
|
end
|
@@ -130,7 +130,7 @@ describe "Matchers should be able to generate their own descriptions" do
|
|
130
130
|
|
131
131
|
it "should respond_to" do
|
132
132
|
[].should respond_to(:insert)
|
133
|
-
Spec::Matchers.generated_description.should == "should respond to
|
133
|
+
Spec::Matchers.generated_description.should == "should respond to [:insert]"
|
134
134
|
end
|
135
135
|
|
136
136
|
it "should throw symbol" do
|
@@ -2,24 +2,25 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Matchers
|
5
|
-
describe
|
5
|
+
describe "eql" do
|
6
6
|
it "should match when actual.eql?(expected)" do
|
7
|
-
|
7
|
+
eql(1).matches?(1).should be_true
|
8
8
|
end
|
9
9
|
it "should not match when !actual.eql?(expected)" do
|
10
|
-
|
10
|
+
eql(1).matches?(2).should be_false
|
11
11
|
end
|
12
12
|
it "should describe itself" do
|
13
|
-
matcher =
|
13
|
+
matcher = eql(1)
|
14
|
+
matcher.matches?(1)
|
14
15
|
matcher.description.should == "eql 1"
|
15
16
|
end
|
16
17
|
it "should provide message, expected and actual on #failure_message" do
|
17
|
-
matcher =
|
18
|
+
matcher = eql("1")
|
18
19
|
matcher.matches?(1)
|
19
20
|
matcher.failure_message.should == ["expected \"1\", got 1 (using .eql?)", "1", 1]
|
20
21
|
end
|
21
22
|
it "should provide message, expected and actual on #negative_failure_message" do
|
22
|
-
matcher =
|
23
|
+
matcher = eql(1)
|
23
24
|
matcher.matches?(1)
|
24
25
|
matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .eql?)", 1, 1]
|
25
26
|
end
|
@@ -2,24 +2,25 @@ require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
|
2
2
|
|
3
3
|
module Spec
|
4
4
|
module Matchers
|
5
|
-
describe
|
5
|
+
describe "equal" do
|
6
6
|
it "should match when actual.equal?(expected)" do
|
7
|
-
|
7
|
+
equal(1).matches?(1).should be_true
|
8
8
|
end
|
9
9
|
it "should not match when !actual.equal?(expected)" do
|
10
|
-
|
10
|
+
equal("1").matches?("1").should be_false
|
11
11
|
end
|
12
12
|
it "should describe itself" do
|
13
|
-
matcher =
|
13
|
+
matcher = equal(1)
|
14
|
+
matcher.matches?(1)
|
14
15
|
matcher.description.should == "equal 1"
|
15
16
|
end
|
16
17
|
it "should provide message, expected and actual on #failure_message" do
|
17
|
-
matcher =
|
18
|
+
matcher = equal("1")
|
18
19
|
matcher.matches?(1)
|
19
20
|
matcher.failure_message.should == ["expected \"1\", got 1 (using .equal?)", "1", 1]
|
20
21
|
end
|
21
22
|
it "should provide message, expected and actual on #negative_failure_message" do
|
22
|
-
matcher =
|
23
|
+
matcher = equal(1)
|
23
24
|
matcher.matches?(1)
|
24
25
|
matcher.negative_failure_message.should == ["expected 1 not to equal 1 (using .equal?)", 1, 1]
|
25
26
|
end
|
@@ -52,7 +52,7 @@ describe "should_not have_sym(*args)" do
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
describe
|
55
|
+
describe "has" do
|
56
56
|
it "should work when the target implements #send" do
|
57
57
|
o = {:a => "A"}
|
58
58
|
def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
|
3
|
-
|
3
|
+
share_as :HaveSpecHelper do
|
4
4
|
def create_collection_owner_with(n)
|
5
5
|
owner = Spec::Expectations::Helper::CollectionOwner.new
|
6
6
|
(1..n).each do |n|
|
@@ -9,8 +9,21 @@ module HaveSpecHelper
|
|
9
9
|
end
|
10
10
|
owner
|
11
11
|
end
|
12
|
+
before(:each) do
|
13
|
+
unless defined?(ActiveSupport::Inflector)
|
14
|
+
@active_support_was_not_defined
|
15
|
+
module ActiveSupport
|
16
|
+
class Inflector
|
17
|
+
def self.pluralize(string)
|
18
|
+
string.to_s + 's'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
12
24
|
end
|
13
25
|
|
26
|
+
|
14
27
|
describe "should have(n).items" do
|
15
28
|
include HaveSpecHelper
|
16
29
|
|
@@ -50,19 +63,6 @@ end
|
|
50
63
|
describe 'should have(1).item when ActiveSupport::Inflector is defined' do
|
51
64
|
include HaveSpecHelper
|
52
65
|
|
53
|
-
before(:each) do
|
54
|
-
unless defined?(ActiveSupport::Inflector)
|
55
|
-
@active_support_was_not_defined
|
56
|
-
module ActiveSupport
|
57
|
-
class Inflector
|
58
|
-
def self.pluralize(string)
|
59
|
-
string.to_s + 's'
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
66
|
it 'should pluralize the collection name' do
|
67
67
|
owner = create_collection_owner_with(1)
|
68
68
|
owner.should have(1).item
|
@@ -70,7 +70,7 @@ describe 'should have(1).item when ActiveSupport::Inflector is defined' do
|
|
70
70
|
|
71
71
|
after(:each) do
|
72
72
|
if @active_support_was_not_defined
|
73
|
-
Object.
|
73
|
+
Object.__send__ :remove_const, :ActiveSupport
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -96,7 +96,7 @@ describe 'should have(1).item when Inflector is defined' do
|
|
96
96
|
|
97
97
|
after(:each) do
|
98
98
|
if @inflector_was_not_defined
|
99
|
-
Object.
|
99
|
+
Object.__send__ :remove_const, :Inflector
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
@@ -327,7 +327,7 @@ end
|
|
327
327
|
|
328
328
|
describe Spec::Matchers::Have, "for a collection owner that implements #send" do
|
329
329
|
include HaveSpecHelper
|
330
|
-
|
330
|
+
|
331
331
|
before(:each) do
|
332
332
|
@collection = Object.new
|
333
333
|
def @collection.floozles; [1,2] end
|
@@ -357,7 +357,12 @@ module Spec
|
|
357
357
|
module Matchers
|
358
358
|
describe Have do
|
359
359
|
it "should have method_missing as private" do
|
360
|
-
|
360
|
+
with_ruby '1.8' do
|
361
|
+
Have.private_instance_methods.should include("method_missing")
|
362
|
+
end
|
363
|
+
with_ruby '1.9' do
|
364
|
+
Have.private_instance_methods.should include(:method_missing)
|
365
|
+
end
|
361
366
|
end
|
362
367
|
|
363
368
|
describe "respond_to?" do
|
@@ -5,6 +5,10 @@ describe "should include(expected)" do
|
|
5
5
|
[1,2,3].should include(3)
|
6
6
|
"abc".should include("a")
|
7
7
|
end
|
8
|
+
|
9
|
+
it 'should pass if target is a Hash and has the expected as a key' do
|
10
|
+
{:key => 'value'}.should include(:key)
|
11
|
+
end
|
8
12
|
|
9
13
|
it "should fail if target does not include expected" do
|
10
14
|
lambda {
|
@@ -13,6 +17,9 @@ describe "should include(expected)" do
|
|
13
17
|
lambda {
|
14
18
|
"abc".should include("d")
|
15
19
|
}.should fail_with("expected \"abc\" to include \"d\"")
|
20
|
+
lambda {
|
21
|
+
{:key => 'value'}.should include(:other)
|
22
|
+
}.should fail_with(%Q|expected {:key=>"value"} to include :other|)
|
16
23
|
end
|
17
24
|
end
|
18
25
|
|
@@ -20,12 +27,22 @@ describe "should include(with, multiple, args)" do
|
|
20
27
|
it "should pass if target includes all items" do
|
21
28
|
[1,2,3].should include(1,2,3)
|
22
29
|
end
|
30
|
+
|
31
|
+
it 'should pass if target is a Hash including all items as keys' do
|
32
|
+
{:key => 'value', :other => 'value'}.should include(:key, :other)
|
33
|
+
end
|
23
34
|
|
24
35
|
it "should fail if target does not include any one of the items" do
|
25
36
|
lambda {
|
26
37
|
[1,2,3].should include(1,2,4)
|
27
38
|
}.should fail_with("expected [1, 2, 3] to include 1, 2 and 4")
|
28
39
|
end
|
40
|
+
|
41
|
+
it 'should pass if target is a Hash missing any item as a key' do
|
42
|
+
lambda {
|
43
|
+
{:key => 'value'}.should include(:key, :other)
|
44
|
+
}.should fail_with(%Q|expected {:key=>"value"} to include :key and :other|)
|
45
|
+
end
|
29
46
|
end
|
30
47
|
|
31
48
|
describe "should_not include(expected)" do
|
@@ -33,6 +50,10 @@ describe "should_not include(expected)" do
|
|
33
50
|
[1,2,3].should_not include(4)
|
34
51
|
"abc".should_not include("d")
|
35
52
|
end
|
53
|
+
|
54
|
+
it 'should pass if target is a Hash and does not have the expected as a key' do
|
55
|
+
{:other => 'value'}.should_not include(:key)
|
56
|
+
end
|
36
57
|
|
37
58
|
it "should fail if target includes expected" do
|
38
59
|
lambda {
|
@@ -41,6 +62,9 @@ describe "should_not include(expected)" do
|
|
41
62
|
lambda {
|
42
63
|
"abc".should_not include("c")
|
43
64
|
}.should fail_with("expected \"abc\" not to include \"c\"")
|
65
|
+
lambda {
|
66
|
+
{:key => 'value'}.should_not include(:key)
|
67
|
+
}.should fail_with(%Q|expected {:key=>"value"} not to include :key|)
|
44
68
|
end
|
45
69
|
end
|
46
70
|
|
@@ -16,18 +16,9 @@ This module should provide the following methods, each of which returns a Matche
|
|
16
16
|
it "be_arbitrary_predicate" do
|
17
17
|
be_arbitrary_predicate.should be_an_instance_of(Be)
|
18
18
|
end
|
19
|
-
it "be_close" do
|
20
|
-
be_close(1,2).should be_an_instance_of(BeClose)
|
21
|
-
end
|
22
19
|
it "change" do
|
23
20
|
change("target", :message).should be_an_instance_of(Change)
|
24
21
|
end
|
25
|
-
it "eql" do
|
26
|
-
eql(:expected).should be_an_instance_of(Eql)
|
27
|
-
end
|
28
|
-
it "equal" do
|
29
|
-
equal(:expected).should be_an_instance_of(Equal)
|
30
|
-
end
|
31
22
|
it "have" do
|
32
23
|
have(0).should be_an_instance_of(Have)
|
33
24
|
end
|
@@ -43,9 +34,6 @@ This module should provide the following methods, each of which returns a Matche
|
|
43
34
|
it "include" do
|
44
35
|
include(:value).should be_an_instance_of(Include)
|
45
36
|
end
|
46
|
-
it "match" do
|
47
|
-
match(:value).should be_an_instance_of(Match)
|
48
|
-
end
|
49
37
|
it "raise_error" do
|
50
38
|
raise_error.should be_an_instance_of(RaiseError)
|
51
39
|
raise_error(NoMethodError).should be_an_instance_of(RaiseError)
|
@@ -70,7 +58,7 @@ This module should provide the following methods, each of which returns a Matche
|
|
70
58
|
end
|
71
59
|
|
72
60
|
it "should convert have_xyz to Has(:have_xyz)" do
|
73
|
-
|
61
|
+
self.should_receive(:has).with(:have_whatever)
|
74
62
|
have_whatever
|
75
63
|
end
|
76
64
|
end
|
@@ -5,7 +5,7 @@ module Spec
|
|
5
5
|
describe ThrowSymbol do
|
6
6
|
describe "with no args" do
|
7
7
|
before(:each) { @matcher = ThrowSymbol.new }
|
8
|
-
|
8
|
+
|
9
9
|
it "should match if any Symbol is thrown" do
|
10
10
|
@matcher.matches?(lambda{ throw :sym }).should be_true
|
11
11
|
end
|
@@ -24,7 +24,7 @@ module Spec
|
|
24
24
|
@matcher.negative_failure_message.should == "expected no Symbol, got :sym"
|
25
25
|
end
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
describe "with a symbol" do
|
29
29
|
before(:each) { @matcher = ThrowSymbol.new(:sym) }
|
30
30
|
|
@@ -56,7 +56,7 @@ module Spec
|
|
56
56
|
@matcher.matches?(lambda{ sym }).should be_false
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
describe "with a symbol and an arg" do
|
61
61
|
before(:each) { @matcher = ThrowSymbol.new(:sym, "a") }
|
62
62
|
|
@@ -1,13 +1,11 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
|
3
3
|
class LiarLiarPantsOnFire
|
4
|
-
|
5
|
-
extend Spec::MetaClass
|
6
|
-
def respond_to?(sym)
|
4
|
+
def respond_to?(sym, incl_private=false)
|
7
5
|
true
|
8
6
|
end
|
9
7
|
|
10
|
-
def self.respond_to?(sym)
|
8
|
+
def self.respond_to?(sym, incl_private=false)
|
11
9
|
true
|
12
10
|
end
|
13
11
|
end
|
@@ -28,6 +26,7 @@ describe 'should_receive' do
|
|
28
26
|
end
|
29
27
|
|
30
28
|
it 'should cleanup after itself' do
|
31
|
-
LiarLiarPantsOnFire.
|
29
|
+
(class << LiarLiarPantsOnFire; self; end).instance_methods.should_not include("something")
|
32
30
|
end
|
33
31
|
end
|
32
|
+
|
@@ -1,16 +1,18 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
2
|
|
3
|
-
|
4
|
-
|
3
|
+
module BugReport496
|
4
|
+
class BaseClass
|
5
|
+
end
|
5
6
|
|
6
|
-
class SubClass < BaseClass
|
7
|
-
end
|
7
|
+
class SubClass < BaseClass
|
8
|
+
end
|
8
9
|
|
9
|
-
describe "a message expectation on a base class object" do
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
describe "a message expectation on a base class object" do
|
11
|
+
it "should correctly pick up message sent to it subclass" do
|
12
|
+
pending("fix for http://rspec.lighthouseapp.com/projects/5645/tickets/496") do
|
13
|
+
BaseClass.should_receive(:new).once
|
14
|
+
SubClass.new
|
15
|
+
end
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper.rb'
|
2
|
+
|
3
|
+
module BugReport600
|
4
|
+
class ExampleClass
|
5
|
+
def self.method_that_uses_define_method
|
6
|
+
define_method "defined_method" do |attributes|
|
7
|
+
load_address(address, attributes)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe "stubbing a class method" do
|
13
|
+
it "should work" do
|
14
|
+
ExampleClass.should_receive(:define_method).with("defined_method")
|
15
|
+
ExampleClass.method_that_uses_define_method
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should restore the original method" do
|
19
|
+
ExampleClass.method_that_uses_define_method
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -300,7 +300,7 @@ OUT
|
|
300
300
|
formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}")
|
301
301
|
io.rewind
|
302
302
|
formatter.dump_pending
|
303
|
-
io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/
|
303
|
+
io.string.should =~ /Pending\:\n\nExampleGroup example \(reason\)\n/
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
@@ -88,17 +88,6 @@ EOE
|
|
88
88
|
EOE
|
89
89
|
end
|
90
90
|
|
91
|
-
it "should dump pending" do
|
92
|
-
example_group = ExampleGroup.describe("example_group") do
|
93
|
-
specify "example" do
|
94
|
-
end
|
95
|
-
end
|
96
|
-
example = example_group.examples.first
|
97
|
-
@formatter.example_pending(example, "message", "#{__FILE__}:#{__LINE__}")
|
98
|
-
@formatter.dump_pending
|
99
|
-
@io.string.should =~ /Pending\:\nexample_group example \(message\)\n/
|
100
|
-
end
|
101
|
-
|
102
91
|
it "should dump pending with file and line number" do
|
103
92
|
example_group = ExampleGroup.describe("example_group") do
|
104
93
|
specify "example" do
|
@@ -112,8 +101,9 @@ EOE
|
|
112
101
|
@io.string.should ==(<<-HERE)
|
113
102
|
*
|
114
103
|
Pending:
|
104
|
+
|
115
105
|
example_group example (message)
|
116
|
-
|
106
|
+
#{file}:#{line}
|
117
107
|
HERE
|
118
108
|
end
|
119
109
|
end
|
@@ -124,11 +114,11 @@ HERE
|
|
124
114
|
@options = mock('options')
|
125
115
|
@out.stub!(:puts)
|
126
116
|
@formatter = ProgressBarFormatter.new(@options, @out)
|
127
|
-
@formatter.class.
|
117
|
+
@formatter.class.__send__ :public, :output_to_tty?
|
128
118
|
end
|
129
119
|
|
130
120
|
after(:each) do
|
131
|
-
@formatter.class.
|
121
|
+
@formatter.class.__send__ :protected, :output_to_tty?
|
132
122
|
end
|
133
123
|
|
134
124
|
it "should not throw NoMethodError on output_to_tty?" do
|
@@ -141,7 +141,7 @@ module Spec
|
|
141
141
|
formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}")
|
142
142
|
io.rewind
|
143
143
|
formatter.dump_pending
|
144
|
-
io.string.should =~ /Pending\:\nExampleGroup example \(reason\)\n/
|
144
|
+
io.string.should =~ /Pending\:\n\nExampleGroup example \(reason\)\n/
|
145
145
|
end
|
146
146
|
end
|
147
147
|
|
@@ -212,7 +212,7 @@ module Spec
|
|
212
212
|
describe "#load_class" do
|
213
213
|
it "should raise error when not class name" do
|
214
214
|
lambda do
|
215
|
-
@options.
|
215
|
+
@options.__send__(:load_class, 'foo', 'fruit', '--food')
|
216
216
|
end.should raise_error('"foo" is not a valid class name')
|
217
217
|
end
|
218
218
|
end
|