active_mocker 1.1.22 → 1.1.23
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.
- checksums.yaml +4 -4
- data/README.md +7 -8
- data/lib/active_hash/init.rb +4 -0
- data/lib/active_mocker/version.rb +1 -1
- data/spec/lib/active_mocker/base_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35394fa054b9991f64200432c22300c0338b5794
|
4
|
+
data.tar.gz: 439c5e2cb084947588d5e9be24e1adef3169103b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b8116e203aefae67690da7552b188fbe3d36b9f8d40a4fa88a1a2deccacfaa7dcad891769795b8b61336c840be80fe819eb8540341c8ed5f9d03c6e8246f1455
|
7
|
+
data.tar.gz: d53d2aaec5da61ecc346ddae968166016543bbf91d431e53d7f665a2814cac4c039f066cc1a7d4803d39fba33586e25249b821b8bec07acdde316978f3728645
|
data/README.md
CHANGED
@@ -164,19 +164,18 @@ Or install it yourself as:
|
|
164
164
|
|
165
165
|
**Instance methods**
|
166
166
|
|
167
|
-
* attributes
|
167
|
+
* attributes
|
168
168
|
* update
|
169
169
|
* save
|
170
170
|
* write_attribute - (private)
|
171
171
|
* read_attribute - (private)
|
172
172
|
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
*
|
177
|
-
*
|
178
|
-
*
|
179
|
-
* Enumerable methods
|
173
|
+
**Collection Associations**
|
174
|
+
|
175
|
+
* last/first
|
176
|
+
* sum(attribute)
|
177
|
+
* <<
|
178
|
+
* Enumerable methods
|
180
179
|
|
181
180
|
### Known Limitations
|
182
181
|
|
data/lib/active_hash/init.rb
CHANGED
@@ -17,6 +17,9 @@ module ActiveHash
|
|
17
17
|
private
|
18
18
|
|
19
19
|
def filter_associations(attributes)
|
20
|
+
permitted_params = [*self.class.send(:attribute_names), *self.class.send(:association_names)]
|
21
|
+
rejected_params = attributes.reject{ |p| permitted_params.include? p.to_sym}
|
22
|
+
raise "Rejected params: #{rejected_params} for #{self.class.name}" if !rejected_params.empty?
|
20
23
|
@attributes = attributes.select do |k, v|
|
21
24
|
self.class.send(:attribute_names).include? k.to_sym
|
22
25
|
end
|
@@ -25,6 +28,7 @@ module ActiveHash
|
|
25
28
|
self.class.send(:association_names).include? k.to_sym
|
26
29
|
end
|
27
30
|
@associations = self.class.send(:association_template).merge(associations)
|
31
|
+
|
28
32
|
end
|
29
33
|
|
30
34
|
end
|
@@ -83,6 +83,10 @@ describe ActiveMocker::Base do
|
|
83
83
|
|
84
84
|
end
|
85
85
|
|
86
|
+
it 'will raise error if not an attribute or association' do
|
87
|
+
expect{mock_class.new(baz: "Hello")}.to raise_error('Rejected params: {"baz"=>"Hello"} for PersonMock')
|
88
|
+
end
|
89
|
+
|
86
90
|
end
|
87
91
|
|
88
92
|
describe '#mock_class' do
|
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.23
|
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-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|