A platform for community discussion. Free, open, simple.
DEV: Make the first argument to the top-level describe a constant in specs
Loïc Guitaut00b3f0e2c4c7
diff --git a/Gemfile.lock b/Gemfile.lockindex 982b6d5bc5d..7442aa66088 100644--- a/Gemfile.lock+++ b/Gemfile.lock@@ -7,7 +7,7 @@ GITGITremote: https://github.com/discourse/rubocop-discourse.git- revision: 9642e65f3767e5fd1d4e1aec4b617179f4128909+ revision: a5aea6e5f150b1eb7765a805bec0ff618cb718b3specs:rubocop-discourse (2.5.0)rubocop (>= 1.1.0)@@ -428,7 +428,7 @@ GEMrubocop-ast (>= 1.19.1, < 2.0)ruby-progressbar (~> 1.7)unicode-display_width (>= 1.4.0, < 3.0)- rubocop-ast (1.20.1)+ rubocop-ast (1.21.0)parser (>= 3.1.1.0)rubocop-rspec (2.12.1)rubocop (~> 1.31)diff --git a/spec/lib/discourse_redis_spec.rb b/spec/lib/discourse_redis_spec.rbindex ba037580e7c..e6564abc56e 100644--- a/spec/lib/discourse_redis_spec.rb+++ b/spec/lib/discourse_redis_spec.rb@@ -245,4 +245,56 @@ RSpec.describe DiscourseRedis doexpect(redis_proxy.calls).to eq([:evalsha, :eval, :evalsha, :evalsha])endend++ describe ".new_redis_store" do+ let(:cache) { Cache.new(namespace: 'foo') }+ let(:store) { DiscourseRedis.new_redis_store }++ before do+ cache.redis.del("key")+ store.delete("key")+ end++ it "can store stuff" do+ store.fetch("key") do+ "key in store"+ end++ r = store.read("key")++ expect(r).to eq("key in store")+ end++ it "doesn't collide with our Cache" do+ store.fetch("key") do+ "key in store"+ end++ cache.fetch("key") do+ "key in cache"+ end++ r = store.read("key")++ expect(r).to eq("key in store")+ end++ it "can be cleared without clearing our cache" do+ cache.clear+ store.clear++ store.fetch("key") do+ "key in store"+ end++ cache.fetch("key") do+ "key in cache"+ end++ store.clear++ expect(store.read("key")).to eq(nil)+ expect(cache.fetch("key")).to eq("key in cache")+ end+ endenddiff --git a/spec/lib/distributed_cache_spec.rb b/spec/lib/distributed_cache_spec.rbindex 21ef2a3f51c..7099365d863 100644--- a/spec/lib/distributed_cache_spec.rb+++ b/spec/lib/distributed_cache_spec.rb@@ -1,7 +1,7 @@# frozen_string_literal: true-RSpec.describe "DistributedCache extensions" do- let(:cache) { DistributedCache.new('mytest') }+RSpec.describe DistributedCache do+ let(:cache) { described_class.new('mytest') }it "can defer_get_set" domessages = MessageBus.track_publish("/distributed_hash") dodiff --git a/spec/lib/onebox/engine_spec.rb b/spec/lib/onebox/engine_spec.rbindex ba9449fc827..6b76f712fa2 100644--- a/spec/lib/onebox/engine_spec.rb+++ b/spec/lib/onebox/engine_spec.rb@@ -86,22 +86,22 @@ RSpec.describe Onebox::Engine doexpect(result).to match(/https/)endend-end-RSpec.describe ".onebox_name" do- module ScopeForTemplateName- class TemplateNameOnebox- include Onebox::Engine+ describe ".onebox_name" do+ module ScopeForTemplateName+ class TemplateNameOnebox+ include Onebox::Engine+ endend- end- let(:onebox_name) { ScopeForTemplateName::TemplateNameOnebox.onebox_name }+ let(:onebox_name) { ScopeForTemplateName::TemplateNameOnebox.onebox_name }- it "should not include the scope" do- expect(onebox_name).not_to include("ScopeForTemplateName", "scopefortemplatename")- end+ it "should not include the scope" do+ expect(onebox_name).not_to include("ScopeForTemplateName", "scopefortemplatename")+ end- it "should not include the word Onebox" do- expect(onebox_name).not_to include("onebox", "Onebox")+ it "should not include the word Onebox" do+ expect(onebox_name).not_to include("onebox", "Onebox")+ endendenddiff --git a/spec/lib/redis_store_spec.rb b/spec/lib/redis_store_spec.rbdeleted file mode 100644index 4e5a0783989..00000000000--- a/spec/lib/redis_store_spec.rb+++ /dev/null@@ -1,64 +0,0 @@-# frozen_string_literal: true--require 'cache'--RSpec.describe "Redis Store" do-- let :cache do- Cache.new(namespace: 'foo')- end-- let :store do- DiscourseRedis.new_redis_store- end-- before(:each) do- cache.redis.del "key"- store.delete "key"- end-- it "can store stuff" do- store.fetch "key" do- "key in store"- end-- r = store.read "key"-- expect(r).to eq("key in store")- end-- it "doesn't collide with our Cache" do-- store.fetch "key" do- "key in store"- end-- cache.fetch "key" do- "key in cache"- end-- r = store.read "key"-- expect(r).to eq("key in store")- end-- it "can be cleared without clearing our cache" do- cache.clear- store.clear-- store.fetch "key" do- "key in store"- end-- cache.fetch "key" do- "key in cache"- end-- store.clear-- expect(store.read("key")).to eq(nil)- expect(cache.fetch("key")).to eq("key in cache")-- end--enddiff --git a/spec/lib/validators/quality_title_validator_spec.rb b/spec/lib/validators/quality_title_validator_spec.rbindex af0ee48dfe7..00a0d705244 100644--- a/spec/lib/validators/quality_title_validator_spec.rb+++ b/spec/lib/validators/quality_title_validator_spec.rb@@ -10,7 +10,7 @@ module QualityTitleValidatorSpecendend-RSpec.describe "A record validated with QualityTitleValidator" do+RSpec.describe QualityTitleValidator dolet(:valid_title) { "hello this is my cool topic! welcome: all;" }let(:short_title) { valid_title.slice(0, SiteSetting.min_topic_title_length - 1) }let(:long_title) { valid_title.center(SiteSetting.max_topic_title_length + 1, 'x') }