helpstation 0.1.5 → 0.1.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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bc387017d0c37a12b74f28b96028cbe0517e32e
4
- data.tar.gz: f4adbd59e1b9b9a6578b56af633f3398562d5692
3
+ metadata.gz: 1737e99497226875f9236ce290876304503b807a
4
+ data.tar.gz: 29114da9c85c49009349d9994ab7b20c5d935492
5
5
  SHA512:
6
- metadata.gz: 20eebb79bc3f800b937ff246676e67ca1ca6248bb3a47d27017cbf7b1dea39d2768c815d15d7c1ba236b902f12063e8ba15400d70af696edbbf22ebe34e8804d
7
- data.tar.gz: 3b17da6034095a4e9b4d7cd5127e401be16ed2392605108e5c85673f5fc9665e97f24ff57991e4cbf12f1fc33400e9e08d2687e46fd2eb0c61b8cbc9242357dc
6
+ metadata.gz: 14b07b8f277a40575784e773458ec32cb8896fa20f0b8da27f3c9606effdf512b46b21c47040c32fa0a372ef4ae04d3b646ed78268a40a02e68b8965f84adef7
7
+ data.tar.gz: 9daa6ca53aafc3e7c90467d9be96a37500d183546aaafb53a668d25a12f1a90e8ea0bbb0e91c7b1daf41fc41b6c747fa22ee0b4fd5a519e78e71a94e823b73fc
data/helpstation.gemspec CHANGED
@@ -18,4 +18,5 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ['lib']
19
19
 
20
20
  spec.add_dependency 'substation', '~> 0.0', '>= 0.0.10'
21
+ spec.add_dependency 'inflecto', '~> 0.0.2'
21
22
  end
data/lib/helpstation.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'substation'
2
+ require 'inflecto'
2
3
 
3
4
  require_relative 'helpstation/version'
4
5
  require_relative 'helpstation/evaluator'
@@ -29,10 +29,10 @@ module Helpstation
29
29
  end
30
30
 
31
31
  class ActiveRecordFetcher < ByKeyFetcher
32
- def self.build(*)
32
+ def call
33
33
  super
34
- rescue ActiveRecord::NotFoundError
35
- raise NotFoundError
34
+ rescue ActiveRecord::RecordNotFound
35
+ error("#{Inflecto.humanize(output_key)} ##{input[input_key]} not found")
36
36
  end
37
37
  end
38
38
  end
@@ -1,3 +1,3 @@
1
1
  module Helpstation
2
- VERSION = '0.1.5'
2
+ VERSION = '0.1.6'
3
3
  end
@@ -0,0 +1,51 @@
1
+ require 'spec_helper'
2
+
3
+ describe Helpstation::Fetchers::ActiveRecordFetcher do
4
+ subject(:response) { processor.call(Substation::Request.new('my_request', env, input)) }
5
+
6
+ let(:env) { { mock_service: :mock_value } }
7
+ let(:input_key) { :my_input }
8
+ let(:output_key) { :my_output }
9
+
10
+ context 'when record is present' do
11
+ let(:processor) {
12
+ described_class.build(input_key, output_key) do |key, env|
13
+ record
14
+ end
15
+ }
16
+ let(:record) { double }
17
+ let(:input) { { my_input: input_key } }
18
+
19
+ it 'returns the record' do
20
+ expect(response).to be_a(Substation::Response::Success)
21
+ expect(response.output).to eq(
22
+ my_input: input[:my_input],
23
+ my_output: record
24
+ )
25
+ end
26
+ end
27
+
28
+ context 'when record is not found' do
29
+ # Helpstation does not have AR depndencies, so we mock them out
30
+ module ActiveRecord
31
+ end
32
+
33
+ class ActiveRecord::RecordNotFound < Exception
34
+ end
35
+
36
+ let(:processor) {
37
+ described_class.build(input_key, output_key) do |key, env|
38
+ raise ActiveRecord::RecordNotFound.new "No record"
39
+ end
40
+ }
41
+ let(:input) { { my_input: 'input_key' } }
42
+
43
+ it 'returns error response' do
44
+ expect(response).to be_a(Substation::Response::Failure)
45
+ expect(response.output).to eq(
46
+ success: false,
47
+ error: "My output #input_key not found"
48
+ )
49
+ end
50
+ end
51
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: helpstation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indrek Juhkam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-15 00:00:00.000000000 Z
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: substation
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 0.0.10
33
+ - !ruby/object:Gem::Dependency
34
+ name: inflecto
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: 0.0.2
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: 0.0.2
33
47
  description: Helps to unify SaleMove services
34
48
  email:
35
49
  - indrek@salemove.com
@@ -58,6 +72,7 @@ files:
58
72
  - lib/helpstation/renderer.rb
59
73
  - lib/helpstation/version.rb
60
74
  - spec/helpstation/evaluator_spec.rb
75
+ - spec/helpstation/fetchers/active_record_fetcher_spec.rb
61
76
  - spec/helpstation/fetchers/by_key_fetcher_spec.rb
62
77
  - spec/helpstation/processors/parallel_processor_spec.rb
63
78
  - spec/spec_helper.rb
@@ -87,6 +102,7 @@ specification_version: 4
87
102
  summary: ''
88
103
  test_files:
89
104
  - spec/helpstation/evaluator_spec.rb
105
+ - spec/helpstation/fetchers/active_record_fetcher_spec.rb
90
106
  - spec/helpstation/fetchers/by_key_fetcher_spec.rb
91
107
  - spec/helpstation/processors/parallel_processor_spec.rb
92
108
  - spec/spec_helper.rb