rr 1.0.4 → 1.0.5.rc1
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.
- checksums.yaml +15 -0
- data/CHANGES.md +376 -0
- data/Gemfile +7 -10
- data/README.md +822 -0
- data/Rakefile +24 -78
- data/VERSION +1 -0
- data/lib/rr.rb +3 -0
- data/lib/rr/adapters/minitest.rb +6 -0
- data/lib/rr/adapters/rr_methods.rb +6 -10
- data/lib/rr/adapters/rspec.rb +3 -0
- data/lib/rr/adapters/rspec2.rb +30 -0
- data/lib/rr/adapters/test_unit.rb +2 -0
- data/lib/rr/double.rb +3 -2
- data/lib/rr/double_definitions/child_double_definition_create.rb +3 -2
- data/lib/rr/double_definitions/double_definition.rb +15 -13
- data/lib/rr/double_definitions/double_definition_create.rb +9 -5
- data/lib/rr/double_definitions/double_injections/any_instance_of.rb +3 -2
- data/lib/rr/double_definitions/strategies/strategy.rb +5 -4
- data/lib/rr/double_definitions/strategies/strategy_methods.rb +6 -8
- data/lib/rr/double_definitions/strategies/verification/mock.rb +3 -3
- data/lib/rr/double_matches.rb +2 -1
- data/lib/rr/expectations/argument_equality_expectation.rb +2 -2
- data/lib/rr/expectations/times_called_expectation.rb +2 -2
- data/lib/rr/injections/double_injection.rb +12 -11
- data/lib/rr/injections/injection.rb +2 -2
- data/lib/rr/injections/method_missing_injection.rb +21 -7
- data/lib/rr/injections/singleton_method_added_injection.rb +3 -1
- data/lib/rr/method_dispatches/base_method_dispatch.rb +1 -1
- data/lib/rr/method_dispatches/method_dispatch.rb +2 -1
- data/lib/rr/method_dispatches/method_missing_dispatch.rb +2 -1
- data/lib/rr/proc_from_block.rb +8 -4
- data/lib/rr/space.rb +3 -2
- data/lib/rr/times_called_matchers/times_called_matcher.rb +2 -2
- data/lib/rr/version.rb +5 -0
- data/lib/rr/wildcard_matchers/boolean.rb +2 -2
- data/spec/runner.rb +41 -0
- metadata +45 -133
- data/.gitignore +0 -10
- data/.runrc +0 -3
- data/.rvmrc +0 -2
- data/CHANGES +0 -266
- data/Gemfile.lock +0 -31
- data/README.rdoc +0 -392
- data/benchmarks/rr_benchmark.rb +0 -32
- data/benchmarks/rspec_benchmark.rb +0 -14
- data/doc/0.6.0.release.markdown +0 -81
- data/doc/todo.txt +0 -0
- data/introducting_rr.txt +0 -206
- data/rr.gemspec +0 -37
- data/spec/api/any_instance_of/all_instances_of_spec.rb +0 -12
- data/spec/api/any_instance_of/any_instance_of_spec.rb +0 -47
- data/spec/api/any_instance_of/instance_of_spec.rb +0 -12
- data/spec/api/dont_allow/dont_allow_after_stub_spec.rb +0 -14
- data/spec/api/mock/mock_spec.rb +0 -193
- data/spec/api/proxy/proxy_spec.rb +0 -86
- data/spec/api/spy/spy_spec.rb +0 -49
- data/spec/api/strong/strong_spec.rb +0 -87
- data/spec/api/stub/stub_spec.rb +0 -152
- data/spec/core_spec_suite.rb +0 -19
- data/spec/environment_fixture_setup.rb +0 -8
- data/spec/minitest_spec_suite.rb +0 -21
- data/spec/proc_from_block_spec.rb +0 -14
- data/spec/rr/adapters/rr_methods_argument_matcher_spec.rb +0 -67
- data/spec/rr/adapters/rr_methods_creator_spec.rb +0 -137
- data/spec/rr/adapters/rr_methods_space_spec.rb +0 -98
- data/spec/rr/adapters/rr_methods_spec_helper.rb +0 -11
- data/spec/rr/adapters/rr_methods_times_matcher_spec.rb +0 -13
- data/spec/rr/double_definitions/child_double_definition_creator_spec.rb +0 -112
- data/spec/rr/double_definitions/double_definition_create_blank_slate_spec.rb +0 -91
- data/spec/rr/double_definitions/double_definition_create_spec.rb +0 -443
- data/spec/rr/double_injection/double_injection_spec.rb +0 -546
- data/spec/rr/double_injection/double_injection_verify_spec.rb +0 -29
- data/spec/rr/errors/rr_error_spec.rb +0 -67
- data/spec/rr/expectations/any_argument_expectation_spec.rb +0 -47
- data/spec/rr/expectations/anything_argument_equality_expectation_spec.rb +0 -14
- data/spec/rr/expectations/argument_equality_expectation_spec.rb +0 -135
- data/spec/rr/expectations/boolean_argument_equality_expectation_spec.rb +0 -34
- data/spec/rr/expectations/hash_including_argument_equality_expectation_spec.rb +0 -82
- data/spec/rr/expectations/hash_including_spec.rb +0 -17
- data/spec/rr/expectations/satisfy_argument_equality_expectation_spec.rb +0 -59
- data/spec/rr/expectations/satisfy_spec.rb +0 -14
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_any_times_spec.rb +0 -22
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_least_spec.rb +0 -37
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_at_most_spec.rb +0 -43
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_helper.rb +0 -15
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_integer_spec.rb +0 -58
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_proc_spec.rb +0 -35
- data/spec/rr/expectations/times_called_expectation/times_called_expectation_range_spec.rb +0 -39
- data/spec/rr/minitest/minitest_integration_test.rb +0 -59
- data/spec/rr/minitest/test_helper.rb +0 -7
- data/spec/rr/rspec/invocation_matcher_spec.rb +0 -279
- data/spec/rr/rspec/rspec_adapter_spec.rb +0 -63
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec.rb +0 -31
- data/spec/rr/rspec/rspec_backtrace_tweaking_spec_fixture.rb +0 -11
- data/spec/rr/rspec/rspec_usage_spec.rb +0 -86
- data/spec/rr/space/hash_with_object_id_key_spec.rb +0 -88
- data/spec/rr/space/space_spec.rb +0 -596
- data/spec/rr/test_unit/test_helper.rb +0 -7
- data/spec/rr/test_unit/test_unit_backtrace_test.rb +0 -36
- data/spec/rr/test_unit/test_unit_integration_test.rb +0 -59
- data/spec/rr/times_called_matchers/any_times_matcher_spec.rb +0 -47
- data/spec/rr/times_called_matchers/at_least_matcher_spec.rb +0 -55
- data/spec/rr/times_called_matchers/at_most_matcher_spec.rb +0 -70
- data/spec/rr/times_called_matchers/integer_matcher_spec.rb +0 -70
- data/spec/rr/times_called_matchers/proc_matcher_spec.rb +0 -55
- data/spec/rr/times_called_matchers/range_matcher_spec.rb +0 -76
- data/spec/rr/times_called_matchers/times_called_matcher_spec.rb +0 -118
- data/spec/rr/wildcard_matchers/anything_spec.rb +0 -24
- data/spec/rr/wildcard_matchers/boolean_spec.rb +0 -36
- data/spec/rr/wildcard_matchers/duck_type_spec.rb +0 -52
- data/spec/rr/wildcard_matchers/is_a_spec.rb +0 -32
- data/spec/rr/wildcard_matchers/numeric_spec.rb +0 -32
- data/spec/rr/wildcard_matchers/range_spec.rb +0 -35
- data/spec/rr/wildcard_matchers/regexp_spec.rb +0 -43
- data/spec/rr_spec.rb +0 -28
- data/spec/rspec_spec_suite.rb +0 -17
- data/spec/spec.opts +0 -10
- data/spec/spec_helper.rb +0 -41
- data/spec/spec_suite.rb +0 -54
- data/spec/spy_verification_spec.rb +0 -129
- data/spec/test_unit_spec_suite.rb +0 -21
@@ -1,67 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module Adapters
|
5
|
-
describe RRMethods do
|
6
|
-
describe "#anything" do
|
7
|
-
it_should_behave_like "RR::Adapters::RRMethods"
|
8
|
-
|
9
|
-
it "returns an Anything matcher" do
|
10
|
-
anything.should == RR::WildcardMatchers::Anything.new
|
11
|
-
end
|
12
|
-
|
13
|
-
it "rr_anything returns an Anything matcher" do
|
14
|
-
rr_anything.should == RR::WildcardMatchers::Anything.new
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe "#is_a" do
|
19
|
-
it_should_behave_like "RR::Adapters::RRMethods"
|
20
|
-
|
21
|
-
it "returns an IsA matcher" do
|
22
|
-
is_a(Integer).should == RR::WildcardMatchers::IsA.new(Integer)
|
23
|
-
end
|
24
|
-
|
25
|
-
it "rr_is_a returns an IsA matcher" do
|
26
|
-
rr_is_a(Integer).should == RR::WildcardMatchers::IsA.new(Integer)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "#numeric" do
|
31
|
-
it_should_behave_like "RR::Adapters::RRMethods"
|
32
|
-
|
33
|
-
it "returns an Numeric matcher" do
|
34
|
-
numeric.should == RR::WildcardMatchers::Numeric.new
|
35
|
-
end
|
36
|
-
|
37
|
-
it "rr_numeric returns an Numeric matcher" do
|
38
|
-
rr_numeric.should == RR::WildcardMatchers::Numeric.new
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#boolean" do
|
43
|
-
it_should_behave_like "RR::Adapters::RRMethods"
|
44
|
-
|
45
|
-
it "returns an Boolean matcher" do
|
46
|
-
boolean.should == RR::WildcardMatchers::Boolean.new
|
47
|
-
end
|
48
|
-
|
49
|
-
it "rr_boolean returns an Boolean matcher" do
|
50
|
-
rr_boolean.should == RR::WildcardMatchers::Boolean.new
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe "#duck_type" do
|
55
|
-
it_should_behave_like "RR::Adapters::RRMethods"
|
56
|
-
|
57
|
-
it "returns a DuckType matcher" do
|
58
|
-
duck_type(:one, :two).should == RR::WildcardMatchers::DuckType.new(:one, :two)
|
59
|
-
end
|
60
|
-
|
61
|
-
it "rr_duck_type returns a DuckType matcher" do
|
62
|
-
rr_duck_type(:one, :two).should == RR::WildcardMatchers::DuckType.new(:one, :two)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
@@ -1,137 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module Adapters
|
5
|
-
describe RRMethods do
|
6
|
-
attr_reader :subject
|
7
|
-
before(:each) do
|
8
|
-
@subject = Object.new
|
9
|
-
end
|
10
|
-
|
11
|
-
after(:each) do
|
12
|
-
RR.reset
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "normal strategy definitions" do
|
16
|
-
attr_reader :strategy_method_name
|
17
|
-
def call_strategy(*args, &block)
|
18
|
-
__send__(strategy_method_name, *args, &block)
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#mock" do
|
22
|
-
before do
|
23
|
-
@strategy_method_name = :mock
|
24
|
-
end
|
25
|
-
|
26
|
-
context "when passing no args" do
|
27
|
-
it "returns a DoubleDefinitionCreate" do
|
28
|
-
call_strategy.class.should == RR::DoubleDefinitions::DoubleDefinitionCreate
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "when passed a method_name argument" do
|
33
|
-
it "creates a mock Double for method" do
|
34
|
-
double_definition = mock(subject, :foobar).returns {:baz}
|
35
|
-
double_definition.times_matcher.should == RR::TimesCalledMatchers::IntegerMatcher.new(1)
|
36
|
-
double_definition.argument_expectation.class.should == RR::Expectations::ArgumentEqualityExpectation
|
37
|
-
double_definition.argument_expectation.expected_arguments.should == []
|
38
|
-
subject.foobar.should == :baz
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "#stub" do
|
44
|
-
before do
|
45
|
-
@strategy_method_name = :stub
|
46
|
-
end
|
47
|
-
|
48
|
-
context "when passing no args" do
|
49
|
-
it "returns a DoubleDefinitionCreate" do
|
50
|
-
call_strategy.class.should == RR::DoubleDefinitions::DoubleDefinitionCreate
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
context "when passed a method_name argument" do
|
55
|
-
it "creates a stub Double for method when passed a method_name argument" do
|
56
|
-
double_definition = stub(subject, :foobar).returns {:baz}
|
57
|
-
double_definition.times_matcher.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
58
|
-
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
59
|
-
subject.foobar.should == :baz
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
describe "#dont_allow" do
|
65
|
-
before do
|
66
|
-
@strategy_method_name = :dont_allow
|
67
|
-
end
|
68
|
-
|
69
|
-
context "when passing no args" do
|
70
|
-
it "returns a DoubleDefinitionCreate" do
|
71
|
-
call_strategy.class.should == RR::DoubleDefinitions::DoubleDefinitionCreate
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
context "when passed a method_name argument_expectation" do
|
76
|
-
it "creates a mock Double for method" do
|
77
|
-
double_definition = dont_allow(subject, :foobar)
|
78
|
-
double_definition.times_matcher.should == RR::TimesCalledMatchers::NeverMatcher.new
|
79
|
-
double_definition.argument_expectation.class.should == RR::Expectations::AnyArgumentExpectation
|
80
|
-
|
81
|
-
lambda do
|
82
|
-
subject.foobar
|
83
|
-
end.should raise_error(RR::Errors::TimesCalledError)
|
84
|
-
RR.reset
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
describe "! strategy definitions" do
|
91
|
-
attr_reader :strategy_method_name
|
92
|
-
def call_strategy(*args, &definition_eval_block)
|
93
|
-
__send__(strategy_method_name, *args, &definition_eval_block)
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "#mock!" do
|
97
|
-
before do
|
98
|
-
@strategy_method_name = :mock!
|
99
|
-
end
|
100
|
-
|
101
|
-
context "when passed a method_name argument" do
|
102
|
-
it "sets #verification_strategy to Mock" do
|
103
|
-
proxy = mock!(:foobar)
|
104
|
-
proxy.double_definition_create.verification_strategy.class.should == RR::DoubleDefinitions::Strategies::Verification::Mock
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "#stub!" do
|
110
|
-
before do
|
111
|
-
@strategy_method_name = :stub!
|
112
|
-
end
|
113
|
-
|
114
|
-
context "when passed a method_name argument" do
|
115
|
-
it "sets #verification_strategy to Stub" do
|
116
|
-
proxy = stub!(:foobar)
|
117
|
-
proxy.double_definition_create.verification_strategy.class.should == RR::DoubleDefinitions::Strategies::Verification::Stub
|
118
|
-
end
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "#dont_allow!" do
|
123
|
-
before do
|
124
|
-
@strategy_method_name = :dont_allow!
|
125
|
-
end
|
126
|
-
|
127
|
-
context "when passed a method_name argument" do
|
128
|
-
it "sets #verification_strategy to DontAllow" do
|
129
|
-
proxy = dont_allow!(:foobar)
|
130
|
-
proxy.double_definition_create.verification_strategy.class.should == RR::DoubleDefinitions::Strategies::Verification::DontAllow
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module Adapters
|
5
|
-
describe RRMethods do
|
6
|
-
attr_reader :space, :subject_1, :subject_2, :method_name
|
7
|
-
it_should_behave_like "Swapped Space"
|
8
|
-
it_should_behave_like "RR::Adapters::RRMethods"
|
9
|
-
before do
|
10
|
-
@subject_1 = Object.new
|
11
|
-
@subject_2 = Object.new
|
12
|
-
@method_name = :foobar
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#verify" do
|
16
|
-
it "aliases #rr_verify" do
|
17
|
-
RRMethods.instance_method("verify").should == RRMethods.instance_method("rr_verify")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "#rr_verify" do
|
22
|
-
it "verifies and deletes the double_injections" do
|
23
|
-
double_1 = ::RR::Injections::DoubleInjection.find_or_create_by_subject(subject_1, method_name)
|
24
|
-
double_1_verify_calls = 0
|
25
|
-
double_1_reset_calls = 0
|
26
|
-
(
|
27
|
-
class << double_1;
|
28
|
-
self;
|
29
|
-
end).class_eval do
|
30
|
-
define_method(:verify) do ||
|
31
|
-
double_1_verify_calls += 1
|
32
|
-
end
|
33
|
-
define_method(:reset) do ||
|
34
|
-
double_1_reset_calls += 1
|
35
|
-
end
|
36
|
-
end
|
37
|
-
double_2 = ::RR::Injections::DoubleInjection.find_or_create_by_subject(subject_2, method_name)
|
38
|
-
double_2_verify_calls = 0
|
39
|
-
double_2_reset_calls = 0
|
40
|
-
( class << double_2; self; end).class_eval do
|
41
|
-
define_method(:verify) do ||
|
42
|
-
double_2_verify_calls += 1
|
43
|
-
end
|
44
|
-
define_method(:reset) do ||
|
45
|
-
double_2_reset_calls += 1
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
rr_verify
|
50
|
-
double_1_verify_calls.should == 1
|
51
|
-
double_2_verify_calls.should == 1
|
52
|
-
double_1_reset_calls.should == 1
|
53
|
-
double_1_reset_calls.should == 1
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "#reset" do
|
58
|
-
it "aliases #rr_reset" do
|
59
|
-
RRMethods.instance_method("reset").should == RRMethods.instance_method("rr_reset")
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "#rr_reset" do
|
64
|
-
it "removes the ordered doubles" do
|
65
|
-
mock(subject_1).foobar1.ordered
|
66
|
-
mock(subject_2).foobar2.ordered
|
67
|
-
|
68
|
-
::RR::Injections::DoubleInjection.instances.should_not be_empty
|
69
|
-
|
70
|
-
rr_reset
|
71
|
-
::RR::Injections::DoubleInjection.instances
|
72
|
-
::RR::Injections::DoubleInjection.instances.should be_empty
|
73
|
-
end
|
74
|
-
|
75
|
-
it "resets all double_injections" do
|
76
|
-
double_1 = ::RR::Injections::DoubleInjection.find_or_create_by_subject(subject_1, method_name)
|
77
|
-
double_1_reset_calls = 0
|
78
|
-
( class << double_1; self; end).class_eval do
|
79
|
-
define_method(:reset) do ||
|
80
|
-
double_1_reset_calls += 1
|
81
|
-
end
|
82
|
-
end
|
83
|
-
double_2 = ::RR::Injections::DoubleInjection.find_or_create_by_subject(subject_2, method_name)
|
84
|
-
double_2_reset_calls = 0
|
85
|
-
( class << double_2; self; end).class_eval do
|
86
|
-
define_method(:reset) do ||
|
87
|
-
double_2_reset_calls += 1
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
rr_reset
|
92
|
-
double_1_reset_calls.should == 1
|
93
|
-
double_2_reset_calls.should == 1
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
-
|
3
|
-
describe RR::Adapters::RRMethods, "#any_times" do
|
4
|
-
it_should_behave_like "RR::Adapters::RRMethods"
|
5
|
-
|
6
|
-
it "returns an AnyTimesMatcher" do
|
7
|
-
any_times.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
8
|
-
end
|
9
|
-
|
10
|
-
it "rr_any_times returns an AnyTimesMatcher" do
|
11
|
-
rr_any_times.should == RR::TimesCalledMatchers::AnyTimesMatcher.new
|
12
|
-
end
|
13
|
-
end
|
@@ -1,112 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module DoubleDefinitions
|
5
|
-
describe ChildDoubleDefinitionCreate do
|
6
|
-
attr_reader :parent_subject, :parent_double_definition_create, :parent_double_definition, :child_double_definition_create
|
7
|
-
it_should_behave_like "Swapped Space"
|
8
|
-
before(:each) do
|
9
|
-
@parent_subject = Object.new
|
10
|
-
@parent_double_definition_create = DoubleDefinitionCreate.new
|
11
|
-
@parent_double_definition = DoubleDefinition.new(parent_double_definition_create)
|
12
|
-
@child_double_definition_create = ChildDoubleDefinitionCreate.new(parent_double_definition)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "#root_subject" do
|
16
|
-
it "returns the #parent_double_definition.root_subject" do
|
17
|
-
child_subject = Object.new
|
18
|
-
parent_double_definition_create.stub(parent_subject)
|
19
|
-
child_double_definition_create.stub(child_subject)
|
20
|
-
child_double_definition_create.root_subject.should == parent_subject
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "Strategies::Verification definitions" do
|
25
|
-
describe "methods without !" do
|
26
|
-
attr_reader :child_subject
|
27
|
-
before do
|
28
|
-
@child_subject = Object.new
|
29
|
-
end
|
30
|
-
|
31
|
-
describe "#mock" do
|
32
|
-
context "when passed a subject" do
|
33
|
-
it "sets #parent_double_definition.implementation to a Proc returning the passed-in subject" do
|
34
|
-
parent_double_definition.implementation.should be_nil
|
35
|
-
child_double_definition_create.mock(child_subject)
|
36
|
-
parent_double_definition.implementation.call.should == child_subject
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "#stub" do
|
42
|
-
context "when passed a subject" do
|
43
|
-
it "sets #parent_double_definition.implementation to a Proc returning the passed-in subject" do
|
44
|
-
parent_double_definition.implementation.should be_nil
|
45
|
-
child_double_definition_create.stub(child_subject)
|
46
|
-
parent_double_definition.implementation.call.should == child_subject
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "#dont_allow" do
|
52
|
-
context "when passed a subject" do
|
53
|
-
it "sets #parent_double_definition.implementation to a Proc returning the passed-in subject" do
|
54
|
-
parent_double_definition.implementation.should be_nil
|
55
|
-
child_double_definition_create.dont_allow(child_subject)
|
56
|
-
parent_double_definition.implementation.call.should == child_subject
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
describe "methods with !" do
|
63
|
-
describe "#mock!" do
|
64
|
-
it "sets #parent_double_definition.implementation to a Proc returning the #subject" do
|
65
|
-
parent_double_definition.implementation.should be_nil
|
66
|
-
child_subject = child_double_definition_create.mock!.__double_definition_create__.subject
|
67
|
-
parent_double_definition.implementation.call.should == child_subject
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "#stub!" do
|
72
|
-
it "sets #parent_double_definition.implementation to a Proc returning the #subject" do
|
73
|
-
parent_double_definition.implementation.should be_nil
|
74
|
-
child_subject = child_double_definition_create.stub!.__double_definition_create__.subject
|
75
|
-
parent_double_definition.implementation.call.should == child_subject
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "#dont_allow!" do
|
80
|
-
it "sets #parent_double_definition.implementation to a Proc returning the #subject" do
|
81
|
-
parent_double_definition.implementation.should be_nil
|
82
|
-
child_subject = child_double_definition_create.dont_allow!.__double_definition_create__.subject
|
83
|
-
parent_double_definition.implementation.call.should == child_subject
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
describe "Strategies::DoubleInjection definitions" do
|
90
|
-
describe "methods without !" do
|
91
|
-
describe "#instance_of" do
|
92
|
-
it "raises a NoMethodError" do
|
93
|
-
lambda do
|
94
|
-
child_double_definition_create.instance_of
|
95
|
-
end.should raise_error(NoMethodError)
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe "methods with !" do
|
101
|
-
describe "#instance_of!" do
|
102
|
-
it "raises a NoMethodError" do
|
103
|
-
lambda do
|
104
|
-
child_double_definition_create.instance_of!
|
105
|
-
end.should raise_error(NoMethodError)
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
require File.expand_path("#{File.dirname(__FILE__)}/../../spec_helper")
|
2
|
-
|
3
|
-
module RR
|
4
|
-
module DoubleDefinitions
|
5
|
-
describe DoubleDefinitionCreateBlankSlate do
|
6
|
-
attr_reader :subject, :double_definition_create, :blank_slate
|
7
|
-
it_should_behave_like "Swapped Space"
|
8
|
-
|
9
|
-
before(:each) do
|
10
|
-
@subject = Object.new
|
11
|
-
@double_definition_create = DoubleDefinitionCreate.new
|
12
|
-
double_definition_create.mock(subject)
|
13
|
-
end
|
14
|
-
|
15
|
-
describe ".new" do
|
16
|
-
it "does not undefine object_id" do
|
17
|
-
blank_slate = DoubleDefinitionCreateBlankSlate.new(double_definition_create)
|
18
|
-
blank_slate.object_id.class.should == Fixnum
|
19
|
-
end
|
20
|
-
|
21
|
-
context "without block" do
|
22
|
-
before do
|
23
|
-
@blank_slate = DoubleDefinitionCreateBlankSlate.new(double_definition_create)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "clears out all methods from proxy" do
|
27
|
-
stub(subject).i_should_be_a_double.should be_instance_of(DoubleDefinition)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context "when passed a block" do
|
32
|
-
context "when the block has an arity of 1" do
|
33
|
-
attr_reader :passed_in_argument
|
34
|
-
before do
|
35
|
-
passed_in_argument = nil
|
36
|
-
stub(subject) do |b|
|
37
|
-
passed_in_argument = b
|
38
|
-
b.foobar(1, 2) {:one_two}
|
39
|
-
b.foobar(1) {:one}
|
40
|
-
b.foobar.with_any_args {:default}
|
41
|
-
b.baz() {:baz_result}
|
42
|
-
end
|
43
|
-
@passed_in_argument = passed_in_argument
|
44
|
-
end
|
45
|
-
|
46
|
-
it "creates double_injections" do
|
47
|
-
subject.foobar(1, 2).should == :one_two
|
48
|
-
subject.foobar(1).should == :one
|
49
|
-
subject.foobar(:something).should == :default
|
50
|
-
subject.baz.should == :baz_result
|
51
|
-
end
|
52
|
-
|
53
|
-
it "passes the self into the block" do
|
54
|
-
passed_in_argument.__double_definition_create__.should be_instance_of(
|
55
|
-
::RR::DoubleDefinitions::DoubleDefinitionCreate
|
56
|
-
)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "when the block has an arity of 0" do
|
61
|
-
attr_reader :self_value
|
62
|
-
before do
|
63
|
-
self_value = nil
|
64
|
-
stub(subject) do ||
|
65
|
-
self_value = self
|
66
|
-
foobar(1, 2) {:one_two}
|
67
|
-
foobar(1) {:one}
|
68
|
-
foobar.with_any_args {:default}
|
69
|
-
baz() {:baz_result}
|
70
|
-
end
|
71
|
-
@self_value = self_value
|
72
|
-
end
|
73
|
-
|
74
|
-
it "creates double_injections" do
|
75
|
-
subject.foobar(1, 2).should == :one_two
|
76
|
-
subject.foobar(1).should == :one
|
77
|
-
subject.foobar(:something).should == :default
|
78
|
-
subject.baz.should == :baz_result
|
79
|
-
end
|
80
|
-
|
81
|
-
it "evaluates the block with the context of self" do
|
82
|
-
self_value.__double_definition_create__.should be_instance_of(
|
83
|
-
::RR::DoubleDefinitions::DoubleDefinitionCreate
|
84
|
-
)
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
91
|
-
end
|