From 2ff6a3c0e82fe4271f56eb5f434e8a2a9d81ee3f Mon Sep 17 00:00:00 2001 From: Bartosz Date: Mon, 12 Aug 2024 10:40:43 +0200 Subject: [PATCH] bump dependencies (#269) --- .rubocop.yml | 8 +++-- Gemfile.lock | 24 ++++--------- lib/castle.rb | 2 +- spec/integration/rails/rails_spec.rb | 9 ++++- spec/lib/castle/client_spec.rb | 24 ++++++------- spec/lib/castle/command_spec.rb | 6 ++-- .../castle/commands/approve_device_spec.rb | 4 +-- spec/lib/castle/commands/authenticate_spec.rb | 30 ++++++++-------- .../castle/commands/end_impersonation_spec.rb | 24 ++++++------- spec/lib/castle/commands/filter_spec.rb | 30 ++++++++-------- spec/lib/castle/commands/get_device_spec.rb | 4 +-- .../commands/get_devices_for_user_spec.rb | 4 +-- spec/lib/castle/commands/log_spec.rb | 30 ++++++++-------- .../lib/castle/commands/report_device_spec.rb | 4 +-- spec/lib/castle/commands/risk_spec.rb | 30 ++++++++-------- .../commands/start_impersonation_spec.rb | 24 ++++++------- spec/lib/castle/commands/track_spec.rb | 36 +++++++++---------- spec/lib/castle/configuration_spec.rb | 2 +- spec/lib/castle/context/get_default_spec.rb | 14 ++++---- spec/lib/castle/core/send_request_spec.rb | 6 ++-- spec/lib/castle/failover/strategy_spec.rb | 10 +++--- spec/lib/castle/headers/format_spec.rb | 10 +++--- .../castle/singleton_configuration_spec.rb | 2 +- spec/lib/castle/utils/clone_spec.rb | 2 +- spec/lib/castle/utils/merge_spec.rb | 2 +- spec/lib/castle/verdict_spec.rb | 6 ++-- spec/lib/castle_spec.rb | 6 ++-- .../support/shared_examples/action_request.rb | 24 ++++++------- spec/support/shared_examples/configuration.rb | 26 +++++++------- 29 files changed, 201 insertions(+), 202 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 9d99b892..3304ae7f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,11 +1,13 @@ require: - rubocop-rspec - rubocop-performance + - rubocop-rspec_rails inherit_gem: prettier: rubocop.yml AllCops: + TargetRubyVersion: 2.7 NewCops: enable Exclude: - bin/**/* @@ -43,7 +45,7 @@ RSpec/MultipleMemoizedHelpers: RSpec/EmptyExampleGroup: Enabled: false -RSpec/Rails/InferredSpecType: +RSpecRails/InferredSpecType: Enabled: false Layout/LineLength: @@ -104,10 +106,10 @@ Performance/Sum: Performance/StringInclude: Enabled: false -RSpec/Rails/HttpStatus: +RSpecRails/HttpStatus: Enabled: false -RSpec/Rails/HaveHttpStatus: +RSpecRails/HaveHttpStatus: Enabled: false Lint/AmbiguousBlockAssociation: diff --git a/Gemfile.lock b/Gemfile.lock index c578211f..a59aa74d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -23,17 +23,12 @@ GEM bigdecimal rexml diff-lcs (1.5.1) - docile (1.4.0) - hashdiff (1.1.0) - mize (0.4.1) - protocol (~> 2.0) - protocol (2.0.0) - ruby_parser (~> 3.0) - public_suffix (6.0.0) - racc (1.8.0) - rack (3.0.11) + docile (1.4.1) + hashdiff (1.1.1) + public_suffix (6.0.1) + rack (3.1.7) rake (13.2.1) - rexml (3.3.1) + rexml (3.3.4) strscan rspec (3.13.0) rspec-core (~> 3.13.0) @@ -48,10 +43,6 @@ GEM diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) rspec-support (3.13.1) - ruby_parser (3.21.1) - racc (~> 1.5) - sexp_processor (~> 4.16) - sexp_processor (4.17.2) simplecov (0.22.0) docile (~> 1.1) simplecov-html (~> 0.11) @@ -60,8 +51,7 @@ GEM simplecov_json_formatter (0.1.4) strscan (3.1.0) sync (0.5.0) - term-ansicolor (1.10.2) - mize + term-ansicolor (1.11.2) tins (~> 1.0) thor (1.3.1) timecop (0.9.10) @@ -89,4 +79,4 @@ DEPENDENCIES webmock BUNDLED WITH - 2.5.11 + 2.5.17 diff --git a/lib/castle.rb b/lib/castle.rb index 8110681b..89a09fb0 100644 --- a/lib/castle.rb +++ b/lib/castle.rb @@ -67,7 +67,7 @@ module Castle class << self def configure(config_hash = nil) - (config_hash || {}).each { |config_name, config_value| config.send("#{config_name}=", config_value) } + (config_hash || {}).each { |config_name, config_value| config.send(:"#{config_name}=", config_value) } yield(config) if block_given? end diff --git a/spec/integration/rails/rails_spec.rb b/spec/integration/rails/rails_spec.rb index 20af82d2..439df4c8 100644 --- a/spec/integration/rails/rails_spec.rb +++ b/spec/integration/rails/rails_spec.rb @@ -40,7 +40,14 @@ } end let(:now) { Time.now } - let(:headers) { { 'HTTP_AUTHORIZATION' => 'Basic 123', 'HTTP_X_FORWARDED_FOR' => '5.5.5.5, 1.2.3.4', 'HTTP_VERSION' => 'HTTP/1.0', 'HTTP_CONTENT_LENGTH' => '0' } } + let(:headers) do + { + 'HTTP_AUTHORIZATION' => 'Basic 123', + 'HTTP_X_FORWARDED_FOR' => '5.5.5.5, 1.2.3.4', + 'HTTP_VERSION' => 'HTTP/1.0', + 'HTTP_CONTENT_LENGTH' => '0' + } + end before do Timecop.freeze(now) diff --git a/spec/lib/castle/client_spec.rb b/spec/lib/castle/client_spec.rb index 0e1bd4a6..e10650e3 100644 --- a/spec/lib/castle/client_spec.rb +++ b/spec/lib/castle/client_spec.rb @@ -208,11 +208,11 @@ end it { assert_not_requested :post, 'https://api.castle.io/v1/authenticate' } - it { expect(request_response[:policy][:action]).to be_eql(Castle::Verdict::ALLOW) } - it { expect(request_response[:action]).to be_eql(Castle::Verdict::ALLOW) } - it { expect(request_response[:user_id]).to be_eql('1234') } + it { expect(request_response[:policy][:action]).to eql(Castle::Verdict::ALLOW) } + it { expect(request_response[:action]).to eql(Castle::Verdict::ALLOW) } + it { expect(request_response[:user_id]).to eql('1234') } it { expect(request_response[:failover]).to be true } - it { expect(request_response[:failover_reason]).to be_eql('Castle is set to do not track.') } + it { expect(request_response[:failover_reason]).to eql('Castle is set to do not track.') } end context 'when request with fail' do @@ -226,11 +226,11 @@ context 'with request error and not throw on eg deny strategy' do it { assert_not_requested :post, 'https://:secret@api.castle.io/v1/authenticate' } - it { expect(request_response[:policy][:action]).to be_eql('allow') } - it { expect(request_response[:action]).to be_eql('allow') } - it { expect(request_response[:user_id]).to be_eql('1234') } + it { expect(request_response[:policy][:action]).to eql('allow') } + it { expect(request_response[:action]).to eql('allow') } + it { expect(request_response[:user_id]).to eql('1234') } it { expect(request_response[:failover]).to be true } - it { expect(request_response[:failover_reason]).to be_eql('Castle::RequestError') } + it { expect(request_response[:failover_reason]).to eql('Castle::RequestError') } end end @@ -245,11 +245,11 @@ describe 'not throw on eg deny strategy' do it { assert_not_requested :post, 'https://:secret@api.castle.io/v1/authenticate' } - it { expect(request_response[:policy][:action]).to be_eql('allow') } - it { expect(request_response[:action]).to be_eql('allow') } - it { expect(request_response[:user_id]).to be_eql('1234') } + it { expect(request_response[:policy][:action]).to eql('allow') } + it { expect(request_response[:action]).to eql('allow') } + it { expect(request_response[:user_id]).to eql('1234') } it { expect(request_response[:failover]).to be true } - it { expect(request_response[:failover_reason]).to be_eql('Castle::InternalServerError') } + it { expect(request_response[:failover_reason]).to eql('Castle::InternalServerError') } end end end diff --git a/spec/lib/castle/command_spec.rb b/spec/lib/castle/command_spec.rb index 38e82c1b..944c66c2 100644 --- a/spec/lib/castle/command_spec.rb +++ b/spec/lib/castle/command_spec.rb @@ -3,7 +3,7 @@ describe Castle::Command do subject(:command) { described_class.new('go', { id: '1' }, :post) } - it { expect(command.path).to be_eql('go') } - it { expect(command.data).to be_eql(id: '1') } - it { expect(command.method).to be_eql(:post) } + it { expect(command.path).to eql('go') } + it { expect(command.data).to eql(id: '1') } + it { expect(command.method).to be(:post) } end diff --git a/spec/lib/castle/commands/approve_device_spec.rb b/spec/lib/castle/commands/approve_device_spec.rb index 96ad7bad..56f579f2 100644 --- a/spec/lib/castle/commands/approve_device_spec.rb +++ b/spec/lib/castle/commands/approve_device_spec.rb @@ -16,8 +16,8 @@ end context 'with device_token' do - it { expect(command.method).to be_eql(:put) } - it { expect(command.path).to be_eql("devices/#{device_token}/approve") } + it { expect(command.method).to be(:put) } + it { expect(command.path).to eql("devices/#{device_token}/approve") } it { expect(command.data).to be_nil } end end diff --git a/spec/lib/castle/commands/authenticate_spec.rb b/spec/lib/castle/commands/authenticate_spec.rb index 775050e2..a263c67b 100644 --- a/spec/lib/castle/commands/authenticate_spec.rb +++ b/spec/lib/castle/commands/authenticate_spec.rb @@ -20,45 +20,45 @@ let(:payload) { default_payload.merge(properties: { test: '1' }) } let(:command_data) { default_payload.merge(properties: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('authenticate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('authenticate') } + it { expect(command.data).to eql(command_data) } end context 'with user_traits' do let(:payload) { default_payload.merge(user_traits: { test: '1' }) } let(:command_data) { default_payload.merge(user_traits: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('authenticate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('authenticate') } + it { expect(command.data).to eql(command_data) } end context 'when active true' do let(:payload) { default_payload.merge(context: context.merge(active: true)) } let(:command_data) { default_payload.merge(context: context.merge(active: true)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('authenticate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('authenticate') } + it { expect(command.data).to eql(command_data) } end context 'when active false' do let(:payload) { default_payload.merge(context: context.merge(active: false)) } let(:command_data) { default_payload.merge(context: context.merge(active: false)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('authenticate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('authenticate') } + it { expect(command.data).to eql(command_data) } end context 'when active string' do let(:payload) { default_payload.merge(context: context.merge(active: 'string')) } let(:command_data) { default_payload.merge(context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('authenticate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('authenticate') } + it { expect(command.data).to eql(command_data) } end end diff --git a/spec/lib/castle/commands/end_impersonation_spec.rb b/spec/lib/castle/commands/end_impersonation_spec.rb index 365079cd..06c32a2f 100644 --- a/spec/lib/castle/commands/end_impersonation_spec.rb +++ b/spec/lib/castle/commands/end_impersonation_spec.rb @@ -21,36 +21,36 @@ let(:payload) { default_payload.merge(properties: { impersonator: impersonator }) } let(:command_data) { default_payload.merge(properties: { impersonator: impersonator }, context: context) } - it { expect(command.method).to be_eql(:delete) } - it { expect(command.path).to be_eql('impersonate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:delete) } + it { expect(command.path).to eql('impersonate') } + it { expect(command.data).to eql(command_data) } end context 'when active true' do let(:payload) { default_payload.merge(context: context.merge(active: true)) } let(:command_data) { default_payload.merge(context: context.merge(active: true)) } - it { expect(command.method).to be_eql(:delete) } - it { expect(command.path).to be_eql('impersonate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:delete) } + it { expect(command.path).to eql('impersonate') } + it { expect(command.data).to eql(command_data) } end context 'when active false' do let(:payload) { default_payload.merge(context: context.merge(active: false)) } let(:command_data) { default_payload.merge(context: context.merge(active: false)) } - it { expect(command.method).to be_eql(:delete) } - it { expect(command.path).to be_eql('impersonate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:delete) } + it { expect(command.path).to eql('impersonate') } + it { expect(command.data).to eql(command_data) } end context 'when active string' do let(:payload) { default_payload.merge(context: context.merge(active: 'string')) } let(:command_data) { default_payload.merge(context: context) } - it { expect(command.method).to be_eql(:delete) } - it { expect(command.path).to be_eql('impersonate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:delete) } + it { expect(command.path).to eql('impersonate') } + it { expect(command.data).to eql(command_data) } end end diff --git a/spec/lib/castle/commands/filter_spec.rb b/spec/lib/castle/commands/filter_spec.rb index f00acc27..1934fc66 100644 --- a/spec/lib/castle/commands/filter_spec.rb +++ b/spec/lib/castle/commands/filter_spec.rb @@ -28,45 +28,45 @@ let(:payload) { default_payload.merge(properties: { test: '1' }) } let(:command_data) { default_payload.merge(properties: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('filter') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('filter') } + it { expect(command.data).to eql(command_data) } end context 'with user_traits' do let(:payload) { default_payload.merge(user_traits: { test: '1' }) } let(:command_data) { default_payload.merge(user_traits: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('filter') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('filter') } + it { expect(command.data).to eql(command_data) } end context 'when active true' do let(:payload) { default_payload.merge(context: context.merge(active: true)) } let(:command_data) { default_payload.merge(context: context.merge(active: true)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('filter') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('filter') } + it { expect(command.data).to eql(command_data) } end context 'when active false' do let(:payload) { default_payload.merge(context: context.merge(active: false)) } let(:command_data) { default_payload.merge(context: context.merge(active: false)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('filter') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('filter') } + it { expect(command.data).to eql(command_data) } end context 'when active string' do let(:payload) { default_payload.merge(context: context.merge(active: 'string')) } let(:command_data) { default_payload.merge(context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('filter') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('filter') } + it { expect(command.data).to eql(command_data) } end end end diff --git a/spec/lib/castle/commands/get_device_spec.rb b/spec/lib/castle/commands/get_device_spec.rb index f5947f9b..5ccc9eb4 100644 --- a/spec/lib/castle/commands/get_device_spec.rb +++ b/spec/lib/castle/commands/get_device_spec.rb @@ -16,8 +16,8 @@ end context 'with device_token' do - it { expect(command.method).to be_eql(:get) } - it { expect(command.path).to be_eql("devices/#{device_token}") } + it { expect(command.method).to be(:get) } + it { expect(command.path).to eql("devices/#{device_token}") } it { expect(command.data).to be_nil } end end diff --git a/spec/lib/castle/commands/get_devices_for_user_spec.rb b/spec/lib/castle/commands/get_devices_for_user_spec.rb index 38d25037..73df1b50 100644 --- a/spec/lib/castle/commands/get_devices_for_user_spec.rb +++ b/spec/lib/castle/commands/get_devices_for_user_spec.rb @@ -16,8 +16,8 @@ end context 'with user_id' do - it { expect(command.method).to be_eql(:get) } - it { expect(command.path).to be_eql("users/#{user_id}/devices") } + it { expect(command.method).to be(:get) } + it { expect(command.path).to eql("users/#{user_id}/devices") } it { expect(command.data).to be_nil } end end diff --git a/spec/lib/castle/commands/log_spec.rb b/spec/lib/castle/commands/log_spec.rb index 9efcf292..a393a2f9 100644 --- a/spec/lib/castle/commands/log_spec.rb +++ b/spec/lib/castle/commands/log_spec.rb @@ -29,45 +29,45 @@ let(:payload) { default_payload.merge(properties: { test: '1' }) } let(:command_data) { default_payload.merge(properties: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('log') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('log') } + it { expect(command.data).to eql(command_data) } end context 'with user_traits' do let(:payload) { default_payload.merge(user_traits: { test: '1' }) } let(:command_data) { default_payload.merge(user_traits: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('log') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('log') } + it { expect(command.data).to eql(command_data) } end context 'when active true' do let(:payload) { default_payload.merge(context: context.merge(active: true)) } let(:command_data) { default_payload.merge(context: context.merge(active: true)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('log') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('log') } + it { expect(command.data).to eql(command_data) } end context 'when active false' do let(:payload) { default_payload.merge(context: context.merge(active: false)) } let(:command_data) { default_payload.merge(context: context.merge(active: false)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('log') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('log') } + it { expect(command.data).to eql(command_data) } end context 'when active string' do let(:payload) { default_payload.merge(context: context.merge(active: 'string')) } let(:command_data) { default_payload.merge(context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('log') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('log') } + it { expect(command.data).to eql(command_data) } end end end diff --git a/spec/lib/castle/commands/report_device_spec.rb b/spec/lib/castle/commands/report_device_spec.rb index 4a4669c8..7774ead4 100644 --- a/spec/lib/castle/commands/report_device_spec.rb +++ b/spec/lib/castle/commands/report_device_spec.rb @@ -16,8 +16,8 @@ end context 'with device_token' do - it { expect(command.method).to be_eql(:put) } - it { expect(command.path).to be_eql("devices/#{device_token}/report") } + it { expect(command.method).to be(:put) } + it { expect(command.path).to eql("devices/#{device_token}/report") } it { expect(command.data).to be_nil } end end diff --git a/spec/lib/castle/commands/risk_spec.rb b/spec/lib/castle/commands/risk_spec.rb index abbea3f1..336342cb 100644 --- a/spec/lib/castle/commands/risk_spec.rb +++ b/spec/lib/castle/commands/risk_spec.rb @@ -29,45 +29,45 @@ let(:payload) { default_payload.merge(properties: { test: '1' }) } let(:command_data) { default_payload.merge(properties: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('risk') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('risk') } + it { expect(command.data).to eql(command_data) } end context 'with user_traits' do let(:payload) { default_payload.merge(user_traits: { test: '1' }) } let(:command_data) { default_payload.merge(user_traits: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('risk') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('risk') } + it { expect(command.data).to eql(command_data) } end context 'when active true' do let(:payload) { default_payload.merge(context: context.merge(active: true)) } let(:command_data) { default_payload.merge(context: context.merge(active: true)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('risk') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('risk') } + it { expect(command.data).to eql(command_data) } end context 'when active false' do let(:payload) { default_payload.merge(context: context.merge(active: false)) } let(:command_data) { default_payload.merge(context: context.merge(active: false)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('risk') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('risk') } + it { expect(command.data).to eql(command_data) } end context 'when active string' do let(:payload) { default_payload.merge(context: context.merge(active: 'string')) } let(:command_data) { default_payload.merge(context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('risk') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('risk') } + it { expect(command.data).to eql(command_data) } end end end diff --git a/spec/lib/castle/commands/start_impersonation_spec.rb b/spec/lib/castle/commands/start_impersonation_spec.rb index 62c7cfa8..dcf5d8d7 100644 --- a/spec/lib/castle/commands/start_impersonation_spec.rb +++ b/spec/lib/castle/commands/start_impersonation_spec.rb @@ -21,36 +21,36 @@ let(:payload) { default_payload.merge(properties: { impersonator: impersonator }) } let(:command_data) { default_payload.merge(properties: { impersonator: impersonator }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('impersonate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('impersonate') } + it { expect(command.data).to eql(command_data) } end context 'when active true' do let(:payload) { default_payload.merge(context: context.merge(active: true)) } let(:command_data) { default_payload.merge(context: context.merge(active: true)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('impersonate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('impersonate') } + it { expect(command.data).to eql(command_data) } end context 'when active false' do let(:payload) { default_payload.merge(context: context.merge(active: false)) } let(:command_data) { default_payload.merge(context: context.merge(active: false)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('impersonate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('impersonate') } + it { expect(command.data).to eql(command_data) } end context 'when active string' do let(:payload) { default_payload.merge(context: context.merge(active: 'string')) } let(:command_data) { default_payload.merge(context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('impersonate') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('impersonate') } + it { expect(command.data).to eql(command_data) } end end diff --git a/spec/lib/castle/commands/track_spec.rb b/spec/lib/castle/commands/track_spec.rb index 69e90d9d..53a95954 100644 --- a/spec/lib/castle/commands/track_spec.rb +++ b/spec/lib/castle/commands/track_spec.rb @@ -20,54 +20,54 @@ let(:payload) { default_payload.merge(user_id: '1234') } let(:command_data) { default_payload.merge(user_id: '1234', context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('track') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('track') } + it { expect(command.data).to eql(command_data) } end context 'with properties' do let(:payload) { default_payload.merge(properties: { test: '1' }) } let(:command_data) { default_payload.merge(properties: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('track') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('track') } + it { expect(command.data).to eql(command_data) } end context 'with user_traits' do let(:payload) { default_payload.merge(user_traits: { test: '1' }) } let(:command_data) { default_payload.merge(user_traits: { test: '1' }, context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('track') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('track') } + it { expect(command.data).to eql(command_data) } end context 'when active true' do let(:payload) { default_payload.merge(context: context.merge(active: true)) } let(:command_data) { default_payload.merge(context: context.merge(active: true)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('track') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('track') } + it { expect(command.data).to eql(command_data) } end context 'when active false' do let(:payload) { default_payload.merge(context: context.merge(active: false)) } let(:command_data) { default_payload.merge(context: context.merge(active: false)) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('track') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('track') } + it { expect(command.data).to eql(command_data) } end context 'when active string' do let(:payload) { default_payload.merge(context: context.merge(active: 'string')) } let(:command_data) { default_payload.merge(context: context) } - it { expect(command.method).to be_eql(:post) } - it { expect(command.path).to be_eql('track') } - it { expect(command.data).to be_eql(command_data) } + it { expect(command.method).to be(:post) } + it { expect(command.path).to eql('track') } + it { expect(command.data).to eql(command_data) } end end diff --git a/spec/lib/castle/configuration_spec.rb b/spec/lib/castle/configuration_spec.rb index 0b172da0..73eba445 100644 --- a/spec/lib/castle/configuration_spec.rb +++ b/spec/lib/castle/configuration_spec.rb @@ -10,5 +10,5 @@ it_behaves_like 'configuration_failover_strategy' it_behaves_like 'configuration_api_secret' - it { expect(config.api_secret).to be_eql('') } + it { expect(config.api_secret).to eql('') } end diff --git a/spec/lib/castle/context/get_default_spec.rb b/spec/lib/castle/context/get_default_spec.rb index 4a48ca2d..59616651 100644 --- a/spec/lib/castle/context/get_default_spec.rb +++ b/spec/lib/castle/context/get_default_spec.rb @@ -31,11 +31,11 @@ before { stub_const('Castle::VERSION', version) } - it { expect(default_context[:active]).to be_eql(true) } - it { expect(default_context[:headers]).to be_eql(result_headers) } - it { expect(default_context[:ip]).to be_eql(ip) } - it { expect(default_context[:client_id]).to be_eql(client_id) } - it { expect(default_context[:library][:name]).to be_eql('castle-rb') } - it { expect(default_context[:library][:version]).to be_eql(version) } - it { expect(default_context[:user_agent]).to be_eql('test') } + it { expect(default_context[:active]).to be(true) } + it { expect(default_context[:headers]).to eql(result_headers) } + it { expect(default_context[:ip]).to eql(ip) } + it { expect(default_context[:client_id]).to eql(client_id) } + it { expect(default_context[:library][:name]).to eql('castle-rb') } + it { expect(default_context[:library][:version]).to eql(version) } + it { expect(default_context[:user_agent]).to eql('test') } end diff --git a/spec/lib/castle/core/send_request_spec.rb b/spec/lib/castle/core/send_request_spec.rb index 810535d7..160e96f3 100644 --- a/spec/lib/castle/core/send_request_spec.rb +++ b/spec/lib/castle/core/send_request_spec.rb @@ -62,7 +62,7 @@ before { allow(Castle::Utils::GetTimestamp).to receive(:call).and_return(time) } - it { expect(build.body).to be_eql(expected_body.to_json) } + it { expect(build.body).to eql(expected_body.to_json) } it { expect(build.method).to eql('POST') } it { expect(build.path).to eql("/v1/#{command.path}") } it { expect(build.to_hash).to have_key('authorization') } @@ -77,7 +77,7 @@ before { allow(Castle::Utils::GetTimestamp).to receive(:call).and_return(time) } - it { expect(build.body).to be_eql(expected_body.to_json) } + it { expect(build.body).to eql(expected_body.to_json) } it { expect(build.method).to eql('GET') } it { expect(build.path).to eql("/v1/#{command.path}") } end @@ -89,7 +89,7 @@ before { allow(Castle::Utils::GetTimestamp).to receive(:call).and_return(time) } - it { expect(build.body).to be_eql(expected_body.to_json) } + it { expect(build.body).to eql(expected_body.to_json) } it { expect(build.method).to eql('PUT') } it { expect(build.path).to eql("/v1/#{command.path}") } end diff --git a/spec/lib/castle/failover/strategy_spec.rb b/spec/lib/castle/failover/strategy_spec.rb index 36c63399..1499adef 100644 --- a/spec/lib/castle/failover/strategy_spec.rb +++ b/spec/lib/castle/failover/strategy_spec.rb @@ -3,10 +3,10 @@ describe Castle::Failover::Strategy do subject(:strategy) { described_class } - it { expect(strategy::ALLOW).to be_eql(:allow) } - it { expect(strategy::DENY).to be_eql(:deny) } - it { expect(strategy::CHALLENGE).to be_eql(:challenge) } - it { expect(strategy::THROW).to be_eql(:throw) } + it { expect(strategy::ALLOW).to be(:allow) } + it { expect(strategy::DENY).to be(:deny) } + it { expect(strategy::CHALLENGE).to be(:challenge) } + it { expect(strategy::THROW).to be(:throw) } - it { expect(Castle::Failover::STRATEGIES).to be_eql(%i[allow deny challenge throw]) } + it { expect(Castle::Failover::STRATEGIES).to eql(%i[allow deny challenge throw]) } end diff --git a/spec/lib/castle/headers/format_spec.rb b/spec/lib/castle/headers/format_spec.rb index e4abe019..2f6eb54f 100644 --- a/spec/lib/castle/headers/format_spec.rb +++ b/spec/lib/castle/headers/format_spec.rb @@ -4,22 +4,22 @@ subject(:format) { described_class } it 'removes HTTP_' do - expect(format.call('HTTP_X_TEST')).to be_eql('X-Test') + expect(format.call('HTTP_X_TEST')).to eql('X-Test') end it 'capitalizes header' do - expect(format.call('X_TEST')).to be_eql('X-Test') + expect(format.call('X_TEST')).to eql('X-Test') end it 'ignores letter case and -_ divider' do - expect(format.call('http-X_teST')).to be_eql('X-Test') + expect(format.call('http-X_teST')).to eql('X-Test') end it 'does not remove http if there is no _- char' do - expect(format.call('httpX_teST')).to be_eql('Httpx-Test') + expect(format.call('httpX_teST')).to eql('Httpx-Test') end it 'capitalizes' do - expect(format.call(:clearance)).to be_eql('Clearance') + expect(format.call(:clearance)).to eql('Clearance') end end diff --git a/spec/lib/castle/singleton_configuration_spec.rb b/spec/lib/castle/singleton_configuration_spec.rb index f56851d7..ebe9f392 100644 --- a/spec/lib/castle/singleton_configuration_spec.rb +++ b/spec/lib/castle/singleton_configuration_spec.rb @@ -10,5 +10,5 @@ it_behaves_like 'configuration_failover_strategy' it_behaves_like 'configuration_api_secret' - it { expect(config.api_secret).to be_eql('secret') } + it { expect(config.api_secret).to eql('secret') } end diff --git a/spec/lib/castle/utils/clone_spec.rb b/spec/lib/castle/utils/clone_spec.rb index cdb18635..58fb5842 100644 --- a/spec/lib/castle/utils/clone_spec.rb +++ b/spec/lib/castle/utils/clone_spec.rb @@ -13,7 +13,7 @@ it do nested[:test] = 'sample' - expect(cloned).to be_eql(result) + expect(cloned).to eql(result) end end end diff --git a/spec/lib/castle/utils/merge_spec.rb b/spec/lib/castle/utils/merge_spec.rb index 9724ce10..d7040449 100644 --- a/spec/lib/castle/utils/merge_spec.rb +++ b/spec/lib/castle/utils/merge_spec.rb @@ -8,6 +8,6 @@ let(:second) { { test2: '2', test: { 'test1' => { d: '5' }, :test2 => '6', :a => nil, :b => '3' } } } let(:result) { { test2: '2', test: { test1: { c: '4', d: '5' }, test2: '6', b: '3' } } } - it { expect(merge.call(first, second)).to be_eql(result) } + it { expect(merge.call(first, second)).to eql(result) } end end diff --git a/spec/lib/castle/verdict_spec.rb b/spec/lib/castle/verdict_spec.rb index 03a61b04..ac40ed16 100644 --- a/spec/lib/castle/verdict_spec.rb +++ b/spec/lib/castle/verdict_spec.rb @@ -3,7 +3,7 @@ describe Castle::Verdict do subject(:verdict) { described_class } - it { expect(verdict::ALLOW).to be_eql('allow') } - it { expect(verdict::DENY).to be_eql('deny') } - it { expect(verdict::CHALLENGE).to be_eql('challenge') } + it { expect(verdict::ALLOW).to eql('allow') } + it { expect(verdict::DENY).to eql('deny') } + it { expect(verdict::CHALLENGE).to eql('challenge') } end diff --git a/spec/lib/castle_spec.rb b/spec/lib/castle_spec.rb index 611da14a..1c08a268 100644 --- a/spec/lib/castle_spec.rb +++ b/spec/lib/castle_spec.rb @@ -12,7 +12,7 @@ before { castle.api_secret = value } - it { expect(castle.config.api_secret).to be_eql(value) } + it { expect(castle.config.api_secret).to eql(value) } end describe 'configure' do @@ -20,8 +20,8 @@ let(:timeout) { 60 } shared_examples 'config_setup' do - it { expect(castle.config.api_secret).to be_eql(value) } - it { expect(castle.config.request_timeout).to be_eql(timeout) } + it { expect(castle.config.api_secret).to eql(value) } + it { expect(castle.config.request_timeout).to eql(timeout) } end context 'with block' do diff --git a/spec/support/shared_examples/action_request.rb b/spec/support/shared_examples/action_request.rb index c5544a60..eda5ff29 100644 --- a/spec/support/shared_examples/action_request.rb +++ b/spec/support/shared_examples/action_request.rb @@ -97,11 +97,11 @@ end it { assert_not_requested :post, "https://api.castle.io/v1/#{action}" } - it { expect(request_response[:policy][:action]).to be_eql(Castle::Verdict::ALLOW) } - it { expect(request_response[:action]).to be_eql(Castle::Verdict::ALLOW) } - it { expect(request_response[:user_id]).to be_eql('1234') } + it { expect(request_response[:policy][:action]).to eql(Castle::Verdict::ALLOW) } + it { expect(request_response[:action]).to eql(Castle::Verdict::ALLOW) } + it { expect(request_response[:user_id]).to eql('1234') } it { expect(request_response[:failover]).to be true } - it { expect(request_response[:failover_reason]).to be_eql('Castle is set to do not track.') } + it { expect(request_response[:failover_reason]).to eql('Castle is set to do not track.') } end context 'when request with fail' do @@ -115,11 +115,11 @@ context 'with request error and not throw on eg deny strategy' do it { assert_not_requested :post, "https:/:secret@api.castle.io/v1/#{action}" } - it { expect(request_response[:policy][:action]).to be_eql('allow') } - it { expect(request_response[:action]).to be_eql('allow') } - it { expect(request_response[:user_id]).to be_eql('1234') } + it { expect(request_response[:policy][:action]).to eql('allow') } + it { expect(request_response[:action]).to eql('allow') } + it { expect(request_response[:user_id]).to eql('1234') } it { expect(request_response[:failover]).to be true } - it { expect(request_response[:failover_reason]).to be_eql('Castle::RequestError') } + it { expect(request_response[:failover_reason]).to eql('Castle::RequestError') } end end @@ -134,11 +134,11 @@ describe 'not throw on eg deny strategy' do it { assert_not_requested :post, "https:/:secret@api.castle.io/v1/#{action}" } - it { expect(request_response[:policy][:action]).to be_eql('allow') } - it { expect(request_response[:action]).to be_eql('allow') } - it { expect(request_response[:user_id]).to be_eql('1234') } + it { expect(request_response[:policy][:action]).to eql('allow') } + it { expect(request_response[:action]).to eql('allow') } + it { expect(request_response[:user_id]).to eql('1234') } it { expect(request_response[:failover]).to be true } - it { expect(request_response[:failover_reason]).to be_eql('Castle::InternalServerError') } + it { expect(request_response[:failover_reason]).to eql('Castle::InternalServerError') } end end diff --git a/spec/support/shared_examples/configuration.rb b/spec/support/shared_examples/configuration.rb index 70650454..b59a41d0 100644 --- a/spec/support/shared_examples/configuration.rb +++ b/spec/support/shared_examples/configuration.rb @@ -3,63 +3,63 @@ shared_examples 'configuration_host' do describe 'host' do context 'with default' do - it { expect(config.base_url.host).to be_eql('api.castle.io') } + it { expect(config.base_url.host).to eql('api.castle.io') } end context 'with setter' do before { config.base_url = 'http://api.castle.dev/v2' } - it { expect(config.base_url.host).to be_eql('api.castle.dev') } + it { expect(config.base_url.host).to eql('api.castle.dev') } end end end shared_examples 'configuration_request_timeout' do describe 'request_timeout' do - it { expect(config.request_timeout).to be_eql(1000) } + it { expect(config.request_timeout).to be(1000) } context 'with setter' do let(:value) { 50.0 } before { config.request_timeout = value } - it { expect(config.request_timeout).to be_eql(value) } + it { expect(config.request_timeout).to eql(value) } end end end shared_examples 'configuration_allowlisted' do describe 'allowlisted' do - it { expect(config.allowlisted.size).to be_eql(0) } + it { expect(config.allowlisted.size).to be(0) } context 'with setter' do before { config.allowlisted = ['header'] } - it { expect(config.allowlisted).to be_eql(['Header']) } + it { expect(config.allowlisted).to eql(['Header']) } end end end shared_examples 'configuration_denylisted' do describe 'denylisted' do - it { expect(config.denylisted.size).to be_eql(0) } + it { expect(config.denylisted.size).to be(0) } context 'with setter' do before { config.denylisted = ['header'] } - it { expect(config.denylisted).to be_eql(['Header']) } + it { expect(config.denylisted).to eql(['Header']) } end end end shared_examples 'configuration_failover_strategy' do describe 'failover_strategy' do - it { expect(config.failover_strategy).to be_eql(Castle::Failover::Strategy::ALLOW) } + it { expect(config.failover_strategy).to eql(Castle::Failover::Strategy::ALLOW) } context 'with setter' do before { config.failover_strategy = Castle::Failover::Strategy::DENY } - it { expect(config.failover_strategy).to be_eql(Castle::Failover::Strategy::DENY) } + it { expect(config.failover_strategy).to eql(Castle::Failover::Strategy::DENY) } end context 'when broken' do @@ -79,12 +79,12 @@ config.reset end - it { expect(config.api_secret).to be_eql(secret_key_env) } + it { expect(config.api_secret).to eql(secret_key_env) } context 'when key is overwritten' do before { config.api_secret = secret_key } - it { expect(config.api_secret).to be_eql(secret_key) } + it { expect(config.api_secret).to eql(secret_key) } end end @@ -93,7 +93,7 @@ before { config.api_secret = value } - it { expect(config.api_secret).to be_eql(value) } + it { expect(config.api_secret).to eql(value) } end end end