From ac9dc6a7b55398bc95216c3bf79cb97a8e1535b5 Mon Sep 17 00:00:00 2001 From: Lewis Buckley Date: Sun, 13 Aug 2023 20:47:47 +0100 Subject: [PATCH] Move test classes to ScopeTest namespace --- test/scope_test.rb | 54 +++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/test/scope_test.rb b/test/scope_test.rb index dd32fdd..34e0916 100644 --- a/test/scope_test.rb +++ b/test/scope_test.rb @@ -2,56 +2,56 @@ require "test_helper" -class Identity - def id - 1 +class ScopeTest < ActiveSupport::TestCase + class Identity + def id + 1 + end end -end -class Person - include Kredis::Attributes + class Person + include Kredis::Attributes - kredis_list :names_with_scope, scope: :identity - kredis_list :names_with_scope_and_key, scope: :identity, key: ->(person) { "custom_key_#{person.example_method}" } + kredis_list :names_with_scope, scope: :identity + kredis_list :names_with_scope_and_key, scope: :identity, key: ->(person) { "custom_key_#{person.example_method}" } - def identity - Identity.new - end + def identity + Identity.new + end - def example_method - "example" + def example_method + "example" + end end -end -class Family - include Kredis::Attributes + class Family + include Kredis::Attributes - kredis_list :members - kredis_list :pets, key: "pets" - kredis_list :members_with_nil_scope, scope: ->(person) { nil } + kredis_list :members + kredis_list :pets, key: "pets" + kredis_list :members_with_nil_scope, scope: ->(person) { nil } - def id - 1 + def id + 1 + end end -end -class ScopeTest < ActiveSupport::TestCase setup do @person = Person.new @family = Family.new end test "key is scoped" do - assert_equal @person.names_with_scope.key, "identities:1:people:names_with_scope" + assert_equal @person.names_with_scope.key, "scope_test:identities:1:scope_test:people:names_with_scope" end test "key is scoped and has custom key component" do - assert_equal @person.names_with_scope_and_key.key, "identities:1:custom_key_example" + assert_equal @person.names_with_scope_and_key.key, "scope_test:identities:1:custom_key_example" end test "scope is nil and key is generated normally" do - assert_equal @family.members_with_nil_scope.key, "families:1:members_with_nil_scope" + assert_equal @family.members_with_nil_scope.key, "scope_test:families:1:members_with_nil_scope" end test "custom key" do @@ -59,6 +59,6 @@ class ScopeTest < ActiveSupport::TestCase end test "key without scope" do - assert_equal @family.members.key, "families:1:members" + assert_equal @family.members.key, "scope_test:families:1:members" end end