caricature 0.7.1 → 0.7.2
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/Rakefile +47 -40
- data/caricature.gemspec +50 -17
- data/lib/caricature.rb +9 -1
- data/lib/caricature/bacon/integration.rb +3 -5
- data/lib/caricature/clr/isolation.rb +1 -1
- data/lib/caricature/method_call_recorder.rb +7 -2
- data/lib/caricature/rspec.rb +1 -0
- data/lib/caricature/rspec/integration.rb +77 -0
- data/lib/caricature/verification.rb +9 -1
- data/lib/caricature/version.rb +1 -1
- data/lib/core_ext/class.rb +1 -1
- data/lib/core_ext/module.rb +1 -1
- data/lib/core_ext/object.rb +2 -2
- data/spec/{integration → bacon/integration}/callback_spec.rb +1 -1
- data/spec/{integration → bacon/integration}/clr_to_clr_spec.rb +1 -1
- data/spec/{integration → bacon/integration}/clr_to_ruby_spec.rb +1 -1
- data/spec/{integration → bacon/integration}/indexer_spec.rb +1 -1
- data/spec/{integration → bacon/integration}/ruby_to_ruby_spec.rb +1 -1
- data/spec/bacon/spec_helper.rb +5 -0
- data/spec/{unit → bacon/unit}/core_ext_spec.rb +13 -13
- data/spec/{unit → bacon/unit}/descriptor_spec.rb +1 -1
- data/spec/{unit → bacon/unit}/expectation_spec.rb +1 -1
- data/spec/{unit → bacon/unit}/interop_spec.rb +3 -3
- data/spec/{unit → bacon/unit}/isolation_spec.rb +1 -1
- data/spec/{unit → bacon/unit}/isolator_spec.rb +1 -1
- data/spec/{unit → bacon/unit}/messaging_spec.rb +1 -1
- data/spec/{unit → bacon/unit}/method_call_spec.rb +2 -2
- data/spec/{unit → bacon/unit}/sword_spec.rb +1 -1
- data/spec/{unit → bacon/unit}/verification_spec.rb +1 -1
- data/spec/bin/ClrModels.dll +0 -0
- data/spec/bin/ClrModels.dll.mdb +0 -0
- data/spec/{bacon_helper.rb → models/ruby_models.rb} +9 -26
- data/spec/rspec/integration/callback_spec.rb +157 -0
- data/spec/rspec/integration/clr_to_clr_spec.rb +255 -0
- data/spec/rspec/integration/clr_to_ruby_spec.rb +228 -0
- data/spec/rspec/integration/indexer_spec.rb +28 -0
- data/spec/rspec/integration/ruby_to_ruby_spec.rb +272 -0
- data/spec/rspec/spec_helper.rb +6 -0
- data/spec/rspec/unit/core_ext_spec.rb +87 -0
- data/spec/rspec/unit/descriptor_spec.rb +160 -0
- data/spec/rspec/unit/expectation_spec.rb +301 -0
- data/spec/rspec/unit/interop_spec.rb +43 -0
- data/spec/rspec/unit/isolation_spec.rb +87 -0
- data/spec/rspec/unit/isolator_spec.rb +220 -0
- data/spec/rspec/unit/messaging_spec.rb +311 -0
- data/spec/rspec/unit/method_call_spec.rb +343 -0
- data/spec/rspec/unit/sword_spec.rb +40 -0
- data/spec/rspec/unit/verification_spec.rb +104 -0
- data/spec/spec_helper.rb +15 -0
- metadata +37 -18
@@ -0,0 +1,87 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "String" do
|
4
|
+
|
5
|
+
it "should underscore a camel cased name" do
|
6
|
+
"MockingAndStubbingForIronRuby1".underscore.should == "mocking_and_stubbing_for_iron_ruby1"
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should get the class if it exists" do
|
10
|
+
"String".classify.should == String
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "Module" do
|
16
|
+
|
17
|
+
it "should strip the module names" do
|
18
|
+
ClrModels::IExposingWarrior.demodulize.should == "IExposingWarrior"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should identify it's not a CLR type for a Ruby defined module" do
|
22
|
+
Caricature.should_not be_clr_type
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should identify it's a CLR type for a CLR defined interface" do
|
26
|
+
ClrModels::IExposingWarrior.should be_clr_type
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should identify it's a CLR type for a Ruby defined module that includes a CLR interface" do
|
30
|
+
Caricature::InterfaceIncludingModule.should be_clr_type
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should identify it's not a CLR type for a Ruby defined module that includes a Ruby module" do
|
34
|
+
Caricature::RubyModuleIncludingModule.should_not be_clr_type
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should identify it's a CLR type when an ancestor includes a CLR interface" do
|
38
|
+
Caricature::InterfaceUpTheWazoo.should be_clr_type
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "Class" do
|
44
|
+
|
45
|
+
it "should strip the module names" do
|
46
|
+
ClrModels::Ninja.demodulize.should == "Ninja"
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should identify it's not a CLR type for a ruby defined type" do
|
50
|
+
Soldier.should_not be_clr_type
|
51
|
+
end
|
52
|
+
|
53
|
+
it "should identify it's not a CLR type for a ruby defined type that subclasses a Ruby class" do
|
54
|
+
Caricature::SubclassingRubyClass.should_not be_clr_type
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should identify it's not a CLR type for a ruby defined type that includes only ruby modueles in its hierarchy" do
|
58
|
+
Caricature::ModuleIncludingClass.should_not be_clr_type
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should identify it's a CLR type for a type defined in C#" do
|
62
|
+
ClrModels::Ninja.should be_clr_type
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should identify it's a CLR type for a type defined in Ruby that includes a CLR interface" do
|
66
|
+
Caricature::InterfaceIncludingClass.should be_clr_type
|
67
|
+
end
|
68
|
+
|
69
|
+
it "should identify it's a CLR type for a type defined in Ruby that subclasses a CLR class" do
|
70
|
+
Caricature::SubClassingClrClass.should be_clr_type
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should identify it's a CLR type for a type defined in Ruby that includes a CLR interface in its hierarchy" do
|
74
|
+
Caricature::InterfaceUpTheWazooClass.should be_clr_type
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "Array" do
|
80
|
+
|
81
|
+
it "should convert an array to a hash" do
|
82
|
+
expected = { :key1 => "value1", :key2 => "value2"}
|
83
|
+
%w(key1 value1 key2 value2).to_h.should == expected
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
@@ -0,0 +1,160 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "Caricature::TypeDescriptor" do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@des = Caricature::TypeDescriptor.new :in_unit_test_for_class
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should have a class_members method" do
|
10
|
+
@des.should respond_to(:class_members)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return an empty collection for the class members" do
|
14
|
+
@des.class_members.should be_empty
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have an instance members method" do
|
18
|
+
@des.should respond_to(:instance_members)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return an empty collection for the instance members" do
|
22
|
+
@des.instance_members.should be_empty
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should raise a NotImplementedError for the initialize_instance_members method" do
|
26
|
+
lambda { @des.initialize_instance_members_for Soldier }.should raise_error(NotImplementedError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should raise a NotImplementedError for the initialize_class_members method" do
|
30
|
+
lambda { @des.initialize_class_members_for Soldier }.should raise_error(NotImplementedError)
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "Caricature::MemberDescriptor" do
|
36
|
+
|
37
|
+
it "should have a name" do
|
38
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
39
|
+
des.name.should_not be_nil
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have the correct name" do
|
43
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
44
|
+
des.name.should == 'a name'
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should have a return_type" do
|
48
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
49
|
+
des.return_type.should_not be_nil
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have the correct return_type" do
|
53
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
54
|
+
des.return_type.should == 'a type'
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should say it's an instance type" do
|
58
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type'
|
59
|
+
des.should be_instance_member
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should say it's not an instance type" do
|
63
|
+
des = Caricature::MemberDescriptor.new 'a name', 'a type', false
|
64
|
+
des.should_not be_instance_member
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
describe "Caricature::ClrInterfaceDescriptor" do
|
70
|
+
|
71
|
+
before do
|
72
|
+
@des = Caricature::ClrInterfaceDescriptor.new ClrModels::IWeapon
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should have 2 instance members" do
|
76
|
+
@des.instance_members.size.should == 2
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should contain only instance members" do
|
80
|
+
result = true
|
81
|
+
@des.instance_members.each do |mem|
|
82
|
+
result = false unless mem.instance_member?
|
83
|
+
end
|
84
|
+
|
85
|
+
result.should be_true
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should have a damage instance member" do
|
89
|
+
@des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
|
90
|
+
end
|
91
|
+
|
92
|
+
it "should correctly identify indexers" do
|
93
|
+
des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
|
94
|
+
des.instance_members.select { |mem| mem.name == "__getitem__" }.should_not be_empty
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should correctly identify indexers" do
|
98
|
+
des = Caricature::ClrInterfaceDescriptor.new ClrModels::IHaveAnIndexer
|
99
|
+
des.instance_members.select { |mem| mem.name == "__setitem__" }.should_not be_empty
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
describe "Caricature::ClrClassDescriptor" do
|
105
|
+
|
106
|
+
before do
|
107
|
+
@des = Caricature::ClrClassDescriptor.new ClrModels::SwordWithStatics
|
108
|
+
end
|
109
|
+
|
110
|
+
it "should have 11 instance members" do
|
111
|
+
@des.instance_members.size.should == 11
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should have 5 static members" do
|
115
|
+
@des.class_members.size.should == 5
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should have a damage instance member" do
|
119
|
+
@des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should have a another method instance member" do
|
123
|
+
@des.instance_members.select { |mem| mem.name == "another_method" }.should_not be_empty
|
124
|
+
end
|
125
|
+
|
126
|
+
it "should correctly identify indexers" do
|
127
|
+
des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
|
128
|
+
des.instance_members.select { |mem| mem.name == "__getitem__" }.should_not be_empty
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should correctly identify indexers" do
|
132
|
+
des = Caricature::ClrClassDescriptor.new ClrModels::IndexerContained
|
133
|
+
des.instance_members.select { |mem| mem.name == "__setitem__" }.should_not be_empty
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
|
138
|
+
describe "Caricature::RubyObjectDescriptor" do
|
139
|
+
|
140
|
+
before do
|
141
|
+
@des = Caricature::RubyObjectDescriptor.new DaggerWithClassMembers
|
142
|
+
end
|
143
|
+
|
144
|
+
it "should have 2 instance members" do
|
145
|
+
@des.instance_members.size.should == 2
|
146
|
+
end
|
147
|
+
|
148
|
+
it "should have a damage instance member" do
|
149
|
+
@des.instance_members.select { |mem| mem.name == "damage" }.should_not be_empty
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should have 1 class member" do
|
153
|
+
@des.class_members.size.should == 1
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should have a class_name class member" do
|
157
|
+
@des.class_members.select { |mem| mem.name == "class_name" }.should_not be_empty
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
@@ -0,0 +1,301 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/../spec_helper"
|
2
|
+
|
3
|
+
describe "Caricature::Expectations" do
|
4
|
+
|
5
|
+
end
|
6
|
+
|
7
|
+
describe "Caricature::ExpectationBuilder" do
|
8
|
+
|
9
|
+
it "should create an expectation builder" do
|
10
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
11
|
+
builder.should_not be_nil
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "when using all defaults" do
|
15
|
+
|
16
|
+
before do
|
17
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
18
|
+
@expectation = builder.build
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should have the correct method_name" do
|
22
|
+
@expectation.method_name.should == :some_method
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should have empty args" do
|
26
|
+
@expectation.args.should be_empty
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should have no super call" do
|
30
|
+
@expectation.super.should == nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should have no error args" do
|
34
|
+
@expectation.error_args.should == nil
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should have no return_value" do
|
38
|
+
@expectation.return_value.should == nil
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should have no callback" do
|
42
|
+
@expectation.should_not be_has_callback
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "when specifying only arguments" do
|
48
|
+
|
49
|
+
before do
|
50
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
51
|
+
builder.with(1, 2, 3)
|
52
|
+
@expectation = builder.build
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should have the correct method_name" do
|
56
|
+
@expectation.method_name.should == :some_method
|
57
|
+
end
|
58
|
+
|
59
|
+
it "should have empty args" do
|
60
|
+
@expectation.args.should == [1,2,3]
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should have no super call" do
|
64
|
+
@expectation.super.should == nil
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should have no error args" do
|
68
|
+
@expectation.error_args.should == nil
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should have no return_value" do
|
72
|
+
@expectation.return_value.should == nil
|
73
|
+
end
|
74
|
+
|
75
|
+
it "should have no callback" do
|
76
|
+
@expectation.should_not be_has_callback
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
describe "when specifying only a block for the return value" do
|
82
|
+
|
83
|
+
before do
|
84
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
85
|
+
builder.return { 5 }
|
86
|
+
@expectation = builder.build
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should have the correct method_name" do
|
90
|
+
@expectation.method_name.should == :some_method
|
91
|
+
end
|
92
|
+
|
93
|
+
it "should have empty args" do
|
94
|
+
@expectation.args.should be_empty
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should have no super call" do
|
98
|
+
@expectation.super.should == nil
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should have no error args" do
|
102
|
+
@expectation.error_args.should == nil
|
103
|
+
end
|
104
|
+
|
105
|
+
it "should have a return callback" do
|
106
|
+
@expectation.return_callback.should_not be_nil
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should have the correct return_value" do
|
110
|
+
@expectation.return_callback.call.should == 5
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
describe "when specifying a return value" do
|
116
|
+
|
117
|
+
before do
|
118
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
119
|
+
builder.return 5
|
120
|
+
@expectation = builder.build
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should have the correct method_name" do
|
124
|
+
@expectation.method_name.should == :some_method
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should have empty args" do
|
128
|
+
@expectation.args.should be_empty
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should have no super call" do
|
132
|
+
@expectation.super.should == nil
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should have no error args" do
|
136
|
+
@expectation.error_args.should == nil
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should have the correct return_value" do
|
140
|
+
@expectation.return_value.should == 5
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
144
|
+
|
145
|
+
describe "when specifying a raise arguments" do
|
146
|
+
|
147
|
+
before do
|
148
|
+
@msg = "Hold on, that wasn't supposed to happen"
|
149
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
150
|
+
builder.raise @msg
|
151
|
+
@expectation = builder.build
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should have the correct method_name" do
|
155
|
+
@expectation.method_name.should == :some_method
|
156
|
+
end
|
157
|
+
|
158
|
+
it "should have empty args" do
|
159
|
+
@expectation.args.should be_empty
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should have no super call" do
|
163
|
+
@expectation.super.should == nil
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should have no error args" do
|
167
|
+
@expectation.error_args.should == [@msg]
|
168
|
+
end
|
169
|
+
|
170
|
+
it "should have the correct return_value" do
|
171
|
+
@expectation.return_value.should == nil
|
172
|
+
end
|
173
|
+
|
174
|
+
end
|
175
|
+
|
176
|
+
describe "when specifying a return value and telling you want a call to super before" do
|
177
|
+
|
178
|
+
before do
|
179
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
180
|
+
builder.return(5).super_before
|
181
|
+
@expectation = builder.build
|
182
|
+
end
|
183
|
+
|
184
|
+
it "should have the correct method_name" do
|
185
|
+
@expectation.method_name.should == :some_method
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should have empty args" do
|
189
|
+
@expectation.args.should be_empty
|
190
|
+
end
|
191
|
+
|
192
|
+
it "should have no super call" do
|
193
|
+
@expectation.super.should == :before
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should have no error args" do
|
197
|
+
@expectation.error_args.should == nil
|
198
|
+
end
|
199
|
+
|
200
|
+
it "should have the correct return_value" do
|
201
|
+
@expectation.return_value.should == 5
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
describe "when giving a block to the arguments constraint it should register it as a callback" do
|
207
|
+
|
208
|
+
before do
|
209
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
210
|
+
@counter, @args = 0, []
|
211
|
+
builder.with(5) do |*args|
|
212
|
+
@counter += 1
|
213
|
+
@args = args
|
214
|
+
end
|
215
|
+
@expectation = builder.build
|
216
|
+
end
|
217
|
+
|
218
|
+
it "should have a callback" do
|
219
|
+
@expectation.should be_has_callback
|
220
|
+
end
|
221
|
+
|
222
|
+
it "should call the callback when the expectation is called" do
|
223
|
+
@expectation.execute
|
224
|
+
@counter.should == 1
|
225
|
+
end
|
226
|
+
|
227
|
+
it "should pass on the correct arguments" do
|
228
|
+
@expectation.execute 1, 2, 3
|
229
|
+
@args.should == [1, 2, 3]
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
describe "when giving a block to a super method it should register it" do
|
234
|
+
|
235
|
+
before do
|
236
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
237
|
+
@counter = 0
|
238
|
+
builder.super_after do
|
239
|
+
@counter += 1
|
240
|
+
end
|
241
|
+
@expectation = builder.build
|
242
|
+
end
|
243
|
+
|
244
|
+
it "should should have a callback" do
|
245
|
+
@expectation.block.should_not be_nil
|
246
|
+
end
|
247
|
+
|
248
|
+
it "should pass on the correct callback" do
|
249
|
+
@expectation.block.call
|
250
|
+
@counter.should == 1
|
251
|
+
end
|
252
|
+
|
253
|
+
end
|
254
|
+
|
255
|
+
describe "when given arguments to the block pass method" do
|
256
|
+
|
257
|
+
before do
|
258
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
259
|
+
builder.pass_block(1,2,3)
|
260
|
+
@expectation = builder.build
|
261
|
+
end
|
262
|
+
|
263
|
+
it "should not have a block callback" do
|
264
|
+
@expectation.should_not be_has_block_callback
|
265
|
+
end
|
266
|
+
|
267
|
+
it "should should execute the block with the provided arguments when executed" do
|
268
|
+
ags = []
|
269
|
+
@expectation.execute do |*args|
|
270
|
+
ags = args
|
271
|
+
end
|
272
|
+
ags.should == [1,2,3]
|
273
|
+
end
|
274
|
+
|
275
|
+
end
|
276
|
+
|
277
|
+
describe "when given arguments to the block pass method" do
|
278
|
+
|
279
|
+
before do
|
280
|
+
builder = Caricature::ExpectationBuilder.new :some_method
|
281
|
+
builder.pass_block do
|
282
|
+
[1,3,4]
|
283
|
+
end
|
284
|
+
@expectation = builder.build
|
285
|
+
end
|
286
|
+
|
287
|
+
it "should have a block callback" do
|
288
|
+
@expectation.should be_has_block_callback
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should execute the block with the result of the provided callback when executed" do
|
292
|
+
ags = []
|
293
|
+
@expectation.execute do |*args|
|
294
|
+
ags = args
|
295
|
+
end
|
296
|
+
ags.should == [1,3,4]
|
297
|
+
end
|
298
|
+
|
299
|
+
end
|
300
|
+
|
301
|
+
end
|