simple_action 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile.lock +1 -1
- data/lib/simple_action/concerns/accepts_params.rb +5 -7
- data/lib/simple_action/params.rb +1 -1
- data/lib/simple_action/version.rb +1 -1
- data/spec/acceptance_spec.rb +98 -84
- data/spec/params_spec.rb +10 -0
- data/spec/spec_helper.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODA5YjFiOWVlMDg1NDQ1MzlkNGE5ODIwNTFmNjI2Yzc1NGU4NWQwMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTIxNTNhZWI1N2ZjMDQxZDhjNWQ3NTM3NmU3ZDRlZGY1YmI0ZTJkYg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjIyMzU4MzBlNTgxYWU2MGQ2YWYxODZkYTdkZTZmMDAyZTBiYjI0OTMwMDEx
|
10
|
+
ODUzZGVjY2E2MmNiMGRmMTE4MTJlNjgwMDk4MTg4N2I3N2MwZmJmZjNmYmU3
|
11
|
+
YTY4ODA4M2M4NTgzMjljZmI5YzZmNzhmMTQzNzE0NWM5NDdhNWU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTZlNGRlMjY3MGQ0ZDYxODRiN2FjYjliMTFjZjM0ZTJkYTViNmY1MTdmYTc1
|
14
|
+
M2ZlYzFmZTIwMjYwZTVhZDBmNjMzMjhjMTdjYmQ3MDZiNjA3ZGQxOTY5MmVj
|
15
|
+
MTc3ZWI3N2IyMTY0MGI4MzUwYTUyN2JhYzY2ZDYyYTVmNjRkZTE=
|
data/Gemfile.lock
CHANGED
@@ -8,13 +8,11 @@ module SimpleAction
|
|
8
8
|
attr_accessor :params_class
|
9
9
|
|
10
10
|
def params(&block)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
}
|
17
|
-
klass.class_eval(&name_function)
|
11
|
+
klass_name = self.model_name.to_s
|
12
|
+
klass_name = klass_name + "Params"
|
13
|
+
@params_class = Class.new(SimpleAction::Params).tap do |klass|
|
14
|
+
extend ActiveModel::Naming
|
15
|
+
self.const_set(klass_name, klass)
|
18
16
|
klass.class_eval(&block)
|
19
17
|
end
|
20
18
|
end
|
data/lib/simple_action/params.rb
CHANGED
data/spec/acceptance_spec.rb
CHANGED
@@ -23,128 +23,142 @@ describe "SimpleAction acceptance spec" do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
name: nil
|
30
|
-
}
|
26
|
+
describe "#model_name" do
|
27
|
+
it "equals class name" do
|
28
|
+
SimpleActionAcceptance.model_name.should eq("SimpleActionAcceptance")
|
31
29
|
end
|
30
|
+
end
|
32
31
|
|
33
|
-
|
34
|
-
|
32
|
+
describe "params #model_name" do
|
33
|
+
it "equals class name::Params" do
|
34
|
+
SimpleActionAcceptance.new.params.model_name.should eq("SimpleActionAcceptance::SimpleActionAcceptanceParams")
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "outcome" do
|
39
|
+
context "with nil params" do
|
40
|
+
let(:params) do
|
41
|
+
{
|
42
|
+
name: nil
|
43
|
+
}
|
44
|
+
end
|
35
45
|
|
36
|
-
|
37
|
-
|
46
|
+
describe "outcome" do
|
47
|
+
subject { SimpleActionAcceptance.run(params) }
|
38
48
|
|
39
|
-
|
40
|
-
|
49
|
+
it { should_not be_valid }
|
50
|
+
it { should_not be_success }
|
51
|
+
|
52
|
+
it "should have name error" do
|
53
|
+
subject.errors[:name].should eq(["can't be blank"])
|
54
|
+
end
|
41
55
|
end
|
42
|
-
end
|
43
56
|
|
44
|
-
|
45
|
-
|
57
|
+
describe "result" do
|
58
|
+
subject { SimpleActionAcceptance.run(params).result }
|
46
59
|
|
47
|
-
|
48
|
-
|
60
|
+
it { should be_nil }
|
61
|
+
end
|
49
62
|
|
50
|
-
|
63
|
+
describe "effects" do
|
64
|
+
end
|
51
65
|
end
|
52
|
-
end
|
53
66
|
|
54
|
-
|
55
|
-
|
67
|
+
context "with invalid params" do
|
68
|
+
let!(:name) { "sdfg" }
|
56
69
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
70
|
+
let(:params) do
|
71
|
+
{
|
72
|
+
name: name
|
73
|
+
}
|
74
|
+
end
|
62
75
|
|
63
|
-
|
64
|
-
|
76
|
+
describe "outcome" do
|
77
|
+
subject { SimpleActionAcceptance.run(params) }
|
65
78
|
|
66
|
-
|
67
|
-
|
79
|
+
it { should_not be_valid }
|
80
|
+
it { should_not be_success }
|
68
81
|
|
69
|
-
|
70
|
-
|
82
|
+
it "should have name error" do
|
83
|
+
subject.errors[:name].should eq(["must contain at least one vowel"])
|
84
|
+
end
|
71
85
|
end
|
72
|
-
end
|
73
86
|
|
74
|
-
|
75
|
-
|
87
|
+
describe "result" do
|
88
|
+
subject { SimpleActionAcceptance.run(params).result }
|
76
89
|
|
77
|
-
|
78
|
-
|
90
|
+
it { should be_nil }
|
91
|
+
end
|
79
92
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
93
|
+
describe "effects" do
|
94
|
+
it "does not alter name" do
|
95
|
+
SimpleActionAcceptance.run(params)
|
96
|
+
name.should eq("sdfg")
|
97
|
+
end
|
84
98
|
end
|
85
99
|
end
|
86
|
-
end
|
87
100
|
|
88
|
-
|
89
|
-
|
101
|
+
context "with valid params" do
|
102
|
+
let!(:name) { "billy12" }
|
90
103
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
104
|
+
let(:params) do
|
105
|
+
{
|
106
|
+
name: name
|
107
|
+
}
|
108
|
+
end
|
96
109
|
|
97
|
-
|
98
|
-
|
110
|
+
describe "outcome" do
|
111
|
+
subject { SimpleActionAcceptance.run(params) }
|
99
112
|
|
100
|
-
|
101
|
-
|
102
|
-
|
113
|
+
it { should be_valid }
|
114
|
+
it { should be_success }
|
115
|
+
end
|
103
116
|
|
104
|
-
|
105
|
-
|
117
|
+
describe "result" do
|
118
|
+
subject { SimpleActionAcceptance.run(params).result }
|
106
119
|
|
107
|
-
|
108
|
-
|
120
|
+
it { should eq("BILLY") }
|
121
|
+
end
|
109
122
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
123
|
+
describe "effects" do
|
124
|
+
it "strips numbers from name" do
|
125
|
+
SimpleActionAcceptance.run(params)
|
126
|
+
name.should eq("billy")
|
127
|
+
end
|
114
128
|
end
|
115
129
|
end
|
116
|
-
end
|
117
130
|
|
118
|
-
|
119
|
-
|
131
|
+
context "with outlier case" do
|
132
|
+
let!(:name) { "outlier12" }
|
120
133
|
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
134
|
+
let(:params) do
|
135
|
+
{
|
136
|
+
name: name
|
137
|
+
}
|
138
|
+
end
|
126
139
|
|
127
|
-
|
128
|
-
|
140
|
+
describe "outcome" do
|
141
|
+
subject { SimpleActionAcceptance.run(params) }
|
129
142
|
|
130
|
-
|
131
|
-
|
143
|
+
it { should_not be_valid }
|
144
|
+
it { should_not be_success }
|
132
145
|
|
133
|
-
|
134
|
-
|
146
|
+
it "should have name error", failing: true do
|
147
|
+
subject.errors[:name].should eq(["can't be outlier"])
|
148
|
+
end
|
135
149
|
end
|
136
|
-
end
|
137
150
|
|
138
|
-
|
139
|
-
|
151
|
+
describe "result" do
|
152
|
+
subject { SimpleActionAcceptance.run(params).result }
|
140
153
|
|
141
|
-
|
142
|
-
|
154
|
+
it { should be_nil }
|
155
|
+
end
|
143
156
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
157
|
+
describe "effects" do
|
158
|
+
it "alter names" do
|
159
|
+
SimpleActionAcceptance.run(params)
|
160
|
+
name.should eq("outlier")
|
161
|
+
end
|
148
162
|
end
|
149
163
|
end
|
150
164
|
end
|
data/spec/params_spec.rb
CHANGED
@@ -2,6 +2,16 @@ require 'spec_helper'
|
|
2
2
|
require 'fixtures/params_spec_class'
|
3
3
|
|
4
4
|
describe SimpleAction::Params do
|
5
|
+
describe "model_name", model_name: true do
|
6
|
+
it "has correct model_name for SimpleAction::Params" do
|
7
|
+
SimpleAction::Params.model_name.should eq("SimpleAction::Params")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "has correct model_name for ParamsSpecClass" do
|
11
|
+
ParamsSpecClass.model_name.should eq("ParamsSpecClass")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
5
15
|
describe "original_params", original_params: true do
|
6
16
|
it "returns symbolized params hash" do
|
7
17
|
params = ParamsSpecClass.new(name: "Tom", address: { "street" => "1 Main St."} )
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- brycesenz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: simple_params
|