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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODdhYTRmMjQ0MjU4OTU0MjBkYmYyNjA1MzQ4MWE0NzY1MzI2MGZiMQ==
4
+ OTQzNmQyZDBjOGVlZThkYmJmNWU3MzJjODA4N2Q2MzI3MTk3MWQ1MA==
5
5
  data.tar.gz: !binary |-
6
- ZTllZjRiZDEzNmJjNThiOGRkOWRjY2Q0NDAzZDNlYzRkMWJiN2IzZg==
6
+ OTQ1MDM0ZTAxN2IyOWNhMjIyZjg3MzBkOTZiYTBlZjRkNWMwZDFmYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NTZiZmViMDgzZmQxYTBmMDQ0NWEzZGU5MmU4ZDg2ZmM1M2M0Yzc1YzAzZTk5
10
- NWEyNjJlOGJhYzY2YTM0NGYxOTY0YWJiMmMwNWQ5ZDkyZDUyOTI3ODk0ZjQw
11
- ZmJhOWUwNTBjOWNhYzE2NDczYThmYTBjNWExYWZmMjdkZDgxMWY=
9
+ OTE1N2ZiNjhhODc0OWUzYmVmODE2NDlmNWUwZWRiMzRmNTc0OWM2OTNkYmMy
10
+ NzEyNTQ4NGNkZWNhYjcwNTgwZWNiNWNlNTVmYzgwNDA2MTBiZWU4NjRkMzk5
11
+ YWIxOTFhY2M1MWEzY2RlZTk0ZTc0OTY2OGQxZWI3MGQ5NTVmMjE=
12
12
  data.tar.gz: !binary |-
13
- OGJhOGMyNmVlNzRiN2Q5NGIyMzE5M2Y1MTQ4N2I4YmFjNjMzNzY4ZWQ5NjNi
14
- M2Y4MmRjNTY1YjdkM2I3N2ZiNmUxMjBhY2U5ODAwODg0ZWExOGJlMmU1MjJm
15
- ZmUxYWY2ODc3Y2M2NDc3Nzk3NDZkZTg2YTQ1ZGM3ZWQ1YzA0MjE=
13
+ MzY4MWRiOWY5ZDA0YTAwN2RiYjc1NWU2NzI2ODA2NDYwYTE3MWM0NTRhNjU1
14
+ NGEzNzFiMzE1MGUxODIwMjdiNDg2YTAyNjBjNmE2YzVlMTQ1NGQ1YThlM2Q2
15
+ MjQzZThmNDdhYjM5Y2E0MzhkYWNjZTViYWExYzVlMDQ4NGU4OTQ=
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- simple_action (0.0.1.pre3)
5
- simple_params (>= 0.0.5, < 1.0)
4
+ simple_action (0.0.1.pre4)
5
+ simple_params (>= 0.0.3, < 1.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -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
- # Doing this to avoid re-running @params.valid? every time.
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
@@ -1,3 +1,3 @@
1
1
  module SimpleAction
2
- VERSION = "0.0.1.pre4"
2
+ VERSION = "0.0.1.pre5"
3
3
  end
@@ -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.5", "< 1.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
@@ -35,7 +35,7 @@ describe SimpleAction::Service do
35
35
  outcome.should be_success
36
36
  end
37
37
 
38
- it "has result equal to output of execute" do
38
+ it "has result equal to output of execute", failing: true do
39
39
  outcome.result.should eq(41)
40
40
  end
41
41
 
data/spec/spec_helper.rb CHANGED
@@ -5,6 +5,8 @@ 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
+
8
10
  RSpec.configure do |config|
9
11
  config.mock_with :rspec
10
12
  end
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.pre4
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.5
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.5
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