active_mocker 1.1.22 → 1.1.23

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8d229156873ba7fc73414eade5ad9b837ac8d450
4
- data.tar.gz: 4d26d5d95f13e24e1973c7d9a6ec9aa3541ab202
3
+ metadata.gz: 35394fa054b9991f64200432c22300c0338b5794
4
+ data.tar.gz: 439c5e2cb084947588d5e9be24e1adef3169103b
5
5
  SHA512:
6
- metadata.gz: 8cd9eaaaa2c2f80bb2bd4b5e00ad8a9e998562fb30340ce9851764e62db0e3fb9c9d506c255a9b7451f118d13f15d5f856d13d1a734929c3a2e6104c41a86876
7
- data.tar.gz: 0d55b2830a04f1ab7c39a71d6138090ff69caf88779b13d2a81c3338cd992ff2bb488c098c320867d545dd5d009c12cd1045cecdfd9de19146c6cbe97be752ce
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
- **Collection Associations**
174
-
175
-
176
- * last/first
177
- * sum(attribute)
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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ActiveMocker
2
- VERSION = "1.1.22"
2
+ VERSION = "1.1.23"
3
3
  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.22
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-26 00:00:00.000000000 Z
11
+ date: 2014-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord