simple_params 1.3.2 → 1.3.3
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 +8 -8
- data/Gemfile.lock +1 -1
- data/lib/simple_params/nil_params.rb +18 -1
- data/lib/simple_params/version.rb +1 -1
- data/spec/nil_params_spec.rb +58 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YjU4MDlmOTRiZGM5ZTk2MjQ2ODhkYzE3N2EwMGM2MDE2NjU2Yjc3OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MmUxYjdiZjlkNDQ2YTAyMTk0ODY4YjQ1ZTM2MDFlNDUwMGNmYTBjZQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MDQzNmU4ZWZlMTBmOTFiM2M2MDQ3MDIwMDBhZDhiOWU3NmZkNjEzYjEyZmNl
|
10
|
+
ZGRjNDg1ZTdhZjEzYWE4YjJlYzQ3MDJmNTljNzhkNDU0NGZkN2FhMjRlNzM4
|
11
|
+
Nzg4NDdlYjQxOGUzMGNkZTYyOGM1YzJkNWNiMDc2Mjg3YzdlYjc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjE3ZTU2YWQ3MjE4ZmI5YmE3NDU3ZGQwZjUyNzYzYzRjM2NiNzM4ZTE2NGQ2
|
14
|
+
MzRiMTNlM2I4ZjYwNzU2ZmE3Nzc4YWY2NmY3MzhlYzkwNmYwMzQyMWUwMDMw
|
15
|
+
MWJjZmIyZDgzMWJjOGYxZTY0NTA2NTExOTcxNzIwN2Q4MjU5ZjM=
|
data/Gemfile.lock
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module SimpleParams
|
2
2
|
class NilParams < Params
|
3
|
-
def initialize(params={})
|
3
|
+
def initialize(params = {}, mocked_object = nil)
|
4
|
+
@mocked_object = mocked_object
|
4
5
|
super(params)
|
5
6
|
end
|
6
7
|
|
@@ -15,5 +16,21 @@ module SimpleParams
|
|
15
16
|
def errors
|
16
17
|
Errors.new(self)
|
17
18
|
end
|
19
|
+
|
20
|
+
def method_missing(method_name, *arguments, &block)
|
21
|
+
if @mocked_object.present?
|
22
|
+
@mocked_object.send(method_name, *arguments, &block)
|
23
|
+
else
|
24
|
+
super(method_name, *arguments, &block)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def respond_to?(method_name, include_private = false)
|
29
|
+
if @mocked_object.present?
|
30
|
+
@mocked_object.respond_to?(:method) || super
|
31
|
+
else
|
32
|
+
super
|
33
|
+
end
|
34
|
+
end
|
18
35
|
end
|
19
36
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/dummy_params'
|
3
|
+
|
4
|
+
describe SimpleParams::NilParams do
|
5
|
+
# Turn off Constant Redefined errors
|
6
|
+
before(:each) do
|
7
|
+
$VERBOSE = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
let!(:mocked_params) { DummyParams.new }
|
11
|
+
|
12
|
+
describe "#valid" do
|
13
|
+
let(:instance) { described_class.new({}, mocked_params)}
|
14
|
+
|
15
|
+
it "is valid" do
|
16
|
+
instance.should be_valid
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#errors" do
|
21
|
+
let(:instance) { described_class.new({}, mocked_params)}
|
22
|
+
|
23
|
+
it "has no errors" do
|
24
|
+
instance.errors.should be_empty
|
25
|
+
end
|
26
|
+
|
27
|
+
it "can clear errors" do
|
28
|
+
instance.valid?
|
29
|
+
instance.errors.clear.should eq([])
|
30
|
+
end
|
31
|
+
|
32
|
+
it "has no error messages" do
|
33
|
+
instance.valid?
|
34
|
+
instance.errors.messages.should be_empty
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#to_hash" do
|
39
|
+
let(:instance) { described_class.new({}, mocked_params)}
|
40
|
+
|
41
|
+
it "is empty" do
|
42
|
+
instance.to_hash.should be_empty
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "#mocked_params accessors" do
|
47
|
+
let(:instance) { described_class.new({}, mocked_params)}
|
48
|
+
|
49
|
+
it "responds to mocked_params" do
|
50
|
+
instance.name.should be_nil
|
51
|
+
instance.age.should be_nil
|
52
|
+
instance.name = "Amy"
|
53
|
+
instance.age = 33
|
54
|
+
instance.name.should eq("Amy")
|
55
|
+
instance.age.should eq(33)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_params
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- brycesenz
|
@@ -167,6 +167,7 @@ files:
|
|
167
167
|
- spec/formatter_spec.rb
|
168
168
|
- spec/multiple_classes_spec.rb
|
169
169
|
- spec/nested_params_spec.rb
|
170
|
+
- spec/nil_params_spec.rb
|
170
171
|
- spec/params_spec.rb
|
171
172
|
- spec/rails_integration_spec.rb
|
172
173
|
- spec/spec_helper.rb
|
@@ -213,6 +214,7 @@ test_files:
|
|
213
214
|
- spec/formatter_spec.rb
|
214
215
|
- spec/multiple_classes_spec.rb
|
215
216
|
- spec/nested_params_spec.rb
|
217
|
+
- spec/nil_params_spec.rb
|
216
218
|
- spec/params_spec.rb
|
217
219
|
- spec/rails_integration_spec.rb
|
218
220
|
- spec/spec_helper.rb
|