flexmock 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile.lock +9 -9
- data/Rakefile +3 -1
- data/lib/flexmock.rb +1 -1
- data/lib/flexmock/argument_matchers.rb +1 -1
- data/lib/flexmock/argument_types.rb +1 -2
- data/lib/flexmock/base.rb +2 -1
- data/lib/flexmock/call_record.rb +30 -0
- data/lib/flexmock/call_validator.rb +68 -0
- data/lib/flexmock/composite_expectation.rb +56 -0
- data/lib/flexmock/core.rb +30 -64
- data/lib/flexmock/core_class_methods.rb +1 -1
- data/lib/flexmock/default_framework_adapter.rb +1 -1
- data/lib/flexmock/deprecated_methods.rb +8 -3
- data/lib/flexmock/errors.rb +1 -1
- data/lib/flexmock/expectation.rb +7 -84
- data/lib/flexmock/expectation_builder.rb +133 -0
- data/lib/flexmock/expectation_director.rb +6 -4
- data/lib/flexmock/expectation_recorder.rb +42 -0
- data/lib/flexmock/extensions/active_record_model.rb +109 -0
- data/lib/flexmock/mock_builder.rb +139 -0
- data/lib/flexmock/mock_container.rb +13 -214
- data/lib/flexmock/noop.rb +1 -1
- data/lib/flexmock/ordering.rb +1 -2
- data/lib/flexmock/partial_mock.rb +95 -57
- data/lib/flexmock/rails.rb +1 -1
- data/lib/flexmock/recorder.rb +4 -3
- data/lib/flexmock/rspec.rb +1 -1
- data/lib/flexmock/rspec_spy_matcher.rb +4 -0
- data/lib/flexmock/spy_describers.rb +22 -5
- data/lib/flexmock/test_unit.rb +2 -40
- data/lib/flexmock/test_unit_integration.rb +4 -4
- data/lib/flexmock/test_unit_testcase_extensions.rb +49 -0
- data/lib/flexmock/undefined.rb +1 -1
- data/lib/flexmock/validators.rb +18 -12
- data/lib/flexmock/version.rb +1 -1
- data/test/based_partials_test.rb +1 -1
- data/test/container_methods_test.rb +1 -1
- data/test/default_framework_adapter_test.rb +1 -1
- data/test/demeter_mocking_test.rb +52 -2
- data/test/deprecated_methods_test.rb +1 -1
- data/test/examples_from_readme_test.rb +1 -1
- data/test/expectation_description_test.rb +1 -1
- data/test/extended_should_receive_test.rb +1 -1
- data/test/mock_builder_test.rb +68 -0
- data/test/naming_test.rb +1 -1
- data/test/new_instances_test.rb +1 -1
- data/test/partial_mock_test.rb +23 -6
- data/test/record_mode_test.rb +1 -1
- data/test/rspec_integration/integration_spec.rb +1 -1
- data/test/samples_test.rb +1 -2
- data/test/should_ignore_missing_test.rb +1 -1
- data/test/should_receive_test.rb +1 -1
- data/test/test_setup.rb +17 -0
- data/test/test_unit_integration/auto_test_unit_test.rb +1 -1
- data/test/tu_integration_test.rb +1 -1
- data/test/undefined_test.rb +1 -1
- metadata +52 -52
- data/TAGS +0 -1056
- data/lib/flexmock/composite.rb +0 -10
- data/lib/flexmock/rails/view_mocking.rb +0 -144
- data/test/rails_view_stub_test.rb +0 -145
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'test/test_setup'
|
2
|
+
|
3
|
+
class MockBuilderTest < Test::Unit::TestCase
|
4
|
+
include FlexMock::TestCase
|
5
|
+
|
6
|
+
def assert_method_name(name)
|
7
|
+
assert_match(FlexMock::ExpectationBuilder::METHOD_NAME_RE, name)
|
8
|
+
end
|
9
|
+
|
10
|
+
def assert_not_method_name(name)
|
11
|
+
refute_match(FlexMock::ExpectationBuilder::METHOD_NAME_RE, name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_valid_method_names
|
15
|
+
assert_method_name "foo"
|
16
|
+
assert_method_name "FooBar"
|
17
|
+
assert_method_name "_foo"
|
18
|
+
assert_method_name "__foo"
|
19
|
+
assert_method_name "___foo"
|
20
|
+
assert_method_name "_"
|
21
|
+
assert_method_name "foo_bar"
|
22
|
+
assert_method_name "foo__bar"
|
23
|
+
assert_method_name "foo_bar_"
|
24
|
+
assert_method_name "foo12"
|
25
|
+
assert_method_name "foo_bar_12"
|
26
|
+
assert_method_name "foo?"
|
27
|
+
assert_method_name "foo!"
|
28
|
+
assert_method_name "foo="
|
29
|
+
assert_method_name "+"
|
30
|
+
assert_method_name "-"
|
31
|
+
assert_method_name "*"
|
32
|
+
assert_method_name "/"
|
33
|
+
assert_method_name "&"
|
34
|
+
assert_method_name "|"
|
35
|
+
assert_method_name "^"
|
36
|
+
assert_method_name "~"
|
37
|
+
assert_method_name "=~"
|
38
|
+
assert_method_name "!~"
|
39
|
+
assert_method_name "`"
|
40
|
+
assert_method_name "!"
|
41
|
+
assert_method_name "**"
|
42
|
+
assert_method_name "+@"
|
43
|
+
assert_method_name "-@"
|
44
|
+
assert_method_name "=="
|
45
|
+
assert_method_name "!="
|
46
|
+
assert_method_name "==="
|
47
|
+
assert_method_name "<="
|
48
|
+
assert_method_name ">="
|
49
|
+
assert_method_name "<"
|
50
|
+
assert_method_name ">"
|
51
|
+
assert_method_name "<=>"
|
52
|
+
assert_method_name "[]"
|
53
|
+
assert_method_name "[]="
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_invalid_method_names
|
57
|
+
assert_not_method_name ""
|
58
|
+
assert_not_method_name "1"
|
59
|
+
assert_not_method_name "1foo"
|
60
|
+
assert_not_method_name "foo!!"
|
61
|
+
assert_not_method_name "foo!?"
|
62
|
+
assert_not_method_name "foo?="
|
63
|
+
assert_not_method_name "foo@"
|
64
|
+
assert_not_method_name "++"
|
65
|
+
assert_not_method_name "!!"
|
66
|
+
assert_not_method_name "~="
|
67
|
+
end
|
68
|
+
end
|
data/test/naming_test.rb
CHANGED
data/test/new_instances_test.rb
CHANGED
data/test/partial_mock_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
#---
|
4
|
-
# Copyright 2003-
|
4
|
+
# Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
|
5
5
|
# All rights reserved.
|
6
6
|
|
7
7
|
# Permission is granted for use, copying, modification, distribution,
|
@@ -41,9 +41,25 @@ class TestStubbing < Test::Unit::TestCase
|
|
41
41
|
assert ! m.instance_variables.include?(:@flexmock_proxy.flexmock_as_name)
|
42
42
|
end
|
43
43
|
|
44
|
-
def
|
44
|
+
def test_forcibly_removing_proxy_causes_failure
|
45
45
|
obj = Object.new
|
46
|
-
flexmock(obj)
|
46
|
+
flexmock(obj)
|
47
|
+
obj.instance_eval { @flexmock_proxy = nil }
|
48
|
+
assert_raises(RuntimeError, /missing.*proxy/i) do
|
49
|
+
obj.should_receive(:hi).and_return(:stub_hi)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_stub_command_add_behavior_to_arbitrary_objects_via_flexmock
|
54
|
+
obj = Object.new
|
55
|
+
flexmock(obj).should_receive(:hi).and_return(:stub_hi)
|
56
|
+
assert_equal :stub_hi, obj.hi
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_stub_command_add_behavior_to_arbitrary_objects_post_flexmock
|
60
|
+
obj = Object.new
|
61
|
+
flexmock(obj)
|
62
|
+
obj.should_receive(:hi).and_return(:stub_hi)
|
47
63
|
assert_equal :stub_hi, obj.hi
|
48
64
|
end
|
49
65
|
|
@@ -64,7 +80,9 @@ class TestStubbing < Test::Unit::TestCase
|
|
64
80
|
|
65
81
|
def test_multiple_stubs_on_the_same_object_reuse_the_same_partial_mock
|
66
82
|
obj = Object.new
|
67
|
-
|
83
|
+
a = flexmock(obj)
|
84
|
+
b = flexmock(obj)
|
85
|
+
assert_equal a.object_id, b.object_id
|
68
86
|
end
|
69
87
|
|
70
88
|
def test_stubbed_methods_can_invoke_original_behavior_directly
|
@@ -189,8 +207,7 @@ class TestStubbing < Test::Unit::TestCase
|
|
189
207
|
assert out.is_a?(IO)
|
190
208
|
out.puts "XYZ"
|
191
209
|
end
|
192
|
-
text =
|
193
|
-
File.open("dummy.txt") { |f| text = f.read }
|
210
|
+
text = File.open("dummy.txt") { |f| f.read }
|
194
211
|
assert_equal "XYZ\n", text
|
195
212
|
ensure
|
196
213
|
FileUtils.rm_f("dummy.txt")
|
data/test/record_mode_test.rb
CHANGED
data/test/samples_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
#---
|
4
|
-
# Copyright 2003-
|
4
|
+
# Copyright 2003-2013 by Jim Weirich (jim.weirich@gmail.com).
|
5
5
|
# All rights reserved.
|
6
6
|
|
7
7
|
# Permission is granted for use, copying, modification, distribution,
|
@@ -126,7 +126,6 @@ class TestDefaults < Test::Unit::TestCase
|
|
126
126
|
|
127
127
|
def test_something_where_bark_must_be_called_once
|
128
128
|
@mock_dog.should_receive(:bark => "bow wow").once
|
129
|
-
|
130
129
|
assert_equal "bow wow", @mock_dog.bark
|
131
130
|
assert_equal :a_tail, @mock_dog.tail
|
132
131
|
end
|
data/test/should_receive_test.rb
CHANGED
data/test/test_setup.rb
CHANGED
@@ -66,10 +66,27 @@ class FlexMock
|
|
66
66
|
ex
|
67
67
|
end
|
68
68
|
|
69
|
+
unless defined?(refute_match)
|
70
|
+
def refute_match(*args)
|
71
|
+
assert_no_match(*args)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
69
75
|
def assert_with_block(msg=nil)
|
70
76
|
unless yield
|
71
77
|
assert(false, msg || "Expected block to yield true")
|
72
78
|
end
|
73
79
|
end
|
80
|
+
|
81
|
+
def pending(msg="")
|
82
|
+
state = "PASSING"
|
83
|
+
begin
|
84
|
+
yield
|
85
|
+
rescue Exception => _
|
86
|
+
state = "FAILING"
|
87
|
+
end
|
88
|
+
where = caller.first.split(/:in/).first
|
89
|
+
puts "\n#{state} PENDING TEST (#{msg}) #{where}"
|
90
|
+
end
|
74
91
|
end
|
75
92
|
end
|
data/test/tu_integration_test.rb
CHANGED
data/test/undefined_test.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flexmock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
5
|
-
prerelease:
|
4
|
+
version: 1.3.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jim Weirich
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-01-20 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
13
|
+
description: "\n FlexMock is a extremely simple mock object class compatible\n
|
15
14
|
\ with the Test::Unit framework. Although the FlexMock's\n interface is
|
16
15
|
simple, it is very flexible.\n "
|
17
16
|
email: jim.weirich@gmail.com
|
@@ -55,29 +54,65 @@ files:
|
|
55
54
|
- Gemfile.lock
|
56
55
|
- README.md
|
57
56
|
- Rakefile
|
58
|
-
-
|
57
|
+
- doc/GoogleExample.rdoc
|
58
|
+
- doc/examples/rspec_examples_spec.rdoc
|
59
|
+
- doc/examples/test_unit_examples_test.rdoc
|
60
|
+
- doc/index.rdoc
|
61
|
+
- doc/releases/flexmock-0.4.0.rdoc
|
62
|
+
- doc/releases/flexmock-0.4.1.rdoc
|
63
|
+
- doc/releases/flexmock-0.4.2.rdoc
|
64
|
+
- doc/releases/flexmock-0.4.3.rdoc
|
65
|
+
- doc/releases/flexmock-0.5.0.rdoc
|
66
|
+
- doc/releases/flexmock-0.5.1.rdoc
|
67
|
+
- doc/releases/flexmock-0.6.0.rdoc
|
68
|
+
- doc/releases/flexmock-0.6.1.rdoc
|
69
|
+
- doc/releases/flexmock-0.6.2.rdoc
|
70
|
+
- doc/releases/flexmock-0.6.3.rdoc
|
71
|
+
- doc/releases/flexmock-0.6.4.rdoc
|
72
|
+
- doc/releases/flexmock-0.7.0.rdoc
|
73
|
+
- doc/releases/flexmock-0.7.1.rdoc
|
74
|
+
- doc/releases/flexmock-0.8.0.rdoc
|
75
|
+
- doc/releases/flexmock-0.8.2.rdoc
|
76
|
+
- doc/releases/flexmock-0.8.3.rdoc
|
77
|
+
- doc/releases/flexmock-0.8.4.rdoc
|
78
|
+
- doc/releases/flexmock-0.8.5.rdoc
|
79
|
+
- doc/releases/flexmock-0.9.0.rdoc
|
80
|
+
- doc/releases/flexmock-1.0.0.rdoc
|
81
|
+
- doc/releases/flexmock-1.0.3.rdoc
|
82
|
+
- doc/releases/flexmock-1.0.4.rdoc
|
83
|
+
- doc/releases/flexmock-1.1.0.rdoc
|
84
|
+
- doc/releases/flexmock-1.2.0.rdoc
|
85
|
+
- doc/releases/flexmock-1.3.0.rdoc
|
86
|
+
- doc/releases/flexmock-1.3.1.rdoc
|
87
|
+
- flexmock.blurb
|
88
|
+
- install.rb
|
59
89
|
- lib/flexmock.rb
|
60
90
|
- lib/flexmock/argument_matchers.rb
|
61
91
|
- lib/flexmock/argument_matching.rb
|
62
92
|
- lib/flexmock/argument_types.rb
|
63
93
|
- lib/flexmock/base.rb
|
94
|
+
- lib/flexmock/call_record.rb
|
95
|
+
- lib/flexmock/call_validator.rb
|
64
96
|
- lib/flexmock/class_extensions.rb
|
65
|
-
- lib/flexmock/
|
97
|
+
- lib/flexmock/composite_expectation.rb
|
66
98
|
- lib/flexmock/core.rb
|
67
99
|
- lib/flexmock/core_class_methods.rb
|
68
100
|
- lib/flexmock/default_framework_adapter.rb
|
69
101
|
- lib/flexmock/deprecated_methods.rb
|
70
102
|
- lib/flexmock/errors.rb
|
71
103
|
- lib/flexmock/expectation.rb
|
104
|
+
- lib/flexmock/expectation_builder.rb
|
72
105
|
- lib/flexmock/expectation_director.rb
|
106
|
+
- lib/flexmock/expectation_recorder.rb
|
73
107
|
- lib/flexmock/explicit_needed.rb
|
108
|
+
- lib/flexmock/extensions/active_record_model.rb
|
109
|
+
- lib/flexmock/mock_builder.rb
|
74
110
|
- lib/flexmock/mock_container.rb
|
75
111
|
- lib/flexmock/noop.rb
|
76
112
|
- lib/flexmock/object_extensions.rb
|
77
113
|
- lib/flexmock/ordering.rb
|
78
114
|
- lib/flexmock/partial_mock.rb
|
79
115
|
- lib/flexmock/rails.rb
|
80
|
-
- lib/flexmock/rails/view_mocking.rb
|
81
116
|
- lib/flexmock/recorder.rb
|
82
117
|
- lib/flexmock/rspec.rb
|
83
118
|
- lib/flexmock/rspec/configure.rb
|
@@ -87,6 +122,7 @@ files:
|
|
87
122
|
- lib/flexmock/test_unit.rb
|
88
123
|
- lib/flexmock/test_unit_assert_spy_called.rb
|
89
124
|
- lib/flexmock/test_unit_integration.rb
|
125
|
+
- lib/flexmock/test_unit_testcase_extensions.rb
|
90
126
|
- lib/flexmock/undefined.rb
|
91
127
|
- lib/flexmock/validators.rb
|
92
128
|
- lib/flexmock/version.rb
|
@@ -102,11 +138,11 @@ files:
|
|
102
138
|
- test/expectation_description_test.rb
|
103
139
|
- test/extended_should_receive_test.rb
|
104
140
|
- test/flexmodel_test.rb
|
141
|
+
- test/mock_builder_test.rb
|
105
142
|
- test/naming_test.rb
|
106
143
|
- test/new_instances_test.rb
|
107
144
|
- test/object_extensions_test.rb
|
108
145
|
- test/partial_mock_test.rb
|
109
|
-
- test/rails_view_stub_test.rb
|
110
146
|
- test/record_mode_test.rb
|
111
147
|
- test/redirect_error.rb
|
112
148
|
- test/rspec_integration/integration_spec.rb
|
@@ -122,68 +158,32 @@ files:
|
|
122
158
|
- test/test_unit_integration/minitest_teardown_test.rb
|
123
159
|
- test/tu_integration_test.rb
|
124
160
|
- test/undefined_test.rb
|
125
|
-
- flexmock.blurb
|
126
|
-
- install.rb
|
127
|
-
- doc/index.rdoc
|
128
|
-
- doc/GoogleExample.rdoc
|
129
|
-
- doc/releases/flexmock-0.4.0.rdoc
|
130
|
-
- doc/releases/flexmock-0.4.1.rdoc
|
131
|
-
- doc/releases/flexmock-0.4.2.rdoc
|
132
|
-
- doc/releases/flexmock-0.4.3.rdoc
|
133
|
-
- doc/releases/flexmock-0.5.0.rdoc
|
134
|
-
- doc/releases/flexmock-0.5.1.rdoc
|
135
|
-
- doc/releases/flexmock-0.6.0.rdoc
|
136
|
-
- doc/releases/flexmock-0.6.1.rdoc
|
137
|
-
- doc/releases/flexmock-0.6.2.rdoc
|
138
|
-
- doc/releases/flexmock-0.6.3.rdoc
|
139
|
-
- doc/releases/flexmock-0.6.4.rdoc
|
140
|
-
- doc/releases/flexmock-0.7.0.rdoc
|
141
|
-
- doc/releases/flexmock-0.7.1.rdoc
|
142
|
-
- doc/releases/flexmock-0.8.0.rdoc
|
143
|
-
- doc/releases/flexmock-0.8.2.rdoc
|
144
|
-
- doc/releases/flexmock-0.8.3.rdoc
|
145
|
-
- doc/releases/flexmock-0.8.4.rdoc
|
146
|
-
- doc/releases/flexmock-0.8.5.rdoc
|
147
|
-
- doc/releases/flexmock-0.9.0.rdoc
|
148
|
-
- doc/releases/flexmock-1.0.0.rdoc
|
149
|
-
- doc/releases/flexmock-1.0.3.rdoc
|
150
|
-
- doc/releases/flexmock-1.0.4.rdoc
|
151
|
-
- doc/releases/flexmock-1.1.0.rdoc
|
152
|
-
- doc/releases/flexmock-1.2.0.rdoc
|
153
|
-
- doc/releases/flexmock-1.3.0.rdoc
|
154
|
-
- doc/releases/flexmock-1.3.1.rdoc
|
155
|
-
- doc/examples/rspec_examples_spec.rdoc
|
156
|
-
- doc/examples/test_unit_examples_test.rdoc
|
157
161
|
homepage: https://github.com/jimweirich/flexmock
|
158
162
|
licenses: []
|
163
|
+
metadata: {}
|
159
164
|
post_install_message:
|
160
165
|
rdoc_options:
|
161
|
-
- --title
|
166
|
+
- "--title"
|
162
167
|
- FlexMock
|
163
|
-
- --main
|
168
|
+
- "--main"
|
164
169
|
- README.rdoc
|
165
|
-
- --line-numbers
|
170
|
+
- "--line-numbers"
|
166
171
|
require_paths:
|
167
172
|
- lib
|
168
173
|
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
-
none: false
|
170
174
|
requirements:
|
171
|
-
- -
|
175
|
+
- - ">="
|
172
176
|
- !ruby/object:Gem::Version
|
173
177
|
version: '0'
|
174
|
-
segments:
|
175
|
-
- 0
|
176
|
-
hash: 1970361257981767370
|
177
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
-
none: false
|
179
179
|
requirements:
|
180
|
-
- -
|
180
|
+
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
182
|
version: '0'
|
183
183
|
requirements: []
|
184
184
|
rubyforge_project:
|
185
|
-
rubygems_version:
|
185
|
+
rubygems_version: 2.2.0
|
186
186
|
signing_key:
|
187
|
-
specification_version:
|
187
|
+
specification_version: 4
|
188
188
|
summary: Simple and Flexible Mock Objects for Testing
|
189
189
|
test_files: []
|