simple_action 1.0.5 → 1.0.6

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MWU2NmZhYWI0MDM3NTJkNzM2NjI4NzVjYmEyZDFkODViYzE5NzJjOQ==
4
+ ODA5YjFiOWVlMDg1NDQ1MzlkNGE5ODIwNTFmNjI2Yzc1NGU4NWQwMg==
5
5
  data.tar.gz: !binary |-
6
- MTBjYTA2NThhZDUwN2QyN2ZiMWFlNWIzM2RjYWRkMDFjMzUxODIzZA==
6
+ ZTIxNTNhZWI1N2ZjMDQxZDhjNWQ3NTM3NmU3ZDRlZGY1YmI0ZTJkYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ZWY0ZGNiYzI3MDcxOTI1OGI5NDZiMzA5M2Y2MGE1YjdmY2YxYzk0NTdjMjc5
10
- YWE3YWYxMTI0N2M3ZjIyZDI2N2M4N2RmMzk2M2JiOWFiNTI0NDJhNjYzNDI2
11
- NzBiZmFhOGU0OWZiN2U1ZjdlMjYyZjFmOWYxNTc4OWMwYzhlMzQ=
9
+ YjIyMzU4MzBlNTgxYWU2MGQ2YWYxODZkYTdkZTZmMDAyZTBiYjI0OTMwMDEx
10
+ ODUzZGVjY2E2MmNiMGRmMTE4MTJlNjgwMDk4MTg4N2I3N2MwZmJmZjNmYmU3
11
+ YTY4ODA4M2M4NTgzMjljZmI5YzZmNzhmMTQzNzE0NWM5NDdhNWU=
12
12
  data.tar.gz: !binary |-
13
- N2E2ZTcwZmM2MzM2MjYyMGJjMGU5M2Y5ODk3NDM5NGFjNTg0Y2ViY2QyZjdm
14
- YmRjNmU4NzBkNTZjMDEwMjA3MmI5NjdjMTVhNzdhZDE1ZDQ1MzdiYzA0YmQx
15
- MDc0OGFiNmJhM2JhZTU0YTkzY2E1OTc1MDk2ZDIwNjg4ZDI4MDY=
13
+ OTZlNGRlMjY3MGQ0ZDYxODRiN2FjYjliMTFjZjM0ZTJkYTViNmY1MTdmYTc1
14
+ M2ZlYzFmZTIwMjYwZTVhZDBmNjMzMjhjMTdjYmQ3MDZiNjA3ZGQxOTY5MmVj
15
+ MTc3ZWI3N2IyMTY0MGI4MzUwYTUyN2JhYzY2ZDYyYTVmNjRkZTE=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_action (1.0.4)
4
+ simple_action (1.0.5)
5
5
  simple_params (>= 1.0.2, < 2.0)
6
6
 
7
7
  GEM
@@ -8,13 +8,11 @@ module SimpleAction
8
8
  attr_accessor :params_class
9
9
 
10
10
  def params(&block)
11
- @params_class = Class.new(Params).tap do |klass|
12
- name_function = Proc.new {
13
- def self.model_name
14
- ActiveModel::Name.new(self, self, "Params")
15
- end
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
@@ -1,4 +1,4 @@
1
- require 'simple_params'
1
+ require "simple_params"
2
2
 
3
3
  module SimpleAction
4
4
  class Params < ::SimpleParams::Params
@@ -1,3 +1,3 @@
1
1
  module SimpleAction
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.6"
3
3
  end
@@ -23,128 +23,142 @@ describe "SimpleAction acceptance spec" do
23
23
  end
24
24
  end
25
25
 
26
- context "with nil params" do
27
- let(:params) do
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
- describe "outcome" do
34
- subject { SimpleActionAcceptance.run(params) }
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
- it { should_not be_valid }
37
- it { should_not be_success }
46
+ describe "outcome" do
47
+ subject { SimpleActionAcceptance.run(params) }
38
48
 
39
- it "should have name error" do
40
- subject.errors[:name].should eq(["can't be blank"])
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
- describe "result" do
45
- subject { SimpleActionAcceptance.run(params).result }
57
+ describe "result" do
58
+ subject { SimpleActionAcceptance.run(params).result }
46
59
 
47
- it { should be_nil }
48
- end
60
+ it { should be_nil }
61
+ end
49
62
 
50
- describe "effects" do
63
+ describe "effects" do
64
+ end
51
65
  end
52
- end
53
66
 
54
- context "with invalid params" do
55
- let!(:name) { "sdfg" }
67
+ context "with invalid params" do
68
+ let!(:name) { "sdfg" }
56
69
 
57
- let(:params) do
58
- {
59
- name: name
60
- }
61
- end
70
+ let(:params) do
71
+ {
72
+ name: name
73
+ }
74
+ end
62
75
 
63
- describe "outcome" do
64
- subject { SimpleActionAcceptance.run(params) }
76
+ describe "outcome" do
77
+ subject { SimpleActionAcceptance.run(params) }
65
78
 
66
- it { should_not be_valid }
67
- it { should_not be_success }
79
+ it { should_not be_valid }
80
+ it { should_not be_success }
68
81
 
69
- it "should have name error" do
70
- subject.errors[:name].should eq(["must contain at least one vowel"])
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
- describe "result" do
75
- subject { SimpleActionAcceptance.run(params).result }
87
+ describe "result" do
88
+ subject { SimpleActionAcceptance.run(params).result }
76
89
 
77
- it { should be_nil }
78
- end
90
+ it { should be_nil }
91
+ end
79
92
 
80
- describe "effects" do
81
- it "does not alter name" do
82
- SimpleActionAcceptance.run(params)
83
- name.should eq("sdfg")
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
- context "with valid params" do
89
- let!(:name) { "billy12" }
101
+ context "with valid params" do
102
+ let!(:name) { "billy12" }
90
103
 
91
- let(:params) do
92
- {
93
- name: name
94
- }
95
- end
104
+ let(:params) do
105
+ {
106
+ name: name
107
+ }
108
+ end
96
109
 
97
- describe "outcome" do
98
- subject { SimpleActionAcceptance.run(params) }
110
+ describe "outcome" do
111
+ subject { SimpleActionAcceptance.run(params) }
99
112
 
100
- it { should be_valid }
101
- it { should be_success }
102
- end
113
+ it { should be_valid }
114
+ it { should be_success }
115
+ end
103
116
 
104
- describe "result" do
105
- subject { SimpleActionAcceptance.run(params).result }
117
+ describe "result" do
118
+ subject { SimpleActionAcceptance.run(params).result }
106
119
 
107
- it { should eq("BILLY") }
108
- end
120
+ it { should eq("BILLY") }
121
+ end
109
122
 
110
- describe "effects" do
111
- it "strips numbers from name" do
112
- SimpleActionAcceptance.run(params)
113
- name.should eq("billy")
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
- context "with outlier case" do
119
- let!(:name) { "outlier12" }
131
+ context "with outlier case" do
132
+ let!(:name) { "outlier12" }
120
133
 
121
- let(:params) do
122
- {
123
- name: name
124
- }
125
- end
134
+ let(:params) do
135
+ {
136
+ name: name
137
+ }
138
+ end
126
139
 
127
- describe "outcome" do
128
- subject { SimpleActionAcceptance.run(params) }
140
+ describe "outcome" do
141
+ subject { SimpleActionAcceptance.run(params) }
129
142
 
130
- it { should_not be_valid }
131
- it { should_not be_success }
143
+ it { should_not be_valid }
144
+ it { should_not be_success }
132
145
 
133
- it "should have name error", failing: true do
134
- subject.errors[:name].should eq(["can't be outlier"])
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
- describe "result" do
139
- subject { SimpleActionAcceptance.run(params).result }
151
+ describe "result" do
152
+ subject { SimpleActionAcceptance.run(params).result }
140
153
 
141
- it { should be_nil }
142
- end
154
+ it { should be_nil }
155
+ end
143
156
 
144
- describe "effects" do
145
- it "alter names" do
146
- SimpleActionAcceptance.run(params)
147
- name.should eq("outlier")
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
@@ -5,8 +5,6 @@ require 'pry'
5
5
 
6
6
  Dir[File.join('.', 'spec', 'support', '**', '*.rb')].each {|f| require f}
7
7
 
8
- # I18n.config.enforce_available_locales = true
9
-
10
8
  RSpec.configure do |config|
11
9
  config.mock_with :rspec
12
10
  end
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.5
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-22 00:00:00.000000000 Z
11
+ date: 2015-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: simple_params