simple_action 0.0.1.pre4 → 0.0.1.pre5
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 +2 -2
- data/lib/simple_action/service.rb +1 -7
- data/lib/simple_action/version.rb +1 -1
- data/simple_action.gemspec +1 -1
- data/spec/acceptance_spec.rb +91 -0
- data/spec/service_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OTQzNmQyZDBjOGVlZThkYmJmNWU3MzJjODA4N2Q2MzI3MTk3MWQ1MA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTQ1MDM0ZTAxN2IyOWNhMjIyZjg3MzBkOTZiYTBlZjRkNWMwZDFmYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTE1N2ZiNjhhODc0OWUzYmVmODE2NDlmNWUwZWRiMzRmNTc0OWM2OTNkYmMy
|
10
|
+
NzEyNTQ4NGNkZWNhYjcwNTgwZWNiNWNlNTVmYzgwNDA2MTBiZWU4NjRkMzk5
|
11
|
+
YWIxOTFhY2M1MWEzY2RlZTk0ZTc0OTY2OGQxZWI3MGQ5NTVmMjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MzY4MWRiOWY5ZDA0YTAwN2RiYjc1NWU2NzI2ODA2NDYwYTE3MWM0NTRhNjU1
|
14
|
+
NGEzNzFiMzE1MGUxODIwMjdiNDg2YTAyNjBjNmE2YzVlMTQ1NGQ1YThlM2Q2
|
15
|
+
MjQzZThmNDdhYjM5Y2E0MzhkYWNjZTViYWExYzVlMDQ4NGU4OTQ=
|
data/Gemfile.lock
CHANGED
@@ -30,7 +30,6 @@ module SimpleAction
|
|
30
30
|
def initialize(params={})
|
31
31
|
@raw_params = params
|
32
32
|
@params = self.class.params_class.new(params)
|
33
|
-
@validity = nil
|
34
33
|
end
|
35
34
|
|
36
35
|
def params
|
@@ -38,12 +37,7 @@ module SimpleAction
|
|
38
37
|
end
|
39
38
|
|
40
39
|
def valid?
|
41
|
-
|
42
|
-
if @validity.nil?
|
43
|
-
@validity = @params.valid?
|
44
|
-
else
|
45
|
-
@validity
|
46
|
-
end
|
40
|
+
@params.valid?
|
47
41
|
end
|
48
42
|
|
49
43
|
def errors
|
data/simple_action.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "simple_params", ">= 0.0.
|
21
|
+
spec.add_dependency "simple_params", ">= 0.0.3", "< 1.0"
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.5"
|
23
23
|
spec.add_development_dependency "rake", "~> 10.1"
|
24
24
|
spec.add_development_dependency "rspec", "~> 2.6"
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "SimpleAction acceptance spec" do
|
4
|
+
class SimpleActionAcceptance < SimpleAction::Service
|
5
|
+
params do
|
6
|
+
param :name, type: :string
|
7
|
+
validate :name_has_vowels, if: :name
|
8
|
+
|
9
|
+
def name_has_vowels
|
10
|
+
unless name.scan(/[aeiou]/).count >= 1
|
11
|
+
errors.add(:name, "must contain at least one vowel")
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
name.upcase
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with nil params" do
|
22
|
+
let(:params) do
|
23
|
+
{
|
24
|
+
name: nil
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "outcome" do
|
29
|
+
subject { SimpleActionAcceptance.run(params) }
|
30
|
+
|
31
|
+
it { should_not be_valid }
|
32
|
+
it { should_not be_success }
|
33
|
+
|
34
|
+
it "should have name error" do
|
35
|
+
subject.errors[:name].should eq(["can't be blank"])
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "result" do
|
40
|
+
subject { SimpleActionAcceptance.run(params).result }
|
41
|
+
|
42
|
+
it { should be_nil }
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context "with invalid params" do
|
47
|
+
let(:params) do
|
48
|
+
{
|
49
|
+
name: "sdfg"
|
50
|
+
}
|
51
|
+
end
|
52
|
+
|
53
|
+
describe "outcome" do
|
54
|
+
subject { SimpleActionAcceptance.run(params) }
|
55
|
+
|
56
|
+
it { should_not be_valid }
|
57
|
+
it { should_not be_success }
|
58
|
+
|
59
|
+
it "should have name error" do
|
60
|
+
subject.errors[:name].should eq(["must contain at least one vowel"])
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "result" do
|
65
|
+
subject { SimpleActionAcceptance.run(params).result }
|
66
|
+
|
67
|
+
it { should be_nil }
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
context "with valid params" do
|
72
|
+
let(:params) do
|
73
|
+
{
|
74
|
+
name: "billy"
|
75
|
+
}
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "outcome" do
|
79
|
+
subject { SimpleActionAcceptance.run(params) }
|
80
|
+
|
81
|
+
it { should be_valid }
|
82
|
+
it { should be_success }
|
83
|
+
end
|
84
|
+
|
85
|
+
describe "result" do
|
86
|
+
subject { SimpleActionAcceptance.run(params).result }
|
87
|
+
|
88
|
+
it { should eq("BILLY") }
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
data/spec/service_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_action
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.pre5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- brycesenz
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ! '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.0.
|
19
|
+
version: 0.0.3
|
20
20
|
- - <
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '1.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.0.
|
29
|
+
version: 0.0.3
|
30
30
|
- - <
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '1.0'
|
@@ -111,6 +111,7 @@ files:
|
|
111
111
|
- lib/simple_action/service.rb
|
112
112
|
- lib/simple_action/version.rb
|
113
113
|
- simple_action.gemspec
|
114
|
+
- spec/acceptance_spec.rb
|
114
115
|
- spec/fixtures/dummy_service_object_class.rb
|
115
116
|
- spec/fixtures/params_spec_class.rb
|
116
117
|
- spec/fixtures/service_spec_class.rb
|
@@ -143,6 +144,7 @@ signing_key:
|
|
143
144
|
specification_version: 4
|
144
145
|
summary: A DSL for specifying services objects, including parameters and execution
|
145
146
|
test_files:
|
147
|
+
- spec/acceptance_spec.rb
|
146
148
|
- spec/fixtures/dummy_service_object_class.rb
|
147
149
|
- spec/fixtures/params_spec_class.rb
|
148
150
|
- spec/fixtures/service_spec_class.rb
|