spec/guard/cane_spec.rb in guard-cane-0.2.0 vs spec/guard/cane_spec.rb in guard-cane-0.2.1

- old
+ new

@@ -1,47 +1,48 @@ -require 'spec_helper' +require "guard/compat/test/helper" -describe Guard::Cane do - subject { guard } - let(:guard) { described_class.new(watchers, options) } +require "guard/cane" +RSpec.describe Guard::Cane do let(:options) { {} } let(:paths) { [] } - let(:watchers) { [] } - before do - Guard::Notifier.stub :notify + let(:guard) { described_class.new(options) } - Guard::UI.stub :info - Guard::UI.stub :error + subject { guard } + + before do + allow(Guard::Compat::UI).to receive :notify + allow(Guard::Compat::UI).to receive :info + allow(Guard::Compat::UI).to receive :error end describe "#start" do subject(:start) { guard.start } it "runs all" do - guard.should_receive :run_all + expect(guard).to receive :run_all start end context "with run_all_on_start: false" do let(:options) { { run_all_on_start: false } } it "does not run all" do - guard.should_not_receive :run_all + expect(guard).to_not receive :run_all start end end end describe "#run_all" do subject(:run_all) { guard.run_all } it "runs cane with no arguments" do - guard.should_receive(:cane).with() + expect(guard).to receive(:cane).with(no_args) run_all end end @@ -49,30 +50,30 @@ subject(:run_on_modifications) { guard.run_on_modifications(paths) } let(:paths) { %w[a b c] } it "runs cane with the paths" do - guard.should_receive(:cane).with(paths) + expect(guard).to receive(:cane).with(paths) run_on_modifications end context "with all_after_pass: true" do let(:options) { { all_after_pass: true } } it "does run all after pass" do - guard.stub(:cane).and_return(true) - guard.should_receive(:cane).with(paths) - guard.should_receive :run_all + allow(guard).to receive(:cane).and_return(true) + expect(guard).to receive(:cane).with(paths) + expect(guard).to receive :run_all run_on_modifications end it "does not run all if tests did not pass" do - guard.stub(:cane).and_return(false) - guard.should_receive(:cane).with(paths) - guard.should_not_receive :run_all + allow(guard).to receive(:cane).and_return(false) + expect(guard).to receive(:cane).with(paths) + expect(guard).to_not receive :run_all run_on_modifications end end end @@ -81,41 +82,44 @@ subject(:cane) { guard.cane(paths) } let(:result) { true } before do - guard.stub system: result + allow(guard).to receive(:system).and_return result end - it { should be_true } + it { should be true } it "does not notify of success" do - Guard::Notifier.should_not_receive(:notify) + expect(Guard::Compat::UI).to_not receive(:notify) - cane.should == true + expect(cane).to be true end context "when failed" do let(:result) { false } - it { should be_false } + it { should be false } it "notifies of a failure" do - Guard::Notifier.should_receive(:notify).with(*described_class::FAILED) + expect(Guard::Compat::UI).to receive(:notify) + .with(*described_class::FAILED) cane end end context "when failing and then succeeding" do it "notifies of a success" do - guard.stub system: false - Guard::Notifier.should_receive(:notify).with(*described_class::FAILED) + allow(guard).to receive(:system).and_return false + expect(Guard::Compat::UI).to receive(:notify) + .with(*described_class::FAILED) guard.cane(paths) - guard.stub system: true - Guard::Notifier.should_receive(:notify).with(*described_class::SUCCESS) + allow(guard).to receive(:system).and_return true + expect(Guard::Compat::UI).to receive(:notify) + .with(*described_class::SUCCESS) guard.cane(paths) end end end