lhs 6.4.0 → 6.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/.rubocop.yml +9 -0
- data/.ruby-version +1 -0
- data/README.md +15 -0
- data/cider-ci.yml +2 -2
- data/cider-ci/bin/bundle +27 -0
- data/cider-ci/bin/ruby_install +8 -0
- data/cider-ci/bin/ruby_version +25 -0
- data/cider-ci/jobs/rspec.yml +17 -41
- data/cider-ci/jobs/rubocop.yml +11 -48
- data/cider-ci/task_components/bundle.yml +18 -0
- data/cider-ci/task_components/rspec.yml +36 -0
- data/cider-ci/task_components/rubocop.yml +29 -0
- data/cider-ci/task_components/ruby.yml +15 -0
- data/lhs.gemspec +4 -4
- data/lib/lhs/concerns/item/validation.rb +2 -2
- data/lib/lhs/concerns/record/batch.rb +1 -1
- data/lib/lhs/concerns/record/endpoints.rb +5 -10
- data/lib/lhs/concerns/record/find.rb +2 -2
- data/lib/lhs/concerns/record/find_by.rb +1 -1
- data/lib/lhs/concerns/record/request.rb +2 -2
- data/lib/lhs/data.rb +4 -2
- data/lib/lhs/item.rb +1 -1
- data/lib/lhs/pagination.rb +2 -2
- data/lib/lhs/proxy.rb +1 -1
- data/lib/lhs/version.rb +1 -1
- data/spec/data/is_item_or_collection_spec.rb +2 -1
- data/spec/data/parent_spec.rb +2 -1
- data/spec/item/internal_data_structure_spec.rb +0 -6
- data/spec/item/save_spec.rb +2 -1
- data/spec/item/validation_spec.rb +6 -5
- data/spec/record/endpoint_inheritance_spec.rb +63 -0
- data/spec/record/includes_spec.rb +2 -1
- data/spec/record/mapping_spec.rb +2 -1
- metadata +31 -27
- data/cider-ci/scripts/bundle.yml +0 -3
- data/cider-ci/scripts/github_comment.yml +0 -6
- data/cider-ci/scripts/rspec.yml +0 -4
- data/cider-ci/scripts/rubocop.yml +0 -5
- data/cider-ci/scripts/ruby-version.yml +0 -2
- data/cider-ci/scripts/tmp-cache.yml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79a4e6c3e274aa01035b67be3b5eeff82c68ddbd
|
4
|
+
data.tar.gz: 9c9362c9aeed7f7e2ed352eb22701b0bce023a22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cebde70543152187087c61cdfd89eb996ea93421393e3abd6062e63da99ba30a4f4ebc4abbd32474ed7f2ea9a3e7afc19c486881af22600d639b0184f8e17a3
|
7
|
+
data.tar.gz: b066b19b120054d863ab7c18f134796c70f7ba0ae84ec1d7a60280188ea2aefd2e48f91326a3c9f847c938a806c1da1e8dec6c0625503e7160da4d9166cb32dd
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.3.0
|
data/README.md
CHANGED
@@ -674,6 +674,21 @@ The behaviour of `count` and `length` is based on ActiveRecord's behaviour.
|
|
674
674
|
|
675
675
|
`length` This returns the number of elements loaded from an endpoint/api. In case of paginated resources this can be different to count, as it depends on how many pages have been loaded.
|
676
676
|
|
677
|
+
## Inheritance
|
678
|
+
|
679
|
+
You can inherit from previously defined records and also inherit endpoints that way:
|
680
|
+
|
681
|
+
```
|
682
|
+
class Base < LHS::Record
|
683
|
+
endpoint 'records/:id'
|
684
|
+
end
|
685
|
+
|
686
|
+
class Example < Base
|
687
|
+
end
|
688
|
+
|
689
|
+
Example.find(1) # GET records/1
|
690
|
+
```
|
691
|
+
|
677
692
|
## License
|
678
693
|
|
679
694
|
[GNU Affero General Public License Version 3.](https://www.gnu.org/licenses/agpl-3.0.en.html)
|
data/cider-ci.yml
CHANGED
data/cider-ci/bin/bundle
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -eux
|
3
|
+
|
4
|
+
export PATH=~/.rubies/$RUBY/bin:$PATH
|
5
|
+
rm -f .bundle/config
|
6
|
+
|
7
|
+
if [ ! -f ~/.rubies/$RUBY/bin/bundle ]; then
|
8
|
+
gem install bundler
|
9
|
+
fi
|
10
|
+
|
11
|
+
sed "s/^source 'https:\/\/rubygems\.intra\.local\.ch'*/source 'http\:\/\/52.29.7.59:9292'/g" Gemfile > Gemfile.tmp
|
12
|
+
mv Gemfile.tmp Gemfile
|
13
|
+
|
14
|
+
DIGEST=$(git ls-tree HEAD --\
|
15
|
+
cider-ci.yml cider-ci Gemfile.lock \
|
16
|
+
| openssl dgst -sha1 | cut -d ' ' -f 2)
|
17
|
+
|
18
|
+
DIGEST=$(echo "$DIGEST $PATH" \
|
19
|
+
| openssl dgst -sha1 | cut -d ' ' -f 2)
|
20
|
+
|
21
|
+
CACHE_SIGNATURE_FILE="/tmp/bundle_cache_signature_${DIGEST}"
|
22
|
+
|
23
|
+
if [ ! -f $CACHE_SIGNATURE_FILE ] ; then
|
24
|
+
bundle install
|
25
|
+
touch $CACHE_SIGNATURE_FILE
|
26
|
+
fi
|
27
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env bash
|
2
|
+
set -eux
|
3
|
+
|
4
|
+
if [ -f ./.ruby-version ]; then
|
5
|
+
echo ".ruby-version file found"
|
6
|
+
fi
|
7
|
+
|
8
|
+
if [ ! -f ./.ruby-version ]; then
|
9
|
+
echo ".ruby-version file not found"
|
10
|
+
exit 1
|
11
|
+
fi
|
12
|
+
|
13
|
+
IFS='-' read -ra EXPLODED_RUBY <<< "$RUBY"
|
14
|
+
|
15
|
+
if [ "${#EXPLODED_RUBY[@]}" == "1" ]; then
|
16
|
+
echo 'No engine/version separator "-" found in .ruby-version file.'
|
17
|
+
exit 1
|
18
|
+
fi
|
19
|
+
|
20
|
+
if [ "${#EXPLODED_RUBY[@]}" != "1" ] && [ "${#EXPLODED_RUBY[@]}" != "2" ]; then
|
21
|
+
echo "Unknown format of .ruby-version file"
|
22
|
+
exit 1
|
23
|
+
fi
|
24
|
+
|
25
|
+
echo $RUBY
|
data/cider-ci/jobs/rspec.yml
CHANGED
@@ -1,48 +1,24 @@
|
|
1
1
|
rspec:
|
2
|
-
name: '
|
2
|
+
name: 'rspec'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
run_when:
|
5
|
+
'some HEAD has been updated':
|
6
|
+
type: branch
|
7
|
+
include_match: ^.*$
|
7
8
|
|
8
9
|
context:
|
9
|
-
task-defaults:
|
10
|
-
ports:
|
11
|
-
CAPYBARA_PORT:
|
12
|
-
inet_address: "localhost"
|
13
|
-
min: 8000
|
14
|
-
max: 8999
|
15
|
-
PHANTOMJS_PORT:
|
16
|
-
inet_address: "localhost"
|
17
|
-
min: 44600
|
18
|
-
max: 44999
|
19
10
|
|
20
|
-
|
21
|
-
|
22
|
-
start-when:
|
23
|
-
- script: bundle
|
24
|
-
- script: ruby-version
|
25
|
-
- script: tmp-cache
|
11
|
+
script_defaults:
|
12
|
+
template_environment_variables: true
|
26
13
|
|
14
|
+
task_defaults:
|
15
|
+
max_trials: 2
|
16
|
+
dispatch_storm_delay_duration: 1 Seconds
|
17
|
+
include:
|
18
|
+
- cider-ci/task_components/ruby.yml
|
19
|
+
- cider-ci/task_components/bundle.yml
|
20
|
+
- cider-ci/task_components/rspec.yml
|
27
21
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
- cider-ci/scripts/ruby-version.yml
|
32
|
-
- cider-ci/scripts/rspec.yml
|
33
|
-
|
34
|
-
|
35
|
-
trial-attachments:
|
36
|
-
logs:
|
37
|
-
include-match: log\/.*\.log$
|
38
|
-
content-type: text/plain
|
39
|
-
image-screenshots:
|
40
|
-
include-match: tmp\/capybara\/.*\.png$
|
41
|
-
content-type: image/png
|
42
|
-
html-screenshots:
|
43
|
-
include-match: tmp\/capybara\/.*\.html$
|
44
|
-
content-type: text/html
|
45
|
-
|
46
|
-
_cider-ci_generate-tasks:
|
47
|
-
include-match: spec/.*_spec.rb
|
48
|
-
exclude-match: spec/support/shared/*
|
22
|
+
tasks:
|
23
|
+
all-rspec:
|
24
|
+
name: All rspec tests
|
data/cider-ci/jobs/rubocop.yml
CHANGED
@@ -1,55 +1,18 @@
|
|
1
1
|
rubocop:
|
2
|
-
name: 'Rubocop
|
2
|
+
name: 'Rubocop'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
run_when:
|
5
|
+
'some HEAD has been updated':
|
6
|
+
type: branch
|
7
|
+
include_match: ^.*$
|
7
8
|
|
8
9
|
context:
|
9
|
-
task-defaults:
|
10
|
-
environment-variables:
|
11
|
-
GIT_REPOSITORY: local-ch/location-app
|
12
|
-
RESULT_PATH: 'tmp/checkstyle.json'
|
13
|
-
|
14
|
-
scripts:
|
15
|
-
rubocop:
|
16
|
-
start-when:
|
17
|
-
- script: bundle
|
18
|
-
- script: ruby-version
|
19
|
-
- script: tmp-cache
|
20
|
-
|
21
|
-
|
22
|
-
github_comment:
|
23
|
-
start-when:
|
24
|
-
- script: rubocop
|
25
|
-
states: [failed]
|
26
|
-
|
27
|
-
|
28
|
-
_cider-ci_include:
|
29
|
-
- cider-ci/scripts/bundle.yml
|
30
|
-
- cider-ci/scripts/tmp-cache.yml
|
31
|
-
- cider-ci/scripts/ruby-version.yml
|
32
|
-
- cider-ci/scripts/rubocop.yml
|
33
|
-
|
34
|
-
- cider-ci/scripts/github_comment.yml
|
35
|
-
|
36
|
-
|
37
|
-
max-auto-trials: 1
|
38
|
-
|
39
|
-
trial-attachments:
|
40
|
-
logs:
|
41
|
-
include-match: tmp\/checkstyle.json$
|
42
|
-
content-type: application/json
|
43
|
-
|
44
|
-
tree-attachments:
|
45
|
-
logs:
|
46
|
-
include-match: tmp\/checkstyle.json$
|
47
|
-
content-type: application/json
|
48
10
|
|
49
11
|
tasks:
|
12
|
+
|
50
13
|
rubocop:
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
14
|
+
|
15
|
+
include:
|
16
|
+
- cider-ci/task_components/ruby.yml
|
17
|
+
- cider-ci/task_components/bundle.yml
|
18
|
+
- cider-ci/task_components/rubocop.yml
|
@@ -0,0 +1,18 @@
|
|
1
|
+
traits:
|
2
|
+
ruby-install: true
|
3
|
+
Bash: true
|
4
|
+
|
5
|
+
trial_attachments:
|
6
|
+
gemfile:
|
7
|
+
include_match: Gemfile
|
8
|
+
content_type: text/plain
|
9
|
+
|
10
|
+
scripts:
|
11
|
+
|
12
|
+
bundle:
|
13
|
+
exclusive_executor_resource: ruby-install_{{$RUBY}}
|
14
|
+
timeout: 20 Minutes
|
15
|
+
body: cider-ci/bin/bundle
|
16
|
+
start_when:
|
17
|
+
'ruby installed':
|
18
|
+
script_key: ruby-install
|
@@ -0,0 +1,36 @@
|
|
1
|
+
ports:
|
2
|
+
CAPYBARA_PORT:
|
3
|
+
min: 8000
|
4
|
+
max: 8999
|
5
|
+
PHANTOMJS_PORT:
|
6
|
+
min: 44600
|
7
|
+
max: 44999
|
8
|
+
|
9
|
+
environment_variables:
|
10
|
+
RUBY:
|
11
|
+
read_and_replace_with: .ruby-version
|
12
|
+
|
13
|
+
scripts:
|
14
|
+
rspec:
|
15
|
+
body: |
|
16
|
+
#!/usr/bin/env bash
|
17
|
+
set -eux
|
18
|
+
mkdir -p tmp/cache
|
19
|
+
export PATH=~/.rubies/$RUBY/bin:$PATH
|
20
|
+
bundle exec rspec
|
21
|
+
|
22
|
+
start_when:
|
23
|
+
'bundled':
|
24
|
+
script_key: bundle
|
25
|
+
|
26
|
+
|
27
|
+
trial_attachments:
|
28
|
+
logs:
|
29
|
+
include_match: log\/.*\.log$
|
30
|
+
content_type: text/plain
|
31
|
+
image-screenshots:
|
32
|
+
include_match: tmp\/capybara\/.*\.png$
|
33
|
+
content_type: image/png
|
34
|
+
html-screenshots:
|
35
|
+
include_match: tmp\/capybara\/.*\.html$
|
36
|
+
content_type: text/html
|
@@ -0,0 +1,29 @@
|
|
1
|
+
trial_attachments:
|
2
|
+
logs:
|
3
|
+
include_match: tmp\/checkstyle.json$
|
4
|
+
content_type: application/json
|
5
|
+
|
6
|
+
tree_attachments:
|
7
|
+
logs:
|
8
|
+
include_match: tmp\/checkstyle.json$
|
9
|
+
content_type: application/json
|
10
|
+
|
11
|
+
environment_variables:
|
12
|
+
RUBY:
|
13
|
+
read_and_replace_with: .ruby-version
|
14
|
+
RESULT_PATH: 'tmp/checkstyle.json'
|
15
|
+
|
16
|
+
max_trials: 1
|
17
|
+
|
18
|
+
scripts:
|
19
|
+
rubocop:
|
20
|
+
start_when:
|
21
|
+
'bundled':
|
22
|
+
script_key: bundle
|
23
|
+
body: |
|
24
|
+
#!/usr/bin/env bash
|
25
|
+
set -eux
|
26
|
+
mkdir -p tmp/cache
|
27
|
+
export PATH=~/.rubies/$RUBY/bin:$PATH
|
28
|
+
bundle exec rubocop --config .rubocop.yml \
|
29
|
+
--format json --out $RESULT_PATH --format progress
|
@@ -0,0 +1,15 @@
|
|
1
|
+
environment_variables:
|
2
|
+
RUBY:
|
3
|
+
read_and_replace_with: .ruby-version
|
4
|
+
|
5
|
+
scripts:
|
6
|
+
ruby-version:
|
7
|
+
body: cider-ci/bin/ruby_version
|
8
|
+
ruby-install:
|
9
|
+
exclusive_executor_resource: ruby-install_{{$RUBY}}
|
10
|
+
timeout: 20 Minutes
|
11
|
+
body: cider-ci/bin/ruby_install
|
12
|
+
start_when:
|
13
|
+
'ruby version checked':
|
14
|
+
script_key: ruby-version
|
15
|
+
|
data/lhs.gemspec
CHANGED
@@ -22,15 +22,15 @@ Gem::Specification.new do |s|
|
|
22
22
|
|
23
23
|
s.add_dependency 'lhc', '>= 3.6.0'
|
24
24
|
s.add_dependency 'lhc-core-interceptors', '>= 2.0.1'
|
25
|
+
s.add_dependency 'activesupport', '> 4'
|
25
26
|
|
26
27
|
s.add_development_dependency 'rspec-rails', '>= 3.0.0'
|
27
28
|
s.add_development_dependency 'rails', '>= 4.0.0'
|
28
29
|
s.add_development_dependency 'webmock'
|
29
|
-
s.add_development_dependency 'geminabox'
|
30
30
|
s.add_development_dependency 'pry'
|
31
|
-
s.add_development_dependency 'pry-byebug'
|
32
|
-
s.add_development_dependency 'ciderizer'
|
33
31
|
s.add_development_dependency 'capybara'
|
34
|
-
|
32
|
+
s.add_development_dependency 'rubocop'
|
33
|
+
s.add_development_dependency 'json', '>= 1.8.2'
|
34
|
+
|
35
35
|
s.license = 'GPL-3'
|
36
36
|
end
|
@@ -8,7 +8,7 @@ class LHS::Item < LHS::Proxy
|
|
8
8
|
def valid?(options = {})
|
9
9
|
options ||= {}
|
10
10
|
self.errors = nil
|
11
|
-
|
11
|
+
raise 'No validation endpoint found!' unless validation_endpoint
|
12
12
|
record = LHS::Record.for_url(validation_endpoint.url)
|
13
13
|
validation_params = validation_endpoint.options[:validates] == true ? { persist: false } : { validation_endpoint.options[:validates] => false }
|
14
14
|
params = validation_endpoint.options.fetch(:params, {})
|
@@ -38,7 +38,7 @@ class LHS::Item < LHS::Proxy
|
|
38
38
|
endpoint = embeded_endpoint if _data.href # take embeded first
|
39
39
|
endpoint ||= _data._record.find_endpoint(_data._raw)
|
40
40
|
validates = endpoint.options && endpoint.options.fetch(:validates, false)
|
41
|
-
|
41
|
+
raise 'Endpoint does not support validations!' unless validates
|
42
42
|
endpoint
|
43
43
|
end
|
44
44
|
|
@@ -18,7 +18,7 @@ class LHS::Record
|
|
18
18
|
|
19
19
|
# Process batches of entries
|
20
20
|
def find_in_batches(options = {})
|
21
|
-
|
21
|
+
raise 'No block given' unless block_given?
|
22
22
|
start = options[:start] || 1
|
23
23
|
batch_size = options[:batch_size] || LHS::Pagination::DEFAULT_LIMIT
|
24
24
|
params = options[:params] || {}
|
@@ -12,16 +12,11 @@ class LHS::Record
|
|
12
12
|
mattr_accessor :all
|
13
13
|
|
14
14
|
module ClassMethods
|
15
|
-
def endpoints
|
16
|
-
@endpoints ||= []
|
17
|
-
end
|
18
|
-
|
19
|
-
def endpoints=(endpoints)
|
20
|
-
@endpoints = endpoints
|
21
|
-
end
|
22
|
-
|
23
15
|
# Adds the endpoint to the list of endpoints.
|
24
16
|
def endpoint(url, options = nil)
|
17
|
+
class_attribute :endpoints unless defined? endpoints
|
18
|
+
self.endpoints ||= []
|
19
|
+
self.endpoints = endpoints.clone
|
25
20
|
endpoint = LHC::Endpoint.new(url, options)
|
26
21
|
sanity_check(endpoint)
|
27
22
|
endpoints.push(endpoint)
|
@@ -52,7 +47,7 @@ class LHS::Record
|
|
52
47
|
invalid = existing_endpoint.placeholders.sort == new_endpoint.placeholders.sort &&
|
53
48
|
existing_endpoint.url != new_endpoint.url
|
54
49
|
next unless invalid
|
55
|
-
|
50
|
+
raise "Clashing endpoints! Cannot differentiate between #{existing_endpoint.url} and #{new_endpoint.url}"
|
56
51
|
end
|
57
52
|
end
|
58
53
|
|
@@ -89,7 +84,7 @@ class LHS::Record
|
|
89
84
|
endpoint.placeholders.length
|
90
85
|
end
|
91
86
|
bases = endpoints[endpoints.keys.min]
|
92
|
-
|
87
|
+
raise 'Multiple base endpoints found' if bases.count > 1
|
93
88
|
bases.first
|
94
89
|
end
|
95
90
|
end
|
@@ -38,8 +38,8 @@ class LHS::Record
|
|
38
38
|
|
39
39
|
def get_unique_item!(data)
|
40
40
|
if data._proxy.is_a?(LHS::Collection)
|
41
|
-
|
42
|
-
data.first ||
|
41
|
+
raise LHC::NotFound.new('Requested unique item. Multiple were found.', data._request.response) if data.length > 1
|
42
|
+
data.first || raise(LHC::NotFound.new('No item was found.', data._request.response))
|
43
43
|
else
|
44
44
|
data
|
45
45
|
end
|
@@ -25,7 +25,7 @@ class LHS::Record
|
|
25
25
|
params = params.dup.merge(limit: 1)
|
26
26
|
data = request(options.merge(params: params))
|
27
27
|
if data._proxy.is_a?(LHS::Collection)
|
28
|
-
data.first ||
|
28
|
+
data.first || raise(LHC::NotFound.new('No item was found.', data._request.response))
|
29
29
|
else
|
30
30
|
data._record.new(data)
|
31
31
|
end
|
@@ -234,7 +234,7 @@ class LHS::Record
|
|
234
234
|
error_class = LHC::Error.find(response)
|
235
235
|
error = error_class.new(error_class, response)
|
236
236
|
handlers = handlers.to_a.select { |error_handler| error.is_a? error_handler.class }
|
237
|
-
|
237
|
+
raise(error) unless handlers.any?
|
238
238
|
handlers.each do |handler|
|
239
239
|
handlers_return = handler.call(response)
|
240
240
|
return_data = handlers_return if handlers_return.present?
|
@@ -251,7 +251,7 @@ class LHS::Record
|
|
251
251
|
next unless record
|
252
252
|
records.push(record)
|
253
253
|
end
|
254
|
-
|
254
|
+
raise 'Found more than one record that could be used to do the request' if records.uniq.count > 1
|
255
255
|
records.uniq.first
|
256
256
|
else # Hash
|
257
257
|
LHS::Record.for_url(options[:url])
|
data/lib/lhs/data.rb
CHANGED
@@ -79,7 +79,9 @@ class LHS::Data
|
|
79
79
|
private
|
80
80
|
|
81
81
|
def collection_proxy?(input)
|
82
|
-
|
82
|
+
(input.is_a?(Hash) && input[items_key]) ||
|
83
|
+
input.is_a?(Array) ||
|
84
|
+
_raw.is_a?(Array)
|
83
85
|
end
|
84
86
|
|
85
87
|
def root_item
|
@@ -110,7 +112,7 @@ class LHS::Data
|
|
110
112
|
end
|
111
113
|
|
112
114
|
def raw_from_input(input)
|
113
|
-
if input.is_a?(String) && input.
|
115
|
+
if input.is_a?(String) && !input.empty?
|
114
116
|
raw_from_json_string(input)
|
115
117
|
elsif defined?(input._raw)
|
116
118
|
input._raw
|
data/lib/lhs/item.rb
CHANGED
data/lib/lhs/pagination.rb
CHANGED
@@ -34,11 +34,11 @@ class LHS::Pagination
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def next_offset
|
37
|
-
|
37
|
+
raise 'to be implemented in subclass'
|
38
38
|
end
|
39
39
|
|
40
40
|
def current_page
|
41
|
-
|
41
|
+
raise 'to be implemented in subclass'
|
42
42
|
end
|
43
43
|
|
44
44
|
def first_page
|
data/lib/lhs/proxy.rb
CHANGED
data/lib/lhs/version.rb
CHANGED
data/spec/data/parent_spec.rb
CHANGED
@@ -32,10 +32,4 @@ describe LHS::Item do
|
|
32
32
|
feedback = Feedback.build('name' => 'BB8')
|
33
33
|
expect(feedback._data._raw.keys).to include(:name)
|
34
34
|
end
|
35
|
-
|
36
|
-
it 'can handle ActionController::Parameters' do
|
37
|
-
params = ActionController::Parameters.new('name' => 'Han')
|
38
|
-
feedback = Feedback.build(params)
|
39
|
-
expect(feedback._data._raw.keys).to include(:name)
|
40
|
-
end
|
41
35
|
end
|
data/spec/item/save_spec.rb
CHANGED
@@ -46,11 +46,12 @@ describe LHS::Item do
|
|
46
46
|
|
47
47
|
let(:failing_validation) do
|
48
48
|
stub_request(:post, "#{datastore}/v2/users?persist=false")
|
49
|
-
.to_return(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
.to_return(
|
50
|
+
status: 400,
|
51
|
+
body: {
|
52
|
+
field_errors: [{ code: "UNSUPPORTED_PROPERTY_VALUE", "path" => ["email"] }]
|
53
|
+
}.to_json
|
54
|
+
)
|
54
55
|
end
|
55
56
|
|
56
57
|
context 'valid data' do
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'rails_helper'
|
2
|
+
|
3
|
+
describe LHS::Record do
|
4
|
+
context 'inherit endpoints' do
|
5
|
+
before(:each) do
|
6
|
+
class Base < LHS::Record
|
7
|
+
endpoint 'records/:id'
|
8
|
+
end
|
9
|
+
|
10
|
+
class Example < Base
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'inherits endpoints based on ruby class_attribute behaviour' do
|
15
|
+
request = stub_request(:get, 'http://records/1').to_return(body: [].to_json)
|
16
|
+
Example.find(1)
|
17
|
+
Base.find(1)
|
18
|
+
assert_requested(request, times: 2)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'define endpoints in subclass' do
|
23
|
+
before(:each) do
|
24
|
+
class Base < LHS::Record
|
25
|
+
endpoint 'records/:id'
|
26
|
+
end
|
27
|
+
|
28
|
+
class Example < Base
|
29
|
+
endpoint 'records'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'inherits endpoints based on ruby class_attribute behaviour' do
|
34
|
+
stub_request(:get, 'http://records?color=blue').to_return(body: [].to_json)
|
35
|
+
Example.where(color: 'blue')
|
36
|
+
expect(
|
37
|
+
-> { Base.all }
|
38
|
+
).to raise_error(RuntimeError, 'Compilation incomplete. Unable to find value for id.')
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'clashing endpoints between super and subclass' do
|
43
|
+
before(:each) do
|
44
|
+
class Base < LHS::Record
|
45
|
+
endpoint 'records'
|
46
|
+
end
|
47
|
+
|
48
|
+
class Example < Base
|
49
|
+
endpoint 'examples/:id'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'inherits endpoints based on ruby class_attribute behaviour' do
|
54
|
+
request = stub_request(:get, 'http://records?limit=100').to_return(body: [].to_json)
|
55
|
+
Base.all
|
56
|
+
assert_requested(request)
|
57
|
+
|
58
|
+
request = stub_request(:get, 'http://examples/1').to_return(body: {}.to_json)
|
59
|
+
Example.find(1)
|
60
|
+
assert_requested(request)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/spec/record/mapping_spec.rb
CHANGED
@@ -65,7 +65,8 @@ describe LHS::Record do
|
|
65
65
|
'href' => "#{datastore}/agbs/547f02c61c266c4830ea6ce7",
|
66
66
|
'preceding_agb' => { 'href' => preceding_agb_url },
|
67
67
|
'binary_url_pdf_de' => 'de'
|
68
|
-
}.to_json
|
68
|
+
}.to_json
|
69
|
+
)
|
69
70
|
|
70
71
|
# includes request
|
71
72
|
stub_request(:get, preceding_agb_url).to_return(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhs/graphs/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lhc
|
@@ -39,49 +39,49 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 2.0.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
48
|
-
type: :
|
47
|
+
version: '4'
|
48
|
+
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name: rails
|
56
|
+
name: rspec-rails
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 3.0.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 3.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rails
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 4.0.0
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 4.0.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: webmock
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: capybara
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
115
|
- - ">="
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: rubocop
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -137,19 +137,19 @@ dependencies:
|
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: json
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - ">="
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version:
|
145
|
+
version: 1.8.2
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version:
|
152
|
+
version: 1.8.2
|
153
153
|
description: Rails gem providing an easy, active-record-like interface for http json
|
154
154
|
services
|
155
155
|
email:
|
@@ -161,18 +161,20 @@ files:
|
|
161
161
|
- ".gitignore"
|
162
162
|
- ".rubocop.localch.yml"
|
163
163
|
- ".rubocop.yml"
|
164
|
+
- ".ruby-version"
|
164
165
|
- Gemfile
|
165
166
|
- README.md
|
166
167
|
- Rakefile
|
167
168
|
- cider-ci.yml
|
169
|
+
- cider-ci/bin/bundle
|
170
|
+
- cider-ci/bin/ruby_install
|
171
|
+
- cider-ci/bin/ruby_version
|
168
172
|
- cider-ci/jobs/rspec.yml
|
169
173
|
- cider-ci/jobs/rubocop.yml
|
170
|
-
- cider-ci/
|
171
|
-
- cider-ci/
|
172
|
-
- cider-ci/
|
173
|
-
- cider-ci/
|
174
|
-
- cider-ci/scripts/ruby-version.yml
|
175
|
-
- cider-ci/scripts/tmp-cache.yml
|
174
|
+
- cider-ci/task_components/bundle.yml
|
175
|
+
- cider-ci/task_components/rspec.yml
|
176
|
+
- cider-ci/task_components/rubocop.yml
|
177
|
+
- cider-ci/task_components/ruby.yml
|
176
178
|
- lhs.gemspec
|
177
179
|
- lib/lhs.rb
|
178
180
|
- lib/lhs/collection.rb
|
@@ -291,6 +293,7 @@ files:
|
|
291
293
|
- spec/record/create_spec.rb
|
292
294
|
- spec/record/creation_failed_spec.rb
|
293
295
|
- spec/record/definitions_spec.rb
|
296
|
+
- spec/record/endpoint_inheritance_spec.rb
|
294
297
|
- spec/record/endpoint_misconfiguration_spec.rb
|
295
298
|
- spec/record/endpoint_options_spec.rb
|
296
299
|
- spec/record/endpoints_spec.rb
|
@@ -352,7 +355,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
352
355
|
requirements:
|
353
356
|
- Ruby >= 2.0.0
|
354
357
|
rubyforge_project:
|
355
|
-
rubygems_version: 2.
|
358
|
+
rubygems_version: 2.5.1
|
356
359
|
signing_key:
|
357
360
|
specification_version: 4
|
358
361
|
summary: Rails gem providing an easy, active-record-like interface for http json services
|
@@ -437,6 +440,7 @@ test_files:
|
|
437
440
|
- spec/record/create_spec.rb
|
438
441
|
- spec/record/creation_failed_spec.rb
|
439
442
|
- spec/record/definitions_spec.rb
|
443
|
+
- spec/record/endpoint_inheritance_spec.rb
|
440
444
|
- spec/record/endpoint_misconfiguration_spec.rb
|
441
445
|
- spec/record/endpoint_options_spec.rb
|
442
446
|
- spec/record/endpoints_spec.rb
|
data/cider-ci/scripts/bundle.yml
DELETED
data/cider-ci/scripts/rspec.yml
DELETED