diff --git a/.rubocop.yml b/.rubocop.yml index d46296cf..f7043105 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,2 +1,5 @@ inherit_gem: rubocop-discourse: default.yml + +RSpec/MessageSpies: + Enabled: false diff --git a/lib/mini_profiler/profiler.rb b/lib/mini_profiler/profiler.rb index 786c005a..b16de3f7 100644 --- a/lib/mini_profiler/profiler.rb +++ b/lib/mini_profiler/profiler.rb @@ -373,7 +373,6 @@ def call(env) return client_settings.handle_cookie(self.flamegraph(flamegraph)) end - begin @storage.save(page_struct) # no matter what it is, it should be unviewed, otherwise we will miss POST diff --git a/spec/integration/mini_profiler_spec.rb b/spec/integration/mini_profiler_spec.rb index dfe6f77a..05d1dc7d 100644 --- a/spec/integration/mini_profiler_spec.rb +++ b/spec/integration/mini_profiler_spec.rb @@ -338,8 +338,8 @@ def load_prof(response) describe 'error handling when storage_instance fails to save' do it "should recover gracefully" do Rack::MiniProfiler.config.pre_authorize_cb = lambda { |env| true } - allow_any_instance_of(Rack::MiniProfiler::MemoryStore).to have_received(:save) { raise "This error" } - expect(Rack::MiniProfiler.config.storage_failure).to have_received(:call) + allow_any_instance_of(Rack::MiniProfiler::MemoryStore).to receive(:save) { raise "This error" } + expect(Rack::MiniProfiler.config.storage_failure).to receive(:call) get '/html' end end diff --git a/spec/integration/railtie_methods_spec.rb b/spec/integration/railtie_methods_spec.rb index 9079c727..851d935c 100644 --- a/spec/integration/railtie_methods_spec.rb +++ b/spec/integration/railtie_methods_spec.rb @@ -11,7 +11,7 @@ def to_seconds(array) describe Rack::MiniProfilerRailsMethods do describe '#render_notification_handler' do before do - allow(Process).to have_received(:clock_gettime).and_return(0) + allow(Process).to receive(:clock_gettime).and_return(0) Rack::MiniProfiler.create_current @current_timer = Rack::MiniProfiler.current.current_timer @@ -22,7 +22,7 @@ def to_seconds(array) ['SELECT E', 73, 77], # in node E ['SELECT F', 93, 96] # in node F ]).each do |query, start, finish| - allow(Process).to have_received(:clock_gettime).and_return(finish) + allow(Process).to receive(:clock_gettime).and_return(finish) @current_timer.add_sql( query, finish - start, @@ -39,7 +39,7 @@ def to_seconds(array) ['custom1 B', 11, 16], ['custom1 B', 17, 19] ]).each do |type, start, finish| - allow(Process).to have_received(:clock_gettime).and_return(finish) + allow(Process).to receive(:clock_gettime).and_return(finish) timing = @current_timer.add_custom( type, finish - start, @@ -68,7 +68,7 @@ def to_seconds(array) ['A', 0, 80], ['F', 90, 100] ]).each do |name, start, finish| - allow(Process).to have_received(:clock_gettime).and_return(finish) + allow(Process).to receive(:clock_gettime).and_return(finish) described_class.render_notification_handler(name, finish, start, name_as_description: true) end @nodes = { diff --git a/spec/lib/sql_patches_spec.rb b/spec/lib/sql_patches_spec.rb index 4a8ffde1..ed5b4d8d 100644 --- a/spec/lib/sql_patches_spec.rb +++ b/spec/lib/sql_patches_spec.rb @@ -33,7 +33,7 @@ it "uses detection of env variable is not defined" do with_patch_env(nil) do expect(SqlPatches.all_patch_files).to eq([]) - expect(Rack::MiniProfiler).to have_received(:patch_rails?).and_return(true) + expect(Rack::MiniProfiler).to receive(:patch_rails?).and_return(true) expect(SqlPatches.all_patch_files).to eq(["activerecord"]) end end diff --git a/spec/lib/storage/memcache_store_spec.rb b/spec/lib/storage/memcache_store_spec.rb index 7f1ff962..71f3e24c 100644 --- a/spec/lib/storage/memcache_store_spec.rb +++ b/spec/lib/storage/memcache_store_spec.rb @@ -80,8 +80,8 @@ client = instance_double("memcache-client") store = Rack::MiniProfiler::MemcacheStore.new(client: client) - expect(client).to have_received(:get) - expect(Dalli::Client).not_to have_received(:new) + expect(client).to receive(:get) + expect(Dalli::Client).not_to receive(:new) store.load("XYZ") end end diff --git a/spec/lib/storage/redis_store_spec.rb b/spec/lib/storage/redis_store_spec.rb index 32bfa3f4..d811f541 100644 --- a/spec/lib/storage/redis_store_spec.rb +++ b/spec/lib/storage/redis_store_spec.rb @@ -33,8 +33,8 @@ connection = instance_double("redis-connection") store = Rack::MiniProfiler::RedisStore.new(connection: connection) - expect(connection).to have_received(:get) - expect(Redis).not_to have_received(:new) + expect(connection).to receive(:get) + expect(Redis).not_to receive(:new) store.load("XYZ") end end diff --git a/spec/lib/timer_struct/timer_struct_spec.rb b/spec/lib/timer_struct/timer_struct_spec.rb index cfdc5d86..bb1da49d 100644 --- a/spec/lib/timer_struct/timer_struct_spec.rb +++ b/spec/lib/timer_struct/timer_struct_spec.rb @@ -27,7 +27,7 @@ end it 'should not add a second (nil) argument if no arguments were passed' do - expect(::JSON).to have_received(:generate).once.with(@timer.attributes, max_nesting: 100).and_return(nil) + expect(::JSON).to receive(:generate).once.with(@timer.attributes, max_nesting: 100).and_return(nil) @timer.to_json end