lazy_mock 1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +39 -0
- data/lib/lazy_mock.rb +5 -0
- metadata +60 -0
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Sage http://sage.com/
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
= LazyMocks
|
2
|
+
|
3
|
+
== Rationale
|
4
|
+
|
5
|
+
In Rspec, using a mock object, the moer functionality you add, the more complaints you get about unexpected messages.
|
6
|
+
|
7
|
+
Sometimes you just want an object that responds to anything you throw at it, and just stub specifc behavior.
|
8
|
+
|
9
|
+
Enter LazyMocks.
|
10
|
+
|
11
|
+
== Usage
|
12
|
+
|
13
|
+
Every method returns a new instance of LazyMock.
|
14
|
+
|
15
|
+
my_mock = LazyMock.new
|
16
|
+
my_mock.some_method_that_doesnt_exist
|
17
|
+
=> #<MyMock>
|
18
|
+
|
19
|
+
It responds to everything.
|
20
|
+
|
21
|
+
my_mock = LazyMock.new
|
22
|
+
my_mock.respond_to?(:huh?)
|
23
|
+
=> true
|
24
|
+
|
25
|
+
Then you can stub what you want to.
|
26
|
+
|
27
|
+
my_mock = LazyMock.new
|
28
|
+
my_mock.stub(:something).and_return('foo')
|
29
|
+
|
30
|
+
Because it returns an instance of iteself, any code paths (the first traversed) will pass:
|
31
|
+
|
32
|
+
my_mock = LazyMock.new
|
33
|
+
if my_mock.thing.other_method.another_method
|
34
|
+
return "Test" if my_mock.has_some_method?
|
35
|
+
else
|
36
|
+
#not getting here..
|
37
|
+
end
|
38
|
+
|
39
|
+
This means that for paths in your specs which you don't care about (because you're testing one specific part) won't break when you add new functionality as you flesh out your implementation.
|
data/lib/lazy_mock.rb
ADDED
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lazy_mock
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '1.0'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- SageOne
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-26 00:00:00.000000000 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: &80080220 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *80080220
|
26
|
+
description: Lazy Mocks just respond to anything you throw at them.
|
27
|
+
email: sageone@sage.com
|
28
|
+
executables: []
|
29
|
+
extensions: []
|
30
|
+
extra_rdoc_files: []
|
31
|
+
files:
|
32
|
+
- lib/lazy_mock.rb
|
33
|
+
- README.rdoc
|
34
|
+
- MIT-LICENSE
|
35
|
+
has_rdoc: true
|
36
|
+
homepage: http://github.com/Sage/lazy_mocks
|
37
|
+
licenses: []
|
38
|
+
post_install_message:
|
39
|
+
rdoc_options: []
|
40
|
+
require_paths:
|
41
|
+
- lib
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
none: false
|
44
|
+
requirements:
|
45
|
+
- - ! '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.9.2
|
48
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.3.6
|
54
|
+
requirements: []
|
55
|
+
rubyforge_project:
|
56
|
+
rubygems_version: 1.6.2
|
57
|
+
signing_key:
|
58
|
+
specification_version: 3
|
59
|
+
summary: Lazy Mocks - They respond to everything man!!
|
60
|
+
test_files: []
|