diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml new file mode 100644 index 0000000..a1b35ef --- /dev/null +++ b/.github/workflows/rubocop.yml @@ -0,0 +1,22 @@ +name: RuboCop + +on: [push, pull_request] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Ruby 3.2 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.2 + bundler-cache: true + + - name: Run RuboCop + run: bundle exec rubocop --parallel diff --git a/.gitignore b/.gitignore index c111b33..1585aa7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.gem +.rubocop-* diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..78166f9 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1 @@ +inherit_from: https://raw.githubusercontent.com/rails/rails/main/.rubocop.yml diff --git a/Gemfile b/Gemfile index 947e3a0..d422832 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,14 @@ +# frozen_string_literal: true + source "https://rubygems.org" gemspec gem "rake" gem "debug", ">= 1.0.0" +gem "rubocop" +gem "rubocop-minitest" +gem "rubocop-packaging" +gem "rubocop-performance" +gem "rubocop-rails" +gem "rubocop-md" diff --git a/Gemfile.lock b/Gemfile.lock index cc433eb..61cb730 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -68,6 +68,7 @@ GEM minitest (>= 5.1) tzinfo (~> 2.0) zeitwerk (~> 2.3) + ast (2.4.2) builder (3.2.4) concurrent-ruby (1.1.8) connection_pool (2.4.1) @@ -83,6 +84,8 @@ GEM io-console (0.6.0) irb (1.7.1) reline (>= 0.3.0) + json (2.6.3) + language_server-protocol (3.17.0.3) loofah (2.9.0) crass (~> 1.0.2) nokogiri (>= 1.5.9) @@ -101,6 +104,10 @@ GEM racc (~> 1.4) nokogiri (1.15.2-x86_64-darwin) racc (~> 1.4) + parallel (1.23.0) + parser (3.2.2.3) + ast (~> 2.4.1) + racc racc (1.7.1) rack (2.2.3) rack-test (1.1.0) @@ -131,13 +138,43 @@ GEM method_source rake (>= 0.8.7) thor (~> 1.0) + rainbow (3.1.1) rake (13.0.3) redis (5.0.6) redis-client (>= 0.9.0) redis-client (0.14.1) connection_pool + regexp_parser (2.8.1) reline (0.3.6) io-console (~> 0.5) + rexml (3.2.5) + rubocop (1.54.1) + json (~> 2.3) + language_server-protocol (>= 3.17.0) + parallel (~> 1.10) + parser (>= 3.2.2.3) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 1.8, < 3.0) + rexml (>= 3.2.5, < 4.0) + rubocop-ast (>= 1.28.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 3.0) + rubocop-ast (1.29.0) + parser (>= 3.2.1.0) + rubocop-md (1.2.0) + rubocop (>= 1.0) + rubocop-minitest (0.31.0) + rubocop (>= 1.39, < 2.0) + rubocop-packaging (0.5.2) + rubocop (>= 1.33, < 2.0) + rubocop-performance (1.18.0) + rubocop (>= 1.7.0, < 2.0) + rubocop-ast (>= 0.4.0) + rubocop-rails (2.20.2) + activesupport (>= 4.2.0) + rack (>= 1.1) + rubocop (>= 1.33.0, < 2.0) + ruby-progressbar (1.13.0) sprockets (4.0.2) concurrent-ruby (~> 1.0) rack (> 1, < 3) @@ -148,6 +185,7 @@ GEM thor (1.1.0) tzinfo (2.0.4) concurrent-ruby (~> 1.0) + unicode-display_width (2.4.2) websocket-driver (0.7.3) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) @@ -163,6 +201,12 @@ DEPENDENCIES kredis! rails (>= 6.0.0) rake + rubocop + rubocop-md + rubocop-minitest + rubocop-packaging + rubocop-performance + rubocop-rails BUNDLED WITH 2.3.12 diff --git a/README.md b/README.md index 8c457de..ca27c60 100644 --- a/README.md +++ b/README.md @@ -21,11 +21,11 @@ integer.value = 5 # => SET myinteger "5" 5 == integer.value # => GET myinteger decimal = Kredis.decimal "mydecimal" # accuracy! -decimal.value = "%.47f" % (1.0/10) # => SET mydecimal "0.10000000000000000555111512312578270211815834045" +decimal.value = "%.47f" % (1.0 / 10) # => SET mydecimal "0.10000000000000000555111512312578270211815834045" BigDecimal("0.10000000000000000555111512312578270211815834045e0") == decimal.value # => GET mydecimal float = Kredis.float "myfloat" # speed! -float.value = 1.0/10 # => SET myfloat "0.1" +float.value = 1.0 / 10 # => SET myfloat "0.1" 0.1 == float.value # => GET myfloat boolean = Kredis.boolean "myboolean" @@ -228,14 +228,14 @@ If you need to connect to Redis with SSL, the recommended approach is to set you ```ruby Kredis::Connections.connections[:shared] = Redis.new( - url: ENV['REDIS_URL'], + url: ENV["REDIS_URL"], ssl_params: { cert_store: OpenSSL::X509::Store.new.tap { |store| - store.add_file(Rails.root.join('config', 'ca_cert.pem').to_s) + store.add_file(Rails.root.join("config", "ca_cert.pem").to_s) }, cert: OpenSSL::X509::Certificate.new(File.read( - Rails.root.join('config', 'client.crt') + Rails.root.join("config", "client.crt") )), key: OpenSSL::PKey::RSA.new( diff --git a/bin/console b/bin/console index 9a6d4e1..4300bda 100755 --- a/bin/console +++ b/bin/console @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +# frozen_string_literal: true require "irb" require "bundler/inline" diff --git a/bin/test b/bin/test index 5516a12..e7e6d47 100755 --- a/bin/test +++ b/bin/test @@ -1,4 +1,6 @@ #!/usr/bin/env ruby +# frozen_string_literal: true + $: << File.expand_path("../test", __dir__) require "bundler/setup" diff --git a/kredis.gemspec b/kredis.gemspec index 8125e5d..9225c69 100644 --- a/kredis.gemspec +++ b/kredis.gemspec @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require_relative "lib/kredis/version" Gem::Specification.new do |s| diff --git a/lib/install/install.rb b/lib/install/install.rb index d7e54e5..b2cc2a6 100644 --- a/lib/install/install.rb +++ b/lib/install/install.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + yaml_path = Rails.root.join("config/redis/shared.yml") unless yaml_path.exist? say "Adding `config/redis/shared.yml`" diff --git a/lib/kredis.rb b/lib/kredis.rb index 03e8b0b..2505032 100644 --- a/lib/kredis.rb +++ b/lib/kredis.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support" require "active_support/core_ext/module/attribute_accessors" require "active_support/core_ext/module/attribute_accessors_per_thread" diff --git a/lib/kredis/attributes.rb b/lib/kredis/attributes.rb index d359d65..e237455 100644 --- a/lib/kredis/attributes.rb +++ b/lib/kredis/attributes.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kredis::Attributes extend ActiveSupport::Concern @@ -106,7 +108,7 @@ def kredis_key_evaluated(key) end def kredis_key_for_attribute(name) - "#{self.class.name.tableize.gsub("/", ":")}:#{extract_kredis_id}:#{name}" + "#{self.class.name.tableize.tr("/", ":")}:#{extract_kredis_id}:#{name}" end def extract_kredis_id diff --git a/lib/kredis/connections.rb b/lib/kredis/connections.rb index e229d15..f55f75f 100644 --- a/lib/kredis/connections.rb +++ b/lib/kredis/connections.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "redis" module Kredis::Connections @@ -6,11 +8,9 @@ module Kredis::Connections mattr_accessor :connector, default: ->(config) { Redis.new(config) } def configured_for(name) - connections[name] ||= begin - Kredis.instrument :meta, message: "Connected to #{name}" do + connections[name] ||= Kredis.instrument :meta, message: "Connected to #{name}" do connector.call configurator.config_for("redis/#{name}") end - end end def clear_all diff --git a/lib/kredis/log_subscriber.rb b/lib/kredis/log_subscriber.rb index 08a906b..1c5ec47 100644 --- a/lib/kredis/log_subscriber.rb +++ b/lib/kredis/log_subscriber.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/log_subscriber" class Kredis::LogSubscriber < ActiveSupport::LogSubscriber diff --git a/lib/kredis/migration.rb b/lib/kredis/migration.rb index b47d1f9..7208450 100644 --- a/lib/kredis/migration.rb +++ b/lib/kredis/migration.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/module/delegation" class Kredis::Migration diff --git a/lib/kredis/namespace.rb b/lib/kredis/namespace.rb index 8433c2a..5a8f871 100644 --- a/lib/kredis/namespace.rb +++ b/lib/kredis/namespace.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kredis::Namespace def namespace=(namespace) Thread.current[:kredis_namespace] = namespace diff --git a/lib/kredis/railtie.rb b/lib/kredis/railtie.rb index 1bc59ec..1351f99 100644 --- a/lib/kredis/railtie.rb +++ b/lib/kredis/railtie.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Railtie < ::Rails::Railtie config.kredis = ActiveSupport::OrderedOptions.new diff --git a/lib/kredis/type_casting.rb b/lib/kredis/type_casting.rb index 412d485..aa61c5f 100644 --- a/lib/kredis/type_casting.rb +++ b/lib/kredis/type_casting.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "json" require "active_model/type" require "kredis/type/json" diff --git a/lib/kredis/types.rb b/lib/kredis/types.rb index 5338a0c..47522c2 100644 --- a/lib/kredis/types.rb +++ b/lib/kredis/types.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kredis::Types autoload :CallbacksProxy, "kredis/types/callbacks_proxy" diff --git a/lib/kredis/types/callbacks_proxy.rb b/lib/kredis/types/callbacks_proxy.rb index c70717e..574f82a 100644 --- a/lib/kredis/types/callbacks_proxy.rb +++ b/lib/kredis/types/callbacks_proxy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::CallbacksProxy attr_reader :type delegate :to_s, to: :type diff --git a/lib/kredis/types/counter.rb b/lib/kredis/types/counter.rb index cacebb3..daeb4a9 100644 --- a/lib/kredis/types/counter.rb +++ b/lib/kredis/types/counter.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::Counter < Kredis::Types::Proxying proxying :multi, :set, :incrby, :decrby, :get, :del, :exists? diff --git a/lib/kredis/types/cycle.rb b/lib/kredis/types/cycle.rb index 8f843fb..2b3d29a 100644 --- a/lib/kredis/types/cycle.rb +++ b/lib/kredis/types/cycle.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::Cycle < Kredis::Types::Counter attr_accessor :values diff --git a/lib/kredis/types/enum.rb b/lib/kredis/types/enum.rb index b14403f..985ba15 100644 --- a/lib/kredis/types/enum.rb +++ b/lib/kredis/types/enum.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/object/inclusion" class Kredis::Types::Enum < Kredis::Types::Proxying diff --git a/lib/kredis/types/flag.rb b/lib/kredis/types/flag.rb index fef9c46..b5902fd 100644 --- a/lib/kredis/types/flag.rb +++ b/lib/kredis/types/flag.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::Flag < Kredis::Types::Proxying proxying :set, :exists?, :del diff --git a/lib/kredis/types/hash.rb b/lib/kredis/types/hash.rb index bc1b990..c33fb7a 100644 --- a/lib/kredis/types/hash.rb +++ b/lib/kredis/types/hash.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/hash" class Kredis::Types::Hash < Kredis::Types::Proxying @@ -14,7 +16,7 @@ def []=(key, value) end def update(**entries) - hset entries.transform_values{ |val| type_to_string(val, typed) } if entries.flatten.any? + hset entries.transform_values { |val| type_to_string(val, typed) } if entries.flatten.any? end def values_at(*keys) diff --git a/lib/kredis/types/list.rb b/lib/kredis/types/list.rb index 3987bfa..aa85150 100644 --- a/lib/kredis/types/list.rb +++ b/lib/kredis/types/list.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::List < Kredis::Types::Proxying proxying :lrange, :lrem, :lpush, :ltrim, :rpush, :exists?, :del diff --git a/lib/kredis/types/ordered_set.rb b/lib/kredis/types/ordered_set.rb index c290c00..05a4b3f 100644 --- a/lib/kredis/types/ordered_set.rb +++ b/lib/kredis/types/ordered_set.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::OrderedSet < Kredis::Types::Proxying proxying :multi, :zrange, :zrem, :zadd, :zremrangebyrank, :zcard, :exists?, :del @@ -42,7 +44,7 @@ def insert(elements, prepending: false) base_score + incremental_score end - [ score , element ] + [ score, element ] end multi do diff --git a/lib/kredis/types/proxy.rb b/lib/kredis/types/proxy.rb index b609a6f..b3a1d2a 100644 --- a/lib/kredis/types/proxy.rb +++ b/lib/kredis/types/proxy.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::Proxy require_relative "proxy/failsafe" include Failsafe diff --git a/lib/kredis/types/proxy/failsafe.rb b/lib/kredis/types/proxy/failsafe.rb index 6f8371c..c201ccd 100644 --- a/lib/kredis/types/proxy/failsafe.rb +++ b/lib/kredis/types/proxy/failsafe.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kredis::Types::Proxy::Failsafe def initialize(*) super diff --git a/lib/kredis/types/proxying.rb b/lib/kredis/types/proxying.rb index 4afe5ad..4479b53 100644 --- a/lib/kredis/types/proxying.rb +++ b/lib/kredis/types/proxying.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "active_support/core_ext/module/delegation" class Kredis::Types::Proxying diff --git a/lib/kredis/types/scalar.rb b/lib/kredis/types/scalar.rb index 03ddf52..28f365d 100644 --- a/lib/kredis/types/scalar.rb +++ b/lib/kredis/types/scalar.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::Scalar < Kredis::Types::Proxying proxying :set, :get, :exists?, :del, :expire, :expireat diff --git a/lib/kredis/types/set.rb b/lib/kredis/types/set.rb index dca921d..870c52b 100644 --- a/lib/kredis/types/set.rb +++ b/lib/kredis/types/set.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::Set < Kredis::Types::Proxying proxying :smembers, :sadd, :srem, :multi, :del, :sismember, :scard, :spop, :exists?, :srandmember diff --git a/lib/kredis/types/slots.rb b/lib/kredis/types/slots.rb index 94c5286..e9f4b97 100644 --- a/lib/kredis/types/slots.rb +++ b/lib/kredis/types/slots.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + class Kredis::Types::Slots < Kredis::Types::Proxying class NotAvailable < StandardError; end diff --git a/lib/kredis/types/unique_list.rb b/lib/kredis/types/unique_list.rb index b931dd9..bd73088 100644 --- a/lib/kredis/types/unique_list.rb +++ b/lib/kredis/types/unique_list.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + # You'd normally call this a set, but Redis already has another data type for that class Kredis::Types::UniqueList < Kredis::Types::List proxying :multi, :ltrim, :exists? diff --git a/lib/kredis/version.rb b/lib/kredis/version.rb index 1f437ec..c314830 100644 --- a/lib/kredis/version.rb +++ b/lib/kredis/version.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + module Kredis VERSION = "1.5.0" end diff --git a/lib/tasks/kredis/install.rake b/lib/tasks/kredis/install.rake index bbf317c..1bf6619 100644 --- a/lib/tasks/kredis/install.rake +++ b/lib/tasks/kredis/install.rake @@ -1,3 +1,5 @@ +# frozen_string_literal: true + namespace :kredis do desc "Install kredis" task :install do diff --git a/test/attributes_callbacks_test.rb b/test/attributes_callbacks_test.rb index dcb1114..4315037 100644 --- a/test/attributes_callbacks_test.rb +++ b/test/attributes_callbacks_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class AttributesCallbacksTest < ActiveSupport::TestCase diff --git a/test/attributes_test.rb b/test/attributes_test.rb index 977cb65..fbd861b 100644 --- a/test/attributes_test.rb +++ b/test/attributes_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" require "active_support/core_ext/integer" @@ -249,7 +251,7 @@ class AttributesTest < ActiveSupport::TestCase assert @person.onboarded.value @person.onboarded.value = false - refute @person.onboarded.value + assert_not @person.onboarded.value end test "missing id to constrain key" do diff --git a/test/callbacks_test.rb b/test/callbacks_test.rb index 0065adf..c4efdc8 100644 --- a/test/callbacks_test.rb +++ b/test/callbacks_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class CallbacksTest < ActiveSupport::TestCase @@ -30,7 +32,7 @@ class CallbacksTest < ActiveSupport::TestCase attention = Kredis.slot "attention", after_change: ->(slot) { @callback_check = slot.available? } attention.reserve - refute @callback_check + assert_not @callback_check end test "enum with after_change proc callback" do diff --git a/test/connections_test.rb b/test/connections_test.rb index 7800362..4c1ae67 100644 --- a/test/connections_test.rb +++ b/test/connections_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class ConnectionsTest < ActiveSupport::TestCase diff --git a/test/log_subscriber_test.rb b/test/log_subscriber_test.rb index b74c3a7..e96cad6 100644 --- a/test/log_subscriber_test.rb +++ b/test/log_subscriber_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" require "active_support/log_subscriber/test_helper" diff --git a/test/migration_test.rb b/test/migration_test.rb index 9ef93ec..3532e3c 100644 --- a/test/migration_test.rb +++ b/test/migration_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class MigrationTest < ActiveSupport::TestCase diff --git a/test/namespace_test.rb b/test/namespace_test.rb index 2ea56c4..fde7840 100644 --- a/test/namespace_test.rb +++ b/test/namespace_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class NamespaceTest < ActiveSupport::TestCase diff --git a/test/proxy_test.rb b/test/proxy_test.rb index 94c8a1f..ff24576 100644 --- a/test/proxy_test.rb +++ b/test/proxy_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class ProxyTest < ActiveSupport::TestCase diff --git a/test/test_helper.rb b/test/test_helper.rb index 40128ab..a4ef65d 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "bundler/setup" require "active_support/test_case" require "active_support/testing/autorun" diff --git a/test/types/counter_test.rb b/test/types/counter_test.rb index 821b7b5..4e4c607 100644 --- a/test/types/counter_test.rb +++ b/test/types/counter_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" require "active_support/core_ext/integer" diff --git a/test/types/cycle_test.rb b/test/types/cycle_test.rb index ffc467e..a51cee6 100644 --- a/test/types/cycle_test.rb +++ b/test/types/cycle_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" require "active_support/core_ext/integer" diff --git a/test/types/enum_test.rb b/test/types/enum_test.rb index 84c587b..d433f8d 100644 --- a/test/types/enum_test.rb +++ b/test/types/enum_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class EnumTest < ActiveSupport::TestCase diff --git a/test/types/flag_test.rb b/test/types/flag_test.rb index b1df179..2178f2e 100644 --- a/test/types/flag_test.rb +++ b/test/types/flag_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class FlagTest < ActiveSupport::TestCase diff --git a/test/types/hash_test.rb b/test/types/hash_test.rb index 3f607f9..ab9e5ad 100644 --- a/test/types/hash_test.rb +++ b/test/types/hash_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" require "active_support/core_ext/integer" @@ -87,7 +89,7 @@ class HashTest < ActiveSupport::TestCase test "exists?" do assert_not @hash.exists? - @hash[:key] = :value + @hash[:key] = :value assert @hash.exists? end end diff --git a/test/types/list_test.rb b/test/types/list_test.rb index 92cd1e2..93626ea 100644 --- a/test/types/list_test.rb +++ b/test/types/list_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" require "active_support/core_ext/integer" diff --git a/test/types/ordered_set_test.rb b/test/types/ordered_set_test.rb index 420736e..baad280 100644 --- a/test/types/ordered_set_test.rb +++ b/test/types/ordered_set_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class OrderedSetTest < ActiveSupport::TestCase diff --git a/test/types/scalar_test.rb b/test/types/scalar_test.rb index 29eacca..e7de529 100644 --- a/test/types/scalar_test.rb +++ b/test/types/scalar_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" require "active_support/core_ext/integer" @@ -32,9 +34,9 @@ class ScalarTest < ActiveSupport::TestCase assert_equal true, boolean.value boolean.value = false assert_equal false, boolean.value - boolean.value = 't' + boolean.value = "t" assert_equal true, boolean.value - boolean.value = 'false' + boolean.value = "false" assert_equal false, boolean.value end @@ -61,8 +63,8 @@ class ScalarTest < ActiveSupport::TestCase json.value = { "one" => 1, "string" => "hello" } assert_equal({ "one" => 1, "string" => "hello" }, json.value) - json.value = {"json_class"=>"String", "raw"=>[97, 98, 99]} - assert_equal({"json_class"=>"String", "raw"=>[97, 98, 99]}, json.value) + json.value = { "json_class" => "String", "raw" => [97, 98, 99] } + assert_equal({ "json_class" => "String", "raw" => [97, 98, 99] }, json.value) end test "invalid type" do @@ -144,7 +146,7 @@ class ScalarTest < ActiveSupport::TestCase test "all scalar types can be configured with expires_in" do duration = 1.second - scalar = Kredis.scalar("ephemeral", expires_in: duration) + Kredis.scalar("ephemeral", expires_in: duration) scalar = Kredis.string("ephemeral", expires_in: duration) assert_equal duration, scalar.expires_in diff --git a/test/types/set_test.rb b/test/types/set_test.rb index bd6bc08..0d0c5b4 100644 --- a/test/types/set_test.rb +++ b/test/types/set_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" require "active_support/core_ext/object/inclusion" diff --git a/test/types/slots_test.rb b/test/types/slots_test.rb index ef11204..359fa9c 100644 --- a/test/types/slots_test.rb +++ b/test/types/slots_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class SlotsTest < ActiveSupport::TestCase diff --git a/test/types/unique_list_test.rb b/test/types/unique_list_test.rb index 17762db..83748f4 100644 --- a/test/types/unique_list_test.rb +++ b/test/types/unique_list_test.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require "test_helper" class UniqueListTest < ActiveSupport::TestCase