Skip to content

Commit de1c294

Browse files
committed
fix rubocop linting issues
1 parent 1126252 commit de1c294

14 files changed

+36
-23
lines changed

.rubocop.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ AllCops:
55
Exclude:
66
- Gemfile
77

8+
Style/Encoding:
9+
Enabled: false
810
Style/SymbolArray:
911
EnforcedStyle: brackets
1012
Style/LineLength:

lib/cli.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ def to_struct(hash)
5151
# @param mockserver [Boolean] true to use mockserver, false to use proxy
5252
# @yieldparam [AbstractClient] a mockserver or a proxy client
5353
# @yieldparam [Struct] a struct created from options hash
54-
def execute_command(mockserver = false, data_required = false, error_msg = '--data option must be provided', &_)
54+
def execute_command(mockserver = false, data_required = false, error_msg = '--data option must be provided', &_arg)
5555
print_parameters(options)
5656
struct_options = to_struct({ data: nil }.merge(options))
5757
if data_required && !options['data']

lib/mockserver/model/enum.rb

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ def pre_process_value(value)
3535
def to_s
3636
@value.to_s
3737
end
38+
39+
def as_json(_arg)
40+
@value.to_s
41+
end
42+
43+
def to_json(_arg)
44+
"\"#{@value}\""
45+
end
3846
end
3947

4048
# Subclass of Enum that has a list of symbols as allowed values.

lib/mockserver/model/expectation.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def populate_from_payload(payload)
4646
# Method to setup the request on the expectation object
4747
# @yieldparam [Request] the request that this expectation references
4848
# @return [Expectation] this object according to the the builder pattern
49-
def request(&_)
49+
def request(&_arg)
5050
if block_given?
5151
@request ||= Request.new
5252
yield @request
@@ -57,7 +57,7 @@ def request(&_)
5757
# Method to setup the response on the expectation object
5858
# @yieldparam [Response] the response that this expectation references
5959
# @return [Expectation] this object according to the the builder pattern
60-
def response(&_)
60+
def response(&_arg)
6161
if block_given?
6262
@response ||= Response.new
6363
yield @response
@@ -68,7 +68,7 @@ def response(&_)
6868
# Method to setup the request on the expectation object
6969
# @yieldparam [Forward] the forward object that this expectation references
7070
# @return [Expectation] this object according to the the builder pattern
71-
def forward(&_)
71+
def forward(&_arg)
7272
if block_given?
7373
@forward ||= Forward.new
7474
yield @forward
@@ -96,8 +96,8 @@ def forward=(forward)
9696

9797
# Override to_json method
9898
# @return [String] the json representation for this object
99-
def to_json(*p)
100-
to_hash.to_json(*p)
99+
def to_json(*param)
100+
to_hash.to_json(*param)
101101
end
102102

103103
# Convert to hash
@@ -124,7 +124,7 @@ def child_class
124124

125125
# DSL method for creating expectation
126126
module DSL
127-
def expectation(&_)
127+
def expectation(&_arg)
128128
expectation = Expectation.new
129129
yield expectation if block_given?
130130
expectation

lib/mockserver/model/forward.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Forward < Hashie::Dash
3232

3333
# DSL methods for forward
3434
module DSL
35-
def forward(&_)
35+
def forward(&_arg)
3636
obj = Forward.new
3737
yield obj if block_given?
3838
obj

lib/mockserver/model/request.rb

+3-6
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@ class Request < Hashie::Trash
3232
property :cookies, default: Cookies.new([])
3333
property :headers, default: Headers.new([])
3434
property :body, transform_with: (lambda do |body|
35-
if body && body.type.to_s == 'BINARY'
35+
if body&.type&.to_s == 'BINARY'
3636
body.type = :STRING
3737
body.value = Base64.decode64(body.value)
3838
end
39-
4039
body
4140
end)
4241

@@ -67,7 +66,7 @@ def child_class
6766

6867
# DSL methods related to requests
6968
module DSL
70-
def request(method, path, &_)
69+
def request(method, path, &_arg)
7170
obj = Request.new(method: method, path: path)
7271
yield obj if block_given?
7372
obj
@@ -76,9 +75,7 @@ def request(method, path, &_)
7675
def request_from_json(payload)
7776
body = payload['body']
7877

79-
if body && body.is_a?(String)
80-
payload['body'] = { 'type' => :STRING, 'value' => body }
81-
end
78+
payload['body'] = { 'type' => :STRING, 'value' => body } if body&.is_a?(String)
8279

8380
request = Request.new(symbolize_keys(payload))
8481
yield request if block_given?

lib/mockserver/model/response.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Response < Hashie::Dash
3232

3333
# DSL Methods for a response
3434
module DSL
35-
def response(&_)
35+
def response(&_arg)
3636
obj = Response.new
3737
yield obj if block_given?
3838
obj

lib/mockserver/model/times.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def at_least(num)
5454
Times.new(remaining_times: num, unlimited: true)
5555
end
5656

57-
def times(&_)
57+
def times(&_arg)
5858
obj = once
5959
yield obj if block_given?
6060
obj

lib/mockserver/utility_methods.rb

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module MockServer::UtilityMethods
1616
# @return [Hash] the transformed hash
1717
# rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
1818
def camelized_hash(obj)
19-
obj = obj && obj.respond_to?(:to_hash) ? obj.to_hash : obj
19+
obj = obj&.respond_to?(:to_hash) ? obj.to_hash : obj
2020

2121
if obj.is_a?(Hash)
2222
obj.each_with_object({}) do |(k, v), acc|
@@ -58,3 +58,4 @@ def parse_string_to_json(response)
5858
response
5959
end
6060
end
61+
# rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength

mockserver-client.gemspec

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
# coding: utf-8
21
# frozen_string_literal: true
32

4-
lib = File.expand_path('../lib', __FILE__)
3+
lib = File.expand_path('lib', __dir__)
54
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
65
require 'mockserver/version'
76

@@ -14,8 +13,8 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
1413
spec.summary = 'A Ruby client for MockServer'
1514
spec.description = 'A Ruby Client for MockServer that enables easy mocking of any system you integrate with via HTTP or HTTPS (i.e. services, web sites, etc)'
1615

17-
spec.required_ruby_version = '>= 2.0'
18-
spec.required_rubygems_version = '~> 2.0'
16+
spec.required_ruby_version = '>= 2.3'
17+
spec.required_rubygems_version = '~> 2.3'
1918

2019
spec.files = `git ls-files -z`.split("\x0")
2120
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -25,16 +24,18 @@ Gem::Specification.new do |spec| # rubocop:disable Metrics/BlockLength
2524
spec.add_development_dependency 'bundler', '~> 1'
2625
spec.add_development_dependency 'rake', '~> 10.3'
2726
spec.add_development_dependency 'rspec', '~> 3.0'
27+
spec.add_development_dependency 'rubocop', '~> 0.23'
2828
spec.add_development_dependency 'simplecov', '~> 0.8'
2929
spec.add_development_dependency 'webmock'
30-
spec.add_development_dependency 'rubocop', '~> 0.23'
3130

31+
spec.add_dependency 'activesupport', '>= 4.1'
32+
spec.add_dependency 'colorize', '~> 0.7'
3233
spec.add_dependency 'hashie', '~> 3.0'
3334
spec.add_dependency 'json', '~> 1.8'
3435
spec.add_dependency 'json_pure', '~> 1.8'
3536
spec.add_dependency 'activesupport', '~> 4.1'
3637
spec.add_dependency 'rest-client'
3738
spec.add_dependency 'logging_factory', '~> 0.0.2'
39+
spec.add_dependency 'rest-client', '>= 1.7'
3840
spec.add_dependency 'thor', '~> 0.19'
39-
spec.add_dependency 'colorize', '~> 0.7'
4041
end

spec/integration/mock_client_integration_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,4 @@ def setup_request(request)
170170
it_behaves_like 'a successful mock response'
171171
end
172172
end
173+
# rubocop:enable Metrics/BlockLength

spec/mockserver/builder_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,4 @@
135135
end
136136
end
137137
end
138+
# rubocop:enable Metrics/BlockLength

spec/mockserver/mock_client_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@
7979
expect(client.retrieve(request(:POST, '/login')).code).to eq(200)
8080
end
8181
end
82+
# rubocop:enable Metrics/BlockLength

spec/mockserver/model/dsl_spec.rb

+1
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,4 @@
5151
end
5252
end
5353
end
54+
# rubocop:enable Metrics/BlockLength

0 commit comments

Comments
 (0)