arbitrary_mock 0.0.3 → 0.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/lib/arbitrary_mock/base.rb +8 -1
- data/lib/arbitrary_mock/version.rb +1 -1
- data/spec/arbitrary_mock/base_spec.rb +11 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0289b1653e5dc1b79d6ce6a50405fb70b746f29a
|
4
|
+
data.tar.gz: 1d6981a806f63a0e172f2a49d7a0b2f0dc98e7e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc343cc640841f75730406f0e85dc5f8f63e0039999628ebf133897ee1c08b577914231201410edfa8f3f7a70a563044db20edc7542062721f5a4ec648f52fc2
|
7
|
+
data.tar.gz: 72cc8bcfc4f0e7dcfac36181b167e89a6e9d0db4498c5f025991d3d3f6f4c0227448dd6db1494391e89f680dfe437c61a55e4cf3179d15869779583cbfeec9fa
|
data/README.md
CHANGED
data/lib/arbitrary_mock/base.rb
CHANGED
@@ -7,12 +7,19 @@ module ArbitraryMock
|
|
7
7
|
|
8
8
|
def method_missing(*args)
|
9
9
|
method_name = args.first
|
10
|
+
arg_position = 1
|
11
|
+
|
12
|
+
if method_name == :try
|
13
|
+
method_name = args[1]
|
14
|
+
arg_position += 1
|
15
|
+
end
|
16
|
+
|
10
17
|
setter_method_match = /(.*)=$/.match(method_name)
|
11
18
|
|
12
19
|
return @property_hash[method_name] if setter_method_match.nil?
|
13
20
|
|
14
21
|
setter_method = setter_method_match.captures.first.to_sym
|
15
|
-
@property_hash[setter_method] = args[
|
22
|
+
@property_hash[setter_method] = args[arg_position]
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
@@ -1,12 +1,14 @@
|
|
1
1
|
require 'arbitrary_mock/base'
|
2
2
|
|
3
3
|
describe ArbitraryMock::Base do
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
describe '#initialize' do
|
5
|
+
it 'allows you to set arbitrary attributes' do
|
6
|
+
mock = ArbitraryMock::Base.new(foo: 'bar')
|
7
|
+
expect(mock.foo).to match 'bar'
|
8
|
+
end
|
7
9
|
end
|
8
10
|
|
9
|
-
it 'allows you to set
|
11
|
+
it 'allows you to set attributes as setters' do
|
10
12
|
mock = ArbitraryMock::Base.new
|
11
13
|
mock.foo = 'bar'
|
12
14
|
expect(mock.foo).to match 'bar'
|
@@ -22,4 +24,9 @@ describe ArbitraryMock::Base do
|
|
22
24
|
MyClass ||= ArbitraryMock::Base
|
23
25
|
MyClass.new(foo: 'bar').foo.should == 'bar'
|
24
26
|
end
|
27
|
+
|
28
|
+
it 'allows you to "try" a method' do
|
29
|
+
MyClass ||= ArbitraryMock::Base
|
30
|
+
MyClass.new(foo: 'bar').try(:foo).should == 'bar'
|
31
|
+
end
|
25
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arbitrary_mock
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.1.0.pre
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert White
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -86,9 +86,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
86
86
|
version: '0'
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- - '
|
89
|
+
- - '>'
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version:
|
91
|
+
version: 1.3.1
|
92
92
|
requirements: []
|
93
93
|
rubyforge_project:
|
94
94
|
rubygems_version: 2.0.3
|