helpstation 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/helpstation.gemspec +1 -0
- data/lib/helpstation.rb +1 -0
- data/lib/helpstation/fetchers.rb +3 -3
- data/lib/helpstation/version.rb +1 -1
- data/spec/helpstation/fetchers/active_record_fetcher_spec.rb +51 -0
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1737e99497226875f9236ce290876304503b807a
|
4
|
+
data.tar.gz: 29114da9c85c49009349d9994ab7b20c5d935492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14b07b8f277a40575784e773458ec32cb8896fa20f0b8da27f3c9606effdf512b46b21c47040c32fa0a372ef4ae04d3b646ed78268a40a02e68b8965f84adef7
|
7
|
+
data.tar.gz: 9daa6ca53aafc3e7c90467d9be96a37500d183546aaafb53a668d25a12f1a90e8ea0bbb0e91c7b1daf41fc41b6c747fa22ee0b4fd5a519e78e71a94e823b73fc
|
data/helpstation.gemspec
CHANGED
data/lib/helpstation.rb
CHANGED
data/lib/helpstation/fetchers.rb
CHANGED
@@ -29,10 +29,10 @@ module Helpstation
|
|
29
29
|
end
|
30
30
|
|
31
31
|
class ActiveRecordFetcher < ByKeyFetcher
|
32
|
-
def
|
32
|
+
def call
|
33
33
|
super
|
34
|
-
rescue ActiveRecord::
|
35
|
-
|
34
|
+
rescue ActiveRecord::RecordNotFound
|
35
|
+
error("#{Inflecto.humanize(output_key)} ##{input[input_key]} not found")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/helpstation/version.rb
CHANGED
@@ -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.
|
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:
|
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
|