active_mocker 1.1.2 → 1.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -4
- data/lib/active_mocker/active_record.rb +2 -0
- data/lib/active_mocker/active_record/unknown_class_method.rb +1 -1
- data/lib/active_mocker/active_record/unknown_module.rb +25 -0
- data/lib/active_mocker/model_reader.rb +16 -3
- data/lib/active_mocker/version.rb +1 -1
- data/spec/lib/active_mocker/base_spec.rb +1 -1
- data/spec/lib/model.rb +2 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: addb986f00f2c8a59ad022a22a1617214d46b058
|
4
|
+
data.tar.gz: 9e77573e2e57c8bb14273c4715b2fd642e3022da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e40f73589ec2ea036b515fa33953515235be712e8793b90e3407387a0961a12fadacf81da5174b69c4709f715237f8c4e51fdf5a508892af31b2a4d63d445941
|
7
|
+
data.tar.gz: a64603e11da45d5df1f6f86c1b95c37dd7274682f2fc8edce0d0425da415d7e0be837c59cdf664465a8eca69f9675cf59cb536b63f7a9681bfb84adbbb5f3693
|
data/README.md
CHANGED
@@ -77,7 +77,7 @@ Or install it yourself as:
|
|
77
77
|
person_mock.first_name
|
78
78
|
=> "Dustin"
|
79
79
|
|
80
|
-
### When schema.rb changes the mock fails
|
80
|
+
### When schema.rb changes, the mock fails
|
81
81
|
|
82
82
|
#db/schema.rb
|
83
83
|
|
@@ -117,7 +117,7 @@ Or install it yourself as:
|
|
117
117
|
"Now implemented"
|
118
118
|
end
|
119
119
|
|
120
|
-
### When the model changes the mock fails
|
120
|
+
### When the model changes, the mock fails
|
121
121
|
|
122
122
|
#app/models/person.rb
|
123
123
|
|
@@ -200,7 +200,7 @@ ActiveHash is a simple base class that allows you to use a ruby hash as a readon
|
|
200
200
|
=> 0
|
201
201
|
|
202
202
|
|
203
|
-
|
203
|
+
#### ::find_by
|
204
204
|
|
205
205
|
person = PersonMock.create(first_name: 'Dustin')
|
206
206
|
|
@@ -210,7 +210,8 @@ ActiveHash is a simple base class that allows you to use a ruby hash as a readon
|
|
210
210
|
|
211
211
|
### Known Limitations
|
212
212
|
|
213
|
-
**::mock** model names and table names must follow the default ActiveRecord naming pattern.
|
213
|
+
* **::mock** model names and table names must follow the default ActiveRecord naming pattern.
|
214
|
+
* Included/extended modules will not be loaded unless they are required explicitly.
|
214
215
|
|
215
216
|
## Contributing
|
216
217
|
|
@@ -2,6 +2,7 @@ $:.unshift File.expand_path('../../', __FILE__)
|
|
2
2
|
require 'active_mocker/active_record/scope'
|
3
3
|
require 'active_mocker/active_record/relationships'
|
4
4
|
require 'active_mocker/active_record/unknown_class_method'
|
5
|
+
require 'active_mocker/active_record/unknown_module'
|
5
6
|
|
6
7
|
module ActiveMocker
|
7
8
|
module ActiveRecord
|
@@ -9,6 +10,7 @@ module ActiveMocker
|
|
9
10
|
extend Scope
|
10
11
|
extend Relationships
|
11
12
|
extend UnknownClassMethod
|
13
|
+
extend UnknownModule
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
@@ -3,7 +3,7 @@ module ActiveMocker
|
|
3
3
|
module UnknownClassMethod
|
4
4
|
|
5
5
|
def method_missing(meth, *args)
|
6
|
-
Logger_.debug "ActiveMocker
|
6
|
+
Logger_.debug "ActiveMocker :: #{meth} called from class #{self.name} is unknown and will not be available in mock."
|
7
7
|
end
|
8
8
|
|
9
9
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ActiveMocker
|
2
|
+
|
3
|
+
module UnknownModule
|
4
|
+
|
5
|
+
def include(_module)
|
6
|
+
begin
|
7
|
+
super _module
|
8
|
+
rescue => e
|
9
|
+
Logger_.debug e
|
10
|
+
Logger_.debug "ActiveMocker :: Can't include module #{_module} from class #{self.name}.\n #{caller}"
|
11
|
+
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def extend(_module)
|
16
|
+
begin
|
17
|
+
super _module
|
18
|
+
rescue
|
19
|
+
Logger_.debug "ActiveMocker :: Can't extend module #{_module} from class #{self.name}..\n #{caller}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -20,9 +20,22 @@ module ActiveMocker
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def eval_file
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
failure = true
|
24
|
+
while failure
|
25
|
+
begin
|
26
|
+
m = Module.new
|
27
|
+
m.module_eval(read_file)
|
28
|
+
rescue NameError => e
|
29
|
+
result = e.to_s.scan /::(\w*)$/ # gets the Constant name from error
|
30
|
+
const_name = result.flatten.first
|
31
|
+
Logger_.debug "ActiveMocker :: Can't can't find Constant #{const_name} from class #{model_name}..\n #{caller}"
|
32
|
+
Object.const_set(const_name,const_name)
|
33
|
+
next
|
34
|
+
end
|
35
|
+
failure = false
|
36
|
+
model = m.const_get m.constants.first
|
37
|
+
end
|
38
|
+
model
|
26
39
|
end
|
27
40
|
|
28
41
|
def read_file
|
data/spec/lib/model.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_mocker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dustin Zeisler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/active_mocker/active_record/schema.rb
|
121
121
|
- lib/active_mocker/active_record/scope.rb
|
122
122
|
- lib/active_mocker/active_record/unknown_class_method.rb
|
123
|
+
- lib/active_mocker/active_record/unknown_module.rb
|
123
124
|
- lib/active_mocker/base.rb
|
124
125
|
- lib/active_mocker/config.rb
|
125
126
|
- lib/active_mocker/field.rb
|