spec/lib/appsignal/hooks/puma_spec.rb in appsignal-2.1.0.beta.1 vs spec/lib/appsignal/hooks/puma_spec.rb in appsignal-2.1.0

- old
+ new

@@ -1,8 +1,8 @@ describe Appsignal::Hooks::PumaHook do context "with puma" do - before(:all) do + before(:context) do class Puma def self.cli_config @cli_config ||= CliConfig.new end @@ -18,24 +18,28 @@ def initialize @options = {} end end end - after(:all) { Object.send(:remove_const, :Puma) } + after(:context) { Object.send(:remove_const, :Puma) } - its(:dependencies_present?) { should be_true } + describe "#dependencies_present?" do + subject { described_class.new.dependencies_present? } + it { is_expected.to be_truthy } + end + context "when installed" do before do Appsignal::Hooks::PumaHook.new.install end it "adds behavior to Unicorn::Worker#close" do cluster = Puma::Cluster.new - Appsignal.should_receive(:stop) - cluster.should_receive(:stop_workers_without_appsignal) + expect(Appsignal).to receive(:stop) + expect(cluster).to receive(:stop_workers_without_appsignal) cluster.stop_workers end end @@ -45,12 +49,12 @@ Puma.cli_config.options.delete(:before_worker_shutdown) Appsignal::Hooks::PumaHook.new.install end it "should add a before shutdown worker callback" do - Puma.cli_config.options[:before_worker_boot].first.should be_a(Proc) - Puma.cli_config.options[:before_worker_shutdown].first.should be_a(Proc) + expect(Puma.cli_config.options[:before_worker_boot].first).to be_a(Proc) + expect(Puma.cli_config.options[:before_worker_shutdown].first).to be_a(Proc) end end context "with existing hooks" do before do @@ -58,15 +62,19 @@ Puma.cli_config.options[:before_worker_shutdown] = [] Appsignal::Hooks::PumaHook.new.install end it "should add a before shutdown worker callback" do - Puma.cli_config.options[:before_worker_boot].first.should be_a(Proc) - Puma.cli_config.options[:before_worker_shutdown].first.should be_a(Proc) + expect(Puma.cli_config.options[:before_worker_boot].first).to be_a(Proc) + expect(Puma.cli_config.options[:before_worker_shutdown].first).to be_a(Proc) end end end context "without puma" do - its(:dependencies_present?) { should be_false } + describe "#dependencies_present?" do + subject { described_class.new.dependencies_present? } + + it { is_expected.to be_falsy } + end end end