lhc 3.4.0 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.localch.yml +190 -0
  3. data/.rubocop.yml +10 -0
  4. data/cider-ci.yml +2 -1
  5. data/cider-ci/jobs/rspec.yml +48 -0
  6. data/cider-ci/jobs/rubocop.yml +55 -0
  7. data/cider-ci/scripts/bundle.yml +2 -0
  8. data/cider-ci/scripts/github_comment.yml +6 -0
  9. data/cider-ci/scripts/rspec.yml +4 -0
  10. data/cider-ci/scripts/rubocop.yml +5 -0
  11. data/cider-ci/scripts/ruby-version.yml +2 -0
  12. data/cider-ci/scripts/tmp-cache.yml +2 -0
  13. data/lhc.gemspec +2 -1
  14. data/lib/lhc.rb +1 -1
  15. data/lib/lhc/concerns/lhc/basic_methods.rb +4 -6
  16. data/lib/lhc/concerns/lhc/formats.rb +0 -2
  17. data/lib/lhc/endpoint.rb +8 -6
  18. data/lib/lhc/error.rb +3 -1
  19. data/lib/lhc/errors/parser_error.rb +4 -0
  20. data/lib/lhc/formats/json.rb +18 -4
  21. data/lib/lhc/interceptor.rb +2 -0
  22. data/lib/lhc/interceptor_processor.rb +1 -1
  23. data/lib/lhc/request.rb +12 -10
  24. data/lib/lhc/response.rb +3 -9
  25. data/lib/lhc/version.rb +1 -1
  26. data/non_rails_spec/request/request_spec.rb +2 -2
  27. data/spec/basic_methods/delete_spec.rb +4 -6
  28. data/spec/basic_methods/get_spec.rb +3 -6
  29. data/spec/basic_methods/post_spec.rb +7 -9
  30. data/spec/basic_methods/put_spec.rb +7 -9
  31. data/spec/basic_methods/request_spec.rb +2 -4
  32. data/spec/config/endpoints_spec.rb +13 -16
  33. data/spec/config/placeholders_spec.rb +9 -11
  34. data/spec/dummy/bin/rails +1 -1
  35. data/spec/dummy/config.ru +1 -1
  36. data/spec/dummy/config/initializers/cookies_serializer.rb +1 -1
  37. data/spec/endpoint/compile_spec.rb +3 -5
  38. data/spec/endpoint/match_spec.rb +10 -12
  39. data/spec/endpoint/placeholders_spec.rb +1 -3
  40. data/spec/endpoint/remove_interpolated_params_spec.rb +2 -3
  41. data/spec/endpoint/values_as_params_spec.rb +2 -4
  42. data/spec/error/find_spec.rb +37 -39
  43. data/spec/error/response_spec.rb +0 -2
  44. data/spec/error/timeout_spec.rb +1 -3
  45. data/spec/interceptors/after_request_spec.rb +2 -4
  46. data/spec/interceptors/after_response_spec.rb +3 -5
  47. data/spec/interceptors/before_request_spec.rb +2 -4
  48. data/spec/interceptors/before_response_spec.rb +2 -4
  49. data/spec/interceptors/default_interceptors_spec.rb +3 -5
  50. data/spec/interceptors/define_spec.rb +4 -6
  51. data/spec/interceptors/response_competition_spec.rb +6 -7
  52. data/spec/interceptors/return_response_spec.rb +8 -11
  53. data/spec/request/encoding_spec.rb +1 -4
  54. data/spec/request/error_handling_spec.rb +13 -2
  55. data/spec/request/headers_spec.rb +1 -2
  56. data/spec/request/option_dup_spec.rb +2 -3
  57. data/spec/request/parallel_requests_spec.rb +2 -2
  58. data/spec/request/url_patterns_spec.rb +4 -5
  59. data/spec/response/body_spec.rb +2 -4
  60. data/spec/response/code_spec.rb +2 -4
  61. data/spec/response/data_spec.rb +2 -4
  62. data/spec/response/effective_url_spec.rb +1 -3
  63. data/spec/response/headers_spec.rb +2 -4
  64. data/spec/response/options_spec.rb +2 -4
  65. data/spec/response/success_spec.rb +2 -3
  66. data/spec/response/time_spec.rb +3 -5
  67. data/spec/spec_helper.rb +1 -1
  68. data/spec/support/reset_config.rb +0 -2
  69. data/spec/timeouts/no_signal_spec.rb +1 -3
  70. data/spec/timeouts/timings_spec.rb +27 -33
  71. metadata +27 -4
  72. data/cider-ci/contexts/rspec.yml +0 -19
  73. data/cider-ci/jobs/tests.yml +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb463da7364d39d932831f54620966aa82caafa6
4
- data.tar.gz: 2af2b5e6e49064dc6cc6f116f1d4605496dd1dce
3
+ metadata.gz: b266f3f9dca6060abde6e24879a26487caec842e
4
+ data.tar.gz: 45fab92b295af92fdc2bc60488f1551471851c30
5
5
  SHA512:
6
- metadata.gz: 723ca264ea852ba2c36f5a76c6775f0943a1a44395567b1701e40e54be6a4784b3d6b10a3c5b76727864987926d394b2ec2506066f633c57d63db6bab5e63947
7
- data.tar.gz: d18edd4d615302b5c39c61c8d148b0880dcec0cd8e0be14fb0e151a87f90e9bed9dc75863d6955588810c2e84d3e61da068441c23c337885fae1d16550943af0
6
+ metadata.gz: 1d471705267c62e35f0a979c341f6a107cd7c03060698e21f72031d4d4aca57d4cbbc8c45aa1587cb01846fc18bb688acd33b893a2e7d545319717081bea113f
7
+ data.tar.gz: 6b913de77b69c93878445e073ae41363e2d0e6d31ca6baa4d7effec68b2142c20aef545426ac6798f8b62738612f1661f04239c21a0c90b762700da2b9cc13da
@@ -0,0 +1,190 @@
1
+ # This is master rubocop configuration.
2
+ # DO NOT EDIT THIS FILE - it WILL be overwriten on every config update
3
+ AllCops:
4
+ TargetRubyVersion: 2.1
5
+ DisplayCopNames: true
6
+ DisplayStyleGuide: true
7
+ Include:
8
+ - '**/Rakefile'
9
+ - '**/config.ru'
10
+ - '**/Capfile'
11
+ Exclude:
12
+ - 'db/**/*'
13
+ - 'script/**/*'
14
+ - 'vendor/bundle/**/*'
15
+ - 'bin/**/*'
16
+ - 'config/unicorn.rb'
17
+ - 'config/compass.rb'
18
+ - 'Rakefile'
19
+
20
+ Rails:
21
+ Enabled: true
22
+
23
+ require:
24
+ - rubocop-rspec
25
+
26
+ Lint/HandleExceptions:
27
+ Exclude:
28
+ - spec/**/*
29
+
30
+ Metrics/LineLength:
31
+ Enabled: false
32
+
33
+ Metrics/AbcSize:
34
+ Enabled: false
35
+
36
+ Metrics/MethodLength:
37
+ Enabled: false
38
+
39
+ Metrics/CyclomaticComplexity:
40
+ Enabled: false
41
+
42
+ Metrics/PerceivedComplexity:
43
+ Enabled: false
44
+
45
+ Metrics/ClassLength:
46
+ Enabled: false
47
+
48
+ Metrics/ModuleLength:
49
+ Enabled: false
50
+
51
+ Metrics/ParameterLists:
52
+ Enabled: false
53
+
54
+ Metrics/BlockNesting:
55
+ Enabled: false
56
+
57
+ Performance/StringReplacement:
58
+ Enabled: false
59
+
60
+ Performance/TimesMap:
61
+ Enabled: false
62
+
63
+ Performance/RedundantBlockCall:
64
+ Enabled: false
65
+
66
+ Performance/RedundantMatch:
67
+ Enabled: false
68
+
69
+ Performance/RedundantMerge:
70
+ Enabled: false
71
+
72
+ Performance/Casecmp:
73
+ Enabled: false
74
+
75
+ Style/MultilineOperationIndentation:
76
+ EnforcedStyle: indented
77
+
78
+ Style/StringLiterals:
79
+ Enabled: false
80
+
81
+ Style/RegexpLiteral:
82
+ Exclude:
83
+ - spec/**/*
84
+
85
+ Style/DotPosition:
86
+ EnforcedStyle: leading
87
+
88
+ Style/AlignParameters:
89
+ Enabled: false
90
+
91
+ Style/NumericLiterals:
92
+ Enabled: false
93
+
94
+ Style/WordArray:
95
+ Enabled: false
96
+
97
+ Style/EmptyLinesAroundClassBody:
98
+ Enabled: false
99
+
100
+ Style/Next:
101
+ Enabled: false
102
+
103
+ Style/PercentLiteralDelimiters:
104
+ Enabled: false
105
+
106
+ Style/GlobalVars:
107
+ Enabled: false
108
+
109
+ Style/CommentAnnotation:
110
+ Enabled: false
111
+
112
+ Style/SymbolProc:
113
+ Enabled: false
114
+
115
+ Style/DoubleNegation:
116
+ Enabled: false
117
+
118
+ Style/FormatString:
119
+ Enabled: false
120
+
121
+ Style/AsciiComments:
122
+ Enabled: false
123
+
124
+ Style/BarePercentLiterals:
125
+ Enabled: false
126
+
127
+ Style/SingleLineBlockParams:
128
+ Enabled: false
129
+
130
+ Style/MultilineBlockChain:
131
+ Enabled: false
132
+
133
+ Style/UnneededCapitalW:
134
+ Enabled: false
135
+
136
+ Style/UnneededPercentQ:
137
+ Enabled: false
138
+
139
+ Style/BlockDelimiters:
140
+ Exclude:
141
+ - spec/**/*
142
+
143
+ Style/BracesAroundHashParameters:
144
+ EnforcedStyle: context_dependent
145
+
146
+ Style/IfUnlessModifier:
147
+ Enabled: false
148
+
149
+ Style/ClassAndModuleChildren:
150
+ Enabled: false
151
+
152
+ Style/Documentation:
153
+ Enabled: false
154
+
155
+ Style/GuardClause:
156
+ Enabled: false
157
+
158
+ Style/AccessorMethodName:
159
+ Exclude:
160
+ - spec/support/pages/**/*
161
+
162
+ Style/NegatedIf:
163
+ Enabled: false
164
+
165
+ Style/MutableConstant:
166
+ Enabled: false
167
+
168
+ Style/ConditionalAssignment:
169
+ Enabled: false
170
+
171
+ Style/IndentArray:
172
+ EnforcedStyle: consistent
173
+
174
+ Style/MultilineMethodCallIndentation:
175
+ EnforcedStyle: indented
176
+
177
+ RSpec/DescribeClass:
178
+ Exclude:
179
+ - spec/views/**/*
180
+ - spec/routing/**/*
181
+ - spec/requests/**/*
182
+ - spec/features/**/*
183
+
184
+ RSpec/FilePath:
185
+ Enabled: false
186
+
187
+ Rails/Output:
188
+ Exclude:
189
+ - 'config/application.rb'
190
+ - 'config/initializers/asset_manifest_warning.rb'
@@ -0,0 +1,10 @@
1
+ # This is project specific rubocop configuration file.
2
+ # You can tweak project settings here
3
+ inherit_from:
4
+ - ./.rubocop.localch.yml
5
+
6
+ Lint/IneffectiveAccessModifier:
7
+ Enabled: false
8
+
9
+ Rails:
10
+ Enabled: false
@@ -1,3 +1,4 @@
1
1
  jobs:
2
2
  _cider-ci_include:
3
- - cider-ci/jobs/tests.yml
3
+ - cider-ci/jobs/rubocop.yml
4
+ - cider-ci/jobs/rspec.yml
@@ -0,0 +1,48 @@
1
+ rspec:
2
+ name: 'RSPec tests'
3
+
4
+ run-on:
5
+ - type: branch
6
+ include-match: ^.*$
7
+
8
+ 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
+
20
+ scripts:
21
+ rspec:
22
+ start-when:
23
+ - script: bundle
24
+ - script: ruby-version
25
+ - script: tmp-cache
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/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/*
@@ -0,0 +1,55 @@
1
+ rubocop:
2
+ name: 'Rubocop analysis'
3
+
4
+ run-on:
5
+ - type: branch
6
+ include-match: ^.*$
7
+
8
+ 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
+
49
+ tasks:
50
+ rubocop:
51
+ scripts:
52
+ rubocop: {}
53
+
54
+ github_comment: {}
55
+
@@ -0,0 +1,2 @@
1
+ bundle:
2
+ body: sed 's/^source.*/source "http\:\/\/52.29.7.59:9292"/g' Gemfile > Gemfile.tmp ; mv Gemfile.tmp Gemfile && bundle install
@@ -0,0 +1,6 @@
1
+ github_comment:
2
+ ignore-state: true
3
+ body: |
4
+ #!/usr/bin/env bash
5
+
6
+ bundle exec rake checkstyle
@@ -0,0 +1,4 @@
1
+ rspec:
2
+ body: |
3
+ #!/usr/bin/env bash
4
+ RAILS_ENV=test bundle exec rspec $CIDER_CI_TASK_FILE
@@ -0,0 +1,5 @@
1
+ rubocop:
2
+ body: |
3
+ #!/usr/bin/env bash
4
+
5
+ bundle exec rubocop --config .rubocop.yml --format json --out $RESULT_PATH --format progress
@@ -0,0 +1,2 @@
1
+ ruby-version:
2
+ body: ruby --version
@@ -0,0 +1,2 @@
1
+ tmp-cache:
2
+ body: mkdir -p tmp/cache
@@ -29,4 +29,5 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency 'webmock'
30
30
  s.add_development_dependency 'geminabox'
31
31
  s.add_development_dependency 'pry'
32
- end
32
+ s.add_development_dependency 'ciderizer'
33
+ end
data/lib/lhc.rb CHANGED
@@ -1,4 +1,4 @@
1
- Dir[File.dirname(__FILE__) + '/lhc/concerns/lhc/*.rb'].sort.each {|file| require file }
1
+ Dir[File.dirname(__FILE__) + '/lhc/concerns/lhc/*.rb'].sort.each { |file| require file }
2
2
 
3
3
  module LHC
4
4
  include BasicMethods
@@ -1,12 +1,10 @@
1
1
  require 'active_support'
2
2
 
3
3
  module LHC
4
-
5
4
  module BasicMethods
6
5
  extend ActiveSupport::Concern
7
6
 
8
7
  module ClassMethods
9
-
10
8
  def request(options)
11
9
  if options.is_a? Array
12
10
  parallel_requests(options)
@@ -18,8 +16,8 @@ module LHC
18
16
  [:get, :post, :put, :delete].each do |http_method|
19
17
  define_method(http_method) do |url, options = {}|
20
18
  request(options.merge(
21
- url: url,
22
- method: http_method
19
+ url: url,
20
+ method: http_method
23
21
  ))
24
22
  end
25
23
  end
@@ -29,8 +27,8 @@ module LHC
29
27
  def parallel_requests(options)
30
28
  hydra = Typhoeus::Hydra.hydra
31
29
  requests = []
32
- options.each do |options|
33
- request = LHC::Request.new(options, false)
30
+ options.each do |option|
31
+ request = LHC::Request.new(option, false)
34
32
  requests << request
35
33
  hydra.queue request.raw
36
34
  end
@@ -1,10 +1,8 @@
1
1
  module LHC
2
-
3
2
  module Formats
4
3
  extend ActiveSupport::Concern
5
4
 
6
5
  module ClassMethods
7
-
8
6
  def json
9
7
  JsonFormat
10
8
  end
@@ -13,11 +13,12 @@ class LHC::Endpoint
13
13
 
14
14
  def compile(params)
15
15
  url.gsub(PLACEHOLDER) do |match|
16
- replacement = if params.is_a? Proc
17
- params.call(match)
18
- else
19
- find_value(match, params)
20
- end
16
+ replacement =
17
+ if params.is_a? Proc
18
+ params.call(match)
19
+ else
20
+ find_value(match, params)
21
+ end
21
22
  replacement || fail("Compilation incomplete. Unable to find value for #{match.gsub(':', '')}.")
22
23
  end
23
24
  end
@@ -34,7 +35,8 @@ class LHC::Endpoint
34
35
  removed = {}
35
36
  url.scan(PLACEHOLDER) do |match|
36
37
  match = match.gsub(/^\:/, '')
37
- if value = find_value(match, params)
38
+ value = find_value(match, params)
39
+ if value
38
40
  removed[match.to_sym] = value
39
41
  params.delete(match.to_sym)
40
42
  end