diff --git a/spec/guard/cli_spec.rb b/spec/guard/cli_spec.rb index 6b1ab8ec5..848e01f67 100644 --- a/spec/guard/cli_spec.rb +++ b/spec/guard/cli_spec.rb @@ -10,7 +10,7 @@ before { Guard.stub(:start) } it 'delegates to Guard.start' do - Guard.should_receive(:start) + expect(Guard).to receive(:start) subject.start end @@ -29,7 +29,7 @@ after { ENV['BUNDLE_GEMFILE'] = @bundler_env } it 'does not show the Bundler warning' do - Guard::UI.should_not_receive(:info).with(/Guard here!/) + expect(Guard::UI).to_not receive(:info).with(/Guard here!/) subject.start end end @@ -43,12 +43,12 @@ after { ENV['BUNDLE_GEMFILE'] = @bundler_env } it 'does show the Bundler warning' do - Guard::UI.should_receive(:info).with(/Guard here!/) + expect(Guard::UI).to receive(:info).with(/Guard here!/) subject.start end it 'does not show the Bundler warning with the :no_bundler_warning flag' do - Guard::UI.should_not_receive(:info).with(/Guard here!/) + expect(Guard::UI).to_not receive(:info).with(/Guard here!/) subject.options = { no_bundler_warning: true } subject.start end @@ -57,7 +57,7 @@ context 'without a Gemfile in the project dir' do before do - File.should_receive(:exists?).with('Gemfile').and_return false + expect(File).to receive(:exists?).with('Gemfile').and_return false @bundler_env = ENV['BUNDLE_GEMFILE'] ENV['BUNDLE_GEMFILE'] = nil end @@ -65,7 +65,7 @@ after { ENV['BUNDLE_GEMFILE'] = @bundler_env } it 'does not show the Bundler warning' do - Guard::UI.should_not_receive(:info).with(/Guard here!/) + expect(Guard::UI).to_not receive(:info).with(/Guard here!/) subject.start end end @@ -73,8 +73,8 @@ describe '#list' do it 'outputs the Guard plugins list' do - ::Guard::DslDescriber.should_receive(:new) { dsl_describer } - dsl_describer.should_receive(:list) + expect(::Guard::DslDescriber).to receive(:new) { dsl_describer } + expect(dsl_describer).to receive(:list) subject.list end @@ -82,8 +82,8 @@ describe '#notifiers' do it 'outputs the notifiers list' do - ::Guard::DslDescriber.should_receive(:new) { dsl_describer } - dsl_describer.should_receive(:notifiers) + expect(::Guard::DslDescriber).to receive(:new) { dsl_describer } + expect(dsl_describer).to receive(:notifiers) subject.notifiers end @@ -91,7 +91,7 @@ describe '#version' do it 'shows the current version' do - subject.should_receive(:puts).with(/#{ ::Guard::VERSION }/) + expect(subject).to receive(:puts).with(/#{ ::Guard::VERSION }/) subject.version end @@ -107,27 +107,27 @@ end it 'creates a Guardfile by delegating to Guardfile.create_guardfile' do - Guard::Guardfile.should_receive(:create_guardfile).with(abort_on_existence: options[:bare]) + expect(Guard::Guardfile).to receive(:create_guardfile).with(abort_on_existence: options[:bare]) subject.init end it 'initializes the templates of all installed Guards by delegating to Guardfile.initialize_all_templates' do - Guard::Guardfile.should_receive(:initialize_all_templates) + expect(Guard::Guardfile).to receive(:initialize_all_templates) subject.init end it 'initializes each passed template by delegating to Guardfile.initialize_template' do - Guard::Guardfile.should_receive(:initialize_template).with('rspec') - Guard::Guardfile.should_receive(:initialize_template).with('pow') + expect(Guard::Guardfile).to receive(:initialize_template).with('rspec') + expect(Guard::Guardfile).to receive(:initialize_template).with('pow') subject.init 'rspec','pow' end context 'when passed a guard name' do it 'initializes the template of the passed Guard by delegating to Guardfile.initialize_template' do - Guard::Guardfile.should_receive(:initialize_template).with('rspec') + expect(Guard::Guardfile).to receive(:initialize_template).with('rspec') subject.init 'rspec' end @@ -137,9 +137,9 @@ let(:options) { {bare: true} } it 'Only creates the Guardfile and does not initialize any Guard template' do - Guard::Guardfile.should_receive(:create_guardfile) - Guard::Guardfile.should_not_receive(:initialize_template) - Guard::Guardfile.should_not_receive(:initialize_all_templates) + expect(Guard::Guardfile).to receive(:create_guardfile) + expect(Guard::Guardfile).to_not receive(:initialize_template) + expect(Guard::Guardfile).to_not receive(:initialize_all_templates) subject.init end @@ -154,7 +154,7 @@ after { ENV['BUNDLE_GEMFILE'] = @bundler_env } it 'does not show the Bundler warning' do - Guard::UI.should_not_receive(:info).with(/Guard here!/) + expect(Guard::UI).to_not receive(:info).with(/Guard here!/) subject.init end @@ -169,7 +169,7 @@ after { ENV['BUNDLE_GEMFILE'] = @bundler_env } it 'does not show the Bundler warning' do - Guard::UI.should_receive(:info).with(/Guard here!/) + expect(Guard::UI).to receive(:info).with(/Guard here!/) subject.init end @@ -178,8 +178,8 @@ describe '#show' do it 'outputs the Guard::DslDescriber.list result' do - ::Guard::DslDescriber.should_receive(:new) { dsl_describer } - dsl_describer.should_receive(:show) + expect(::Guard::DslDescriber).to receive(:new) { dsl_describer } + expect(dsl_describer).to receive(:show) subject.show end diff --git a/spec/guard/commander_spec.rb b/spec/guard/commander_spec.rb index 888d75ffd..eebf4e4b5 100644 --- a/spec/guard/commander_spec.rb +++ b/spec/guard/commander_spec.rb @@ -15,7 +15,7 @@ before { ::Guard.stub(:running) { false } } it "setup Guard" do - ::Guard.should_receive(:setup).with(foo: 'bar') + expect(::Guard).to receive(:setup).with(foo: 'bar') ::Guard.start(foo: 'bar') end @@ -23,19 +23,19 @@ it "displays an info message" do ::Guard.instance_variable_set('@watchdirs', ['/foo/bar']) - ::Guard::UI.should_receive(:info).with("Guard is now watching at '/foo/bar'") + expect(::Guard::UI).to receive(:info).with("Guard is now watching at '/foo/bar'") ::Guard.start end it "tell the runner to run the :start task" do - ::Guard.runner.should_receive(:run).with(:start) + expect(::Guard.runner).to receive(:run).with(:start) ::Guard.start end it "start the listener" do - ::Guard.listener.should_receive(:start) + expect(::Guard.listener).to receive(:start) ::Guard.start end @@ -53,26 +53,26 @@ before { ::Guard.stub(:running) { false } } it "setup Guard" do - ::Guard.should_receive(:setup) + expect(::Guard).to receive(:setup) ::Guard.stop end end it "turns the notifier off" do - ::Guard::Notifier.should_receive(:turn_off) + expect(::Guard::Notifier).to receive(:turn_off) ::Guard.stop end it "tell the runner to run the :stop task" do - ::Guard.runner.should_receive(:run).with(:stop) + expect(::Guard.runner).to receive(:run).with(:stop) ::Guard.stop end it "stops the listener" do - ::Guard.listener.should_receive(:stop) + expect(::Guard.listener).to receive(:stop) ::Guard.stop end @@ -80,7 +80,7 @@ it "sets the running state to false" do ::Guard.running = true ::Guard.stop - ::Guard.running.should be_false + expect(::Guard.running).to be_false end end @@ -100,27 +100,27 @@ before { ::Guard.stub(:running) { false } } it "setup Guard" do - ::Guard.should_receive(:setup) + expect(::Guard).to receive(:setup) ::Guard.reload end end it 'clears the screen' do - ::Guard::UI.should_receive(:clear) + expect(::Guard::UI).to receive(:clear) subject.reload end context 'with a given scope' do it 'does not re-evaluate the Guardfile' do - Guard::Guardfile::Evaluator.any_instance.should_not_receive(:reevaluate_guardfile) + ::Guard::Guardfile::Evaluator.any_instance.should_not_receive(:reevaluate_guardfile) subject.reload({ groups: [group] }) end it 'reloads Guard' do - runner.should_receive(:run).with(:reload, { groups: [group] }) + expect(runner).to receive(:run).with(:reload, { groups: [group] }) subject.reload({ groups: [group] }) end @@ -134,7 +134,7 @@ end it 'does not reload Guard' do - runner.should_not_receive(:run).with(:reload, {}) + expect(runner).to_not receive(:run).with(:reload, {}) subject.reload end @@ -157,7 +157,7 @@ before { ::Guard.stub(:running) { false } } it "setup Guard" do - ::Guard.should_receive(:setup) + expect(::Guard).to receive(:setup) ::Guard.run_all end @@ -165,7 +165,7 @@ context 'with a given scope' do it 'runs all with the scope' do - runner.should_receive(:run).with(:run_all, { groups: [group] }) + expect(runner).to receive(:run).with(:run_all, { groups: [group] }) subject.run_all({ groups: [group] }) end @@ -173,7 +173,7 @@ context 'with an empty scope' do it 'runs all' do - runner.should_receive(:run).with(:run_all, {}) + expect(runner).to receive(:run).with(:run_all, {}) subject.run_all end @@ -185,20 +185,20 @@ before { subject.interactor = double('interactor').as_null_object } it 'disallows running the block concurrently to avoid inconsistent states' do - subject.lock.should_receive(:synchronize) + expect(subject.lock).to receive(:synchronize) subject.within_preserved_state &Proc.new {} end it 'runs the passed block' do @called = false subject.within_preserved_state { @called = true } - @called.should be_true + expect(@called).to be_true end context '@running is true' do it 'stops the interactor before running the block and starts it again when done' do - subject.interactor.should_receive(:stop) - subject.interactor.should_receive(:start) + expect(subject.interactor).to receive(:stop) + expect(subject.interactor).to receive(:start) subject.within_preserved_state &Proc.new {} end end @@ -207,8 +207,8 @@ before { ::Guard.stub(:running) { false } } it 'stops the interactor before running the block and do not starts it again when done' do - subject.interactor.should_receive(:stop) - subject.interactor.should_not_receive(:start) + expect(subject.interactor).to receive(:stop) + expect(subject.interactor).to_not receive(:start) subject.within_preserved_state &Proc.new {} end end diff --git a/spec/guard/commands/all_spec.rb b/spec/guard/commands/all_spec.rb index 77194add0..5365f27da 100644 --- a/spec/guard/commands/all_spec.rb +++ b/spec/guard/commands/all_spec.rb @@ -17,28 +17,28 @@ describe '#perform' do context 'without scope' do it 'runs the :run_all action' do - Guard.should_receive(:run_all).with(groups: [], plugins: []) + expect(Guard).to receive(:run_all).with(groups: [], plugins: []) Pry.run_command 'all' end end context 'with a valid Guard group scope' do it 'runs the :run_all action with the given scope' do - Guard.should_receive(:run_all).with(groups: [foo_group], plugins: []) + expect(Guard).to receive(:run_all).with(groups: [foo_group], plugins: []) Pry.run_command 'all foo' end end context 'with a valid Guard plugin scope' do it 'runs the :run_all action with the given scope' do - Guard.should_receive(:run_all).with(plugins: [bar_guard], groups: []) + expect(Guard).to receive(:run_all).with(plugins: [bar_guard], groups: []) Pry.run_command 'all bar' end end context 'with an invalid scope' do it 'does not run the action' do - Guard.should_not_receive(:run_all) + expect(Guard).to_not receive(:run_all) Pry.run_command 'all baz' end end diff --git a/spec/guard/commands/change_spec.rb b/spec/guard/commands/change_spec.rb index 49b82bbc0..5dec9a40b 100644 --- a/spec/guard/commands/change_spec.rb +++ b/spec/guard/commands/change_spec.rb @@ -11,21 +11,21 @@ describe '#perform' do context 'with a file' do it 'runs the :run_on_changes action with the given scope' do - ::Guard.runner.should_receive(:run_on_changes).with(['foo'], [], []) + expect(::Guard.runner).to receive(:run_on_changes).with(['foo'], [], []) Pry.run_command 'change foo' end end context 'with multiple files' do it 'runs the :run_on_changes action with the given scope' do - ::Guard.runner.should_receive(:run_on_changes).with(['foo', 'bar', 'baz'], [], []) + expect(::Guard.runner).to receive(:run_on_changes).with(['foo', 'bar', 'baz'], [], []) Pry.run_command 'change foo bar baz' end end context 'without a file' do it 'does not run the :run_on_changes action' do - ::Guard.runner.should_not_receive(:run_on_changes) + expect(::Guard.runner).to_not receive(:run_on_changes) Pry.run_command 'change' end end diff --git a/spec/guard/commands/notification_spec.rb b/spec/guard/commands/notification_spec.rb index 1f5702e46..10ab4f717 100644 --- a/spec/guard/commands/notification_spec.rb +++ b/spec/guard/commands/notification_spec.rb @@ -8,7 +8,7 @@ describe '#perform' do it 'toggles the Guard notifier' do - ::Guard::Notifier.should_receive(:toggle) + expect(::Guard::Notifier).to receive(:toggle) Pry.run_command 'notification' end end diff --git a/spec/guard/commands/pause_spec.rb b/spec/guard/commands/pause_spec.rb index 229cd723b..27f59ba1e 100644 --- a/spec/guard/commands/pause_spec.rb +++ b/spec/guard/commands/pause_spec.rb @@ -8,7 +8,7 @@ describe '#perform' do it 'pauses Guard' do - ::Guard.should_receive(:pause) + expect(::Guard).to receive(:pause) Pry.run_command 'pause' end end diff --git a/spec/guard/commands/reload_spec.rb b/spec/guard/commands/reload_spec.rb index c935924d3..10e618b4b 100644 --- a/spec/guard/commands/reload_spec.rb +++ b/spec/guard/commands/reload_spec.rb @@ -17,28 +17,28 @@ describe '#perform' do context 'without scope' do it 'runs the :reload action' do - Guard.should_receive(:reload).with({ groups: [], plugins: [] }) + expect(Guard).to receive(:reload).with({ groups: [], plugins: [] }) Pry.run_command 'reload' end end context 'with a valid Guard group scope' do it 'runs the :reload action with the given scope' do - Guard.should_receive(:reload).with({ groups: [foo_group], plugins: [] }) + expect(Guard).to receive(:reload).with({ groups: [foo_group], plugins: [] }) Pry.run_command 'reload foo' end end context 'with a valid Guard plugin scope' do it 'runs the :reload action with the given scope' do - Guard.should_receive(:reload).with({ plugins: [bar_guard], groups: [] }) + expect(Guard).to receive(:reload).with({ plugins: [bar_guard], groups: [] }) Pry.run_command 'reload bar' end end context 'with an invalid scope' do it 'does not run the action' do - Guard.should_not_receive(:reload) + expect(Guard).to_not receive(:reload) Pry.run_command 'reload baz' end end diff --git a/spec/guard/commands/scope_spec.rb b/spec/guard/commands/scope_spec.rb index 694dfe28f..3239bb9fd 100644 --- a/spec/guard/commands/scope_spec.rb +++ b/spec/guard/commands/scope_spec.rb @@ -17,29 +17,29 @@ describe '#perform' do context 'without scope' do it 'does not call :scope=' do - Guard.should_not_receive(:scope=) - Pry.output.should_receive(:puts).with 'Usage: scope ' + expect(Guard).to_not receive(:scope=) + expect(Pry.output).to receive(:puts).with 'Usage: scope ' Pry.run_command 'scope' end end context 'with a valid Guard group scope' do it 'runs the :scope= action with the given scope' do - Guard.should_receive(:scope=).with(groups: [foo_group], plugins: []) + expect(Guard).to receive(:scope=).with(groups: [foo_group], plugins: []) Pry.run_command 'scope foo' end end context 'with a valid Guard plugin scope' do it 'runs the :scope= action with the given scope' do - Guard.should_receive(:scope=).with(plugins: [bar_guard], groups: []) + expect(Guard).to receive(:scope=).with(plugins: [bar_guard], groups: []) Pry.run_command 'scope bar' end end context 'with an invalid scope' do it 'does not run the action' do - Guard.should_not_receive(:scope=) + expect(Guard).to_not receive(:scope=) Pry.run_command 'scope baz' end end diff --git a/spec/guard/commands/show_spec.rb b/spec/guard/commands/show_spec.rb index cba8c8bfe..4067ac240 100644 --- a/spec/guard/commands/show_spec.rb +++ b/spec/guard/commands/show_spec.rb @@ -4,7 +4,7 @@ describe '#perform' do it 'outputs the DSL description' do - ::Guard::DslDescriber.should_receive(:show) + expect(::Guard::DslDescriber).to receive(:show) Pry.run_command 'show' end end diff --git a/spec/guard/deprecated_methods_spec.rb b/spec/guard/deprecated_methods_spec.rb index b9ee5e829..a96e24392 100644 --- a/spec/guard/deprecated_methods_spec.rb +++ b/spec/guard/deprecated_methods_spec.rb @@ -11,13 +11,13 @@ module TestModule before { TestModule.stub(:plugins) } it 'displays a deprecation warning to the user' do - ::Guard::UI.should_receive(:deprecation).with(::Guard::Deprecator::GUARDS_DEPRECATION) + expect(::Guard::UI).to receive(:deprecation).with(::Guard::Deprecator::GUARDS_DEPRECATION) TestModule.guards end it 'delegates to Guard.plugins' do - TestModule.should_receive(:plugins).with(group: 'backend') + expect(TestModule).to receive(:plugins).with(group: 'backend') TestModule.guards(group: 'backend') end @@ -27,13 +27,13 @@ module TestModule before { TestModule.stub(:add_plugin) } it 'displays a deprecation warning to the user' do - ::Guard::UI.should_receive(:deprecation).with(::Guard::Deprecator::ADD_GUARD_DEPRECATION) + expect(::Guard::UI).to receive(:deprecation).with(::Guard::Deprecator::ADD_GUARD_DEPRECATION) TestModule.add_guard('rspec') end it 'delegates to Guard.plugins' do - TestModule.should_receive(:add_plugin).with('rspec', group: 'backend') + expect(TestModule).to receive(:add_plugin).with('rspec', group: 'backend') TestModule.add_guard('rspec', group: 'backend') end @@ -44,22 +44,22 @@ module TestModule before { ::Guard::PluginUtil.stub(:new).and_return(plugin_util) } it 'displays a deprecation warning to the user' do - ::Guard::UI.should_receive(:deprecation).with(::Guard::Deprecator::GET_GUARD_CLASS_DEPRECATION) + expect(::Guard::UI).to receive(:deprecation).with(::Guard::Deprecator::GET_GUARD_CLASS_DEPRECATION) TestModule.get_guard_class('rspec') end it 'delegates to Guard::PluginUtil' do - ::Guard::PluginUtil.should_receive(:new).with('rspec') { plugin_util } - plugin_util.should_receive(:plugin_class).with(fail_gracefully: false) + expect(::Guard::PluginUtil).to receive(:new).with('rspec') { plugin_util } + expect(plugin_util).to receive(:plugin_class).with(fail_gracefully: false) TestModule.get_guard_class('rspec') end describe ':fail_gracefully' do it 'pass it to get_guard_class' do - ::Guard::PluginUtil.should_receive(:new).with('rspec') { plugin_util } - plugin_util.should_receive(:plugin_class).with(fail_gracefully: true) + expect(::Guard::PluginUtil).to receive(:new).with('rspec') { plugin_util } + expect(plugin_util).to receive(:plugin_class).with(fail_gracefully: true) TestModule.get_guard_class('rspec', true) end @@ -71,14 +71,14 @@ module TestModule before { ::Guard::PluginUtil.stub(:new).and_return(plugin_util) } it 'displays a deprecation warning to the user' do - ::Guard::UI.should_receive(:deprecation).with(::Guard::Deprecator::LOCATE_GUARD_DEPRECATION) + expect(::Guard::UI).to receive(:deprecation).with(::Guard::Deprecator::LOCATE_GUARD_DEPRECATION) TestModule.locate_guard('rspec') end it 'delegates to Guard::PluginUtil' do - ::Guard::PluginUtil.should_receive(:new).with('rspec') { plugin_util } - plugin_util.should_receive(:plugin_location) + expect(::Guard::PluginUtil).to receive(:new).with('rspec') { plugin_util } + expect(plugin_util).to receive(:plugin_location) TestModule.locate_guard('rspec') end @@ -88,13 +88,13 @@ module TestModule before { ::Guard::PluginUtil.stub(:plugin_names) } it 'displays a deprecation warning to the user' do - ::Guard::UI.should_receive(:deprecation).with(::Guard::Deprecator::GUARD_GEM_NAMES_DEPRECATION) + expect(::Guard::UI).to receive(:deprecation).with(::Guard::Deprecator::GUARD_GEM_NAMES_DEPRECATION) TestModule.guard_gem_names end it 'delegates to Guard::PluginUtil' do - Guard::PluginUtil.should_receive(:plugin_names) + expect(Guard::PluginUtil).to receive(:plugin_names) TestModule.guard_gem_names end diff --git a/spec/guard/dsl_describer_spec.rb b/spec/guard/dsl_describer_spec.rb index 3d5606a32..2702a5eaf 100644 --- a/spec/guard/dsl_describer_spec.rb +++ b/spec/guard/dsl_describer_spec.rb @@ -90,7 +90,7 @@ it 'shows the Guards and their options' do ::Guard::DslDescriber.new(guardfile_contents: guardfile).show - @output.should eq result + expect(@output).to eq result end end @@ -124,7 +124,7 @@ it 'shows the notifiers and their options' do ::Guard::DslDescriber.new(guardfile_contents: guardfile).notifiers - @output.should eq result + expect(@output).to eq result end end end diff --git a/spec/guard/dsl_spec.rb b/spec/guard/dsl_spec.rb index 55de7009f..fd2d28e8e 100644 --- a/spec/guard/dsl_spec.rb +++ b/spec/guard/dsl_spec.rb @@ -21,14 +21,14 @@ def self.disable_user_config describe '.evaluate_guardfile' do it 'displays a deprecation warning to the user' do - ::Guard::UI.should_receive(:deprecation).with(::Guard::Deprecator::EVALUATE_GUARDFILE_DEPRECATION) + expect(::Guard::UI).to receive(:deprecation).with(::Guard::Deprecator::EVALUATE_GUARDFILE_DEPRECATION) described_class.evaluate_guardfile end it 'delegates to Guard::Guardfile::Generator' do - Guard::Guardfile::Evaluator.should_receive(:new).with(foo: 'bar') { guardfile_evaluator } - guardfile_evaluator.should_receive(:evaluate_guardfile) + expect(Guard::Guardfile::Evaluator).to receive(:new).with(foo: 'bar') { guardfile_evaluator } + expect(guardfile_evaluator).to receive(:evaluate_guardfile) described_class.evaluate_guardfile(foo: 'bar') end @@ -40,7 +40,7 @@ def self.disable_user_config it 'adds ignored regexps to the listener' do ::Guard.stub(:listener) { listener } - ::Guard.listener.should_receive(:ignore).with(/^foo/,/bar/) { listener } + expect(::Guard.listener).to receive(:ignore).with(/^foo/,/bar/) { listener } described_class.evaluate_guardfile(guardfile_contents: 'ignore %r{^foo}, /bar/') end @@ -52,7 +52,7 @@ def self.disable_user_config it 'replaces ignored regexps in the listener' do ::Guard.stub(:listener) { listener } - ::Guard.listener.should_receive(:ignore!).with([[/^foo/,/bar/]]) { listener } + expect(::Guard.listener).to receive(:ignore!).with([[/^foo/,/bar/]]) { listener } described_class.evaluate_guardfile(guardfile_contents: 'ignore! %r{^foo}, /bar/') end @@ -60,7 +60,7 @@ def self.disable_user_config it 'replaces ignored regexps in the listener but keeps these setted by filter!' do ::Guard.stub(:listener) { listener } ::Guard.listener.stub(:ignore!) - ::Guard.listener.should_receive(:ignore!).with([[/.txt$/, /.*.zip/], [/^foo/]]) { listener } + expect(::Guard.listener).to receive(:ignore!).with([[/.txt$/, /.*.zip/], [/^foo/]]) { listener } described_class.evaluate_guardfile(guardfile_contents: "filter! %r{.txt$}, /.*.zip/\n ignore! %r{^foo}") end @@ -72,7 +72,7 @@ def self.disable_user_config it 'adds ignored regexps to the listener' do ::Guard.stub(:listener) { listener } - ::Guard.listener.should_receive(:ignore).with(/.txt$/, /.*.zip/) { listener } + expect(::Guard.listener).to receive(:ignore).with(/.txt$/, /.*.zip/) { listener } described_class.evaluate_guardfile(guardfile_contents: 'filter %r{.txt$}, /.*.zip/') end @@ -84,7 +84,7 @@ def self.disable_user_config it 'replaces ignored regexps in the listener' do ::Guard.stub(:listener) { listener } - ::Guard.listener.should_receive(:ignore!).with([[/.txt$/, /.*.zip/]]) { listener } + expect(::Guard.listener).to receive(:ignore!).with([[/.txt$/, /.*.zip/]]) { listener } described_class.evaluate_guardfile(guardfile_contents: 'filter! %r{.txt$}, /.*.zip/') end @@ -92,7 +92,7 @@ def self.disable_user_config it 'replaces ignored regexps in the listener but keeps these setted by ignore!' do ::Guard.stub(:listener) { listener } ::Guard.listener.stub(:ignore!) - ::Guard.listener.should_receive(:ignore!).with([[/^foo/], [/.txt$/, /.*.zip/]]) { listener } + expect(::Guard.listener).to receive(:ignore!).with([[/^foo/], [/.txt$/, /.*.zip/]]) { listener } described_class.evaluate_guardfile(guardfile_contents: "ignore! %r{^foo}\n filter! %r{.txt$}, /.*.zip/") end @@ -102,13 +102,13 @@ def self.disable_user_config disable_user_config it 'adds a notification to the notifier' do - ::Guard::Notifier.should_receive(:add_notifier).with(:growl, { silent: false }) + expect(::Guard::Notifier).to receive(:add_notifier).with(:growl, { silent: false }) described_class.evaluate_guardfile(guardfile_contents: 'notification :growl') end it 'adds multiple notification to the notifier' do - ::Guard::Notifier.should_receive(:add_notifier).with(:growl, { silent: false }) - ::Guard::Notifier.should_receive(:add_notifier).with(:ruby_gntp, { host: '192.168.1.5', silent: false }) + expect(::Guard::Notifier).to receive(:add_notifier).with(:growl, { silent: false }) + expect(::Guard::Notifier).to receive(:add_notifier).with(:ruby_gntp, { host: '192.168.1.5', silent: false }) described_class.evaluate_guardfile(guardfile_contents: "notification :growl\nnotification :ruby_gntp, host: '192.168.1.5'") end end @@ -118,12 +118,12 @@ def self.disable_user_config it 'disables the interactions with :off' do described_class.evaluate_guardfile(guardfile_contents: 'interactor :off') - Guard::Interactor.enabled.should be_false + expect(Guard::Interactor.enabled).to be_false end it 'passes the options to the interactor' do described_class.evaluate_guardfile(guardfile_contents: 'interactor option1: \'a\', option2: 123') - Guard::Interactor.options.should include({ option1: 'a', option2: 123 }) + expect(Guard::Interactor.options).to include({ option1: 'a', option2: 123 }) end end @@ -132,7 +132,7 @@ def self.disable_user_config context 'no plugins in group' do it 'displays an error' do - ::Guard::UI.should_receive(:error).with("No Guard plugins found in the group 'w', please add at least one.") + expect(::Guard::UI).to receive(:error).with("No Guard plugins found in the group 'w', please add at least one.") described_class.evaluate_guardfile(guardfile_contents: guardfile_string_with_empty_group) end @@ -151,10 +151,10 @@ def self.disable_user_config end it 'evaluates all groups' do - ::Guard.should_receive(:add_plugin).with(:pow, { watchers: [], callbacks: [], group: :default }) - ::Guard.should_receive(:add_plugin).with(:test, { watchers: [], callbacks: [], group: :w }) - ::Guard.should_receive(:add_plugin).with(:rspec, { watchers: [], callbacks: [], group: :x }).twice - ::Guard.should_receive(:add_plugin).with(:less, { watchers: [], callbacks: [], group: :y }) + expect(::Guard).to receive(:add_plugin).with(:pow, { watchers: [], callbacks: [], group: :default }) + expect(::Guard).to receive(:add_plugin).with(:test, { watchers: [], callbacks: [], group: :w }) + expect(::Guard).to receive(:add_plugin).with(:rspec, { watchers: [], callbacks: [], group: :x }).twice + expect(::Guard).to receive(:add_plugin).with(:less, { watchers: [], callbacks: [], group: :y }) described_class.evaluate_guardfile(guardfile_contents: valid_guardfile_string) end @@ -164,31 +164,31 @@ def self.disable_user_config disable_user_config it 'loads a guard specified as a quoted string from the DSL' do - ::Guard.should_receive(:add_plugin).with('test', { watchers: [], callbacks: [], group: :default }) + expect(::Guard).to receive(:add_plugin).with('test', { watchers: [], callbacks: [], group: :default }) described_class.evaluate_guardfile(guardfile_contents: 'guard \'test\'') end it 'loads a guard specified as a double quoted string from the DSL' do - ::Guard.should_receive(:add_plugin).with('test', { watchers: [], callbacks: [], group: :default }) + expect(::Guard).to receive(:add_plugin).with('test', { watchers: [], callbacks: [], group: :default }) described_class.evaluate_guardfile(guardfile_contents: 'guard "test"') end it 'loads a guard specified as a symbol from the DSL' do - ::Guard.should_receive(:add_plugin).with(:test, { watchers: [], callbacks: [], group: :default }) + expect(::Guard).to receive(:add_plugin).with(:test, { watchers: [], callbacks: [], group: :default }) described_class.evaluate_guardfile(guardfile_contents: 'guard :test') end it 'loads a guard specified as a symbol and called with parens from the DSL' do - ::Guard.should_receive(:add_plugin).with(:test, { watchers: [], callbacks: [], group: :default }) + expect(::Guard).to receive(:add_plugin).with(:test, { watchers: [], callbacks: [], group: :default }) described_class.evaluate_guardfile(guardfile_contents: 'guard(:test)') end it 'receives options when specified, from normal arg' do - ::Guard.should_receive(:add_plugin).with('test', { watchers: [], callbacks: [], opt_a: 1, opt_b: 'fancy', group: :default }) + expect(::Guard).to receive(:add_plugin).with('test', { watchers: [], callbacks: [], opt_a: 1, opt_b: 'fancy', group: :default }) described_class.evaluate_guardfile(guardfile_contents: 'guard \'test\', opt_a: 1, opt_b: \'fancy\'') end @@ -198,12 +198,12 @@ def self.disable_user_config disable_user_config it 'should receive watchers when specified' do - ::Guard.should_receive(:add_plugin).with(:dummy, { watchers: [anything, anything], callbacks: [], group: :default }) do |_, options| - options[:watchers].size.should eq 2 - options[:watchers][0].pattern.should eq 'a' - options[:watchers][0].action.call.should eq proc { 'b' }.call - options[:watchers][1].pattern.should eq 'c' - options[:watchers][1].action.should be_nil + expect(::Guard).to receive(:add_plugin).with(:dummy, { watchers: [anything, anything], callbacks: [], group: :default }) do |_, options| + expect(options[:watchers].size).to eq 2 + expect(options[:watchers][0].pattern).to eq 'a' + expect(options[:watchers][0].action.call).to eq proc { 'b' }.call + expect(options[:watchers][1].pattern).to eq 'c' + expect(options[:watchers][1].action).to be_nil end described_class.evaluate_guardfile(guardfile_contents: ' guard :dummy do @@ -221,12 +221,12 @@ def self.call(plugin, event, args) end end - ::Guard.should_receive(:add_plugin).with(:rspec, { watchers: [], callbacks: [anything, anything], group: :default }) do |_, options| - options[:callbacks].should have(2).items - options[:callbacks][0][:events].should eq :start_end - options[:callbacks][0][:listener].call(Guard::RSpec, :start_end, 'foo').should eq 'Guard::RSpec executed \'start_end\' hook with foo!' - options[:callbacks][1][:events].should eq [:start_begin, :run_all_begin] - options[:callbacks][1][:listener].should eq MyCustomCallback + expect(::Guard).to receive(:add_plugin).with(:rspec, { watchers: [], callbacks: [anything, anything], group: :default }) do |_, options| + expect(options[:callbacks]).to have(2).items + expect(options[:callbacks][0][:events]).to eq :start_end + expect(options[:callbacks][0][:listener].call(Guard::RSpec, :start_end, 'foo')).to eq 'Guard::RSpec executed \'start_end\' hook with foo!' + expect(options[:callbacks][1][:events]).to eq [:start_begin, :run_all_begin] + expect(options[:callbacks][1][:listener]).to eq MyCustomCallback end described_class.evaluate_guardfile(guardfile_contents: ' @@ -243,78 +243,78 @@ def self.call(plugin, event, args) context 'with valid options' do it 'sets the logger log level' do described_class.evaluate_guardfile(guardfile_contents: 'logger level: :error') - Guard::UI.options.level.should eq :error + expect(Guard::UI.options.level).to eq :error end it 'sets the logger log level and convert to a symbol' do described_class.evaluate_guardfile(guardfile_contents: 'logger level: \'error\'') - Guard::UI.options.level.should eq :error + expect(Guard::UI.options.level).to eq :error end it 'sets the logger template' do described_class.evaluate_guardfile(guardfile_contents: 'logger template: \':message - :severity\'') - Guard::UI.options.template.should eq ':message - :severity' + expect(Guard::UI.options.template).to eq ':message - :severity' end it 'sets the logger time format' do described_class.evaluate_guardfile(guardfile_contents: 'logger time_format: \'%Y\'') - Guard::UI.options.time_format.should eq '%Y' + expect(Guard::UI.options.time_format).to eq '%Y' end it 'sets the logger only filter from a symbol' do described_class.evaluate_guardfile(guardfile_contents: 'logger only: :cucumber') - Guard::UI.options.only.should eq(/cucumber/i) + expect(Guard::UI.options.only).to eq(/cucumber/i) end it 'sets the logger only filter from a string' do described_class.evaluate_guardfile(guardfile_contents: 'logger only: \'jasmine\'') - Guard::UI.options.only.should eq(/jasmine/i) + expect(Guard::UI.options.only).to eq(/jasmine/i) end it 'sets the logger only filter from an array of symbols and string' do described_class.evaluate_guardfile(guardfile_contents: 'logger only: [:rspec, \'cucumber\']') - Guard::UI.options.only.should eq(/rspec|cucumber/i) + expect(Guard::UI.options.only).to eq(/rspec|cucumber/i) end it 'sets the logger except filter from a symbol' do described_class.evaluate_guardfile(guardfile_contents: 'logger except: :jasmine') - Guard::UI.options.except.should eq(/jasmine/i) + expect(Guard::UI.options.except).to eq(/jasmine/i) end it 'sets the logger except filter from a string' do described_class.evaluate_guardfile(guardfile_contents: 'logger except: \'jasmine\'') - Guard::UI.options.except.should eq(/jasmine/i) + expect(Guard::UI.options.except).to eq(/jasmine/i) end it 'sets the logger except filter from an array of symbols and string' do described_class.evaluate_guardfile(guardfile_contents: 'logger except: [:rspec, \'cucumber\', :jasmine]') - Guard::UI.options.except.should eq(/rspec|cucumber|jasmine/i) + expect(Guard::UI.options.except).to eq(/rspec|cucumber|jasmine/i) end end context 'with invalid options' do context 'for the log level' do it 'shows a warning' do - Guard::UI.should_receive(:warning).with 'Invalid log level `baz` ignored. Please use either :debug, :info, :warn or :error.' + expect(Guard::UI).to receive(:warning).with 'Invalid log level `baz` ignored. Please use either :debug, :info, :warn or :error.' described_class.evaluate_guardfile(guardfile_contents: 'logger level: :baz') end it 'does not set the invalid value' do described_class.evaluate_guardfile(guardfile_contents: 'logger level: :baz') - Guard::UI.options.level.should eq :info + expect(Guard::UI.options.level).to eq :info end end context 'when having both the :only and :except options' do it 'shows a warning' do - Guard::UI.should_receive(:warning).with 'You cannot specify the logger options :only and :except at the same time.' + expect(Guard::UI).to receive(:warning).with 'You cannot specify the logger options :only and :except at the same time.' described_class.evaluate_guardfile(guardfile_contents: 'logger only: :jasmine, except: :rspec') end it 'removes the options' do described_class.evaluate_guardfile(guardfile_contents: 'logger only: :jasmine, except: :rspec') - Guard::UI.options.only.should be_nil - Guard::UI.options.except.should be_nil + expect(Guard::UI.options.only).to be_nil + expect(Guard::UI.options.except).to be_nil end end @@ -331,24 +331,24 @@ def self.call(plugin, event, args) it 'does use the DSL scope plugin' do described_class.evaluate_guardfile(guardfile_contents: 'scope plugin: :baz') - ::Guard.scope[:plugins].should eq [::Guard.plugin(:baz)] + expect(::Guard.scope[:plugins]).to eq [::Guard.plugin(:baz)] ::Guard.setup_scope(plugins: [], groups: []) - ::Guard.scope[:plugins].should eq [::Guard.plugin(:baz)] + expect(::Guard.scope[:plugins]).to eq [::Guard.plugin(:baz)] end it 'does use the DSL scope plugins' do described_class.evaluate_guardfile(guardfile_contents: 'scope plugins: [:foo, :bar]') - ::Guard.scope[:plugins].should eq [::Guard.plugin(:foo), ::Guard.plugin(:bar)] + expect(::Guard.scope[:plugins]).to eq [::Guard.plugin(:foo), ::Guard.plugin(:bar)] end it 'does use the DSL scope group' do described_class.evaluate_guardfile(guardfile_contents: 'scope group: :baz') - ::Guard.scope[:groups].should eq ::Guard.groups(:baz) + expect(::Guard.scope[:groups]).to eq ::Guard.groups(:baz) end it 'does use the DSL scope groups' do described_class.evaluate_guardfile(guardfile_contents: 'scope groups: [:foo, :bar]') - ::Guard.scope[:groups].should eq [::Guard.group(:foo), ::Guard.group(:bar)] + expect(::Guard.scope[:groups]).to eq [::Guard.group(:foo), ::Guard.group(:bar)] end end diff --git a/spec/guard/group_spec.rb b/spec/guard/group_spec.rb index 759c83d06..9c1bf69a4 100644 --- a/spec/guard/group_spec.rb +++ b/spec/guard/group_spec.rb @@ -4,29 +4,29 @@ describe ".initialize" do it "accepts a name as a string and provides an accessor for it (returning a symbol)" do - described_class.new('foo').name.should eq :foo + expect(described_class.new('foo').name).to eq :foo end it "accepts a name as a symbol and provides an accessor for it (returning a symbol)" do - described_class.new(:foo).name.should eq :foo + expect(described_class.new(:foo).name).to eq :foo end it "accepts options and provides an accessor for it" do - described_class.new('foo', halt_on_fail: true).options.should eq({ halt_on_fail: true }) + expect(described_class.new('foo', halt_on_fail: true).options).to eq({ halt_on_fail: true }) end end describe '#title' do it "output Group title properly" do group = described_class.new(:foo) - group.title.should eq 'Foo' + expect(group.title).to eq 'Foo' end end describe '#to_s' do it "output Group properly" do group = described_class.new(:foo) - group.to_s.should eq '#' + expect(group.to_s).to eq '#' end end diff --git a/spec/guard/guard_spec.rb b/spec/guard/guard_spec.rb index 26fe8e053..432f37c35 100644 --- a/spec/guard/guard_spec.rb +++ b/spec/guard/guard_spec.rb @@ -6,23 +6,23 @@ describe '#initialize' do it 'assigns the defined watchers' do watchers = [Guard::Watcher.new('*')] - Guard::Guard.new(watchers).watchers.should eq watchers + expect(Guard::Guard.new(watchers).watchers).to eq watchers end it 'assigns the defined options' do options = { a: 1, b: 2 } - Guard::Guard.new([], options).options.should eq options + expect(Guard::Guard.new([], options).options).to eq options end context 'with a group in the options' do it 'assigns the given group' do - Guard::Guard.new([], group: :test).group.should eq Guard.group(:test) + expect(Guard::Guard.new([], group: :test).group).to eq Guard.group(:test) end end context 'without a group in the options' do it 'assigns a default group' do - Guard::Guard.new.group.should eq Guard.group(:default) + expect(Guard::Guard.new.group).to eq Guard.group(:default) end end end diff --git a/spec/guard/guardfile/evaluator_spec.rb b/spec/guard/guardfile/evaluator_spec.rb index 913913a4e..edcf959ad 100644 --- a/spec/guard/guardfile/evaluator_spec.rb +++ b/spec/guard/guardfile/evaluator_spec.rb @@ -18,14 +18,14 @@ def self.disable_user_config describe '.evaluate' do it 'displays an error message when Guardfile is not valid and raise original exception' do - Guard::UI.should_receive(:error).with(/Invalid Guardfile, original error is:/) + expect(Guard::UI).to receive(:error).with(/Invalid Guardfile, original error is:/) expect { described_class.new(guardfile_contents: 'Bad Guardfile').evaluate_guardfile }.to raise_error(NoMethodError) end it 'displays an error message when no Guardfile is found' do guardfile_evaluator.stub(:_guardfile_default_path).and_return('no_guardfile_here') - Guard::UI.should_receive(:error).with('No Guardfile found, please create one with `guard init`.') + expect(Guard::UI).to receive(:error).with('No Guardfile found, please create one with `guard init`.') expect { guardfile_evaluator.evaluate_guardfile }.to raise_error end @@ -34,7 +34,7 @@ def self.disable_user_config guardfile_evaluator = described_class.new(guardfile_contents: valid_guardfile_string) guardfile_evaluator.stub(:_instance_eval_guardfile) ::Guard.stub(:plugins).and_return([]) - Guard::UI.should_not_receive(:error) + expect(Guard::UI).to_not receive(:error) guardfile_evaluator.evaluate_guardfile end @@ -46,14 +46,14 @@ def self.disable_user_config File.stub(:exist?).with('/def/Guardfile') { true } File.stub(:read).with('/def/Guardfile') { raise Errno::EACCES.new('permission error') } - Guard::UI.should_receive(:error).with(/^Error reading file/) + expect(Guard::UI).to receive(:error).with(/^Error reading file/) expect { described_class.new(guardfile: '/def/Guardfile').evaluate_guardfile }.to raise_error end it 'raises error when given Guardfile doesn\'t exist' do File.stub(:exist?).with('/def/Guardfile') { false } - Guard::UI.should_receive(:error).with(/No Guardfile exists at/) + expect(Guard::UI).to receive(:error).with(/No Guardfile exists at/) expect { described_class.new(guardfile: '/def/Guardfile').evaluate_guardfile }.to raise_error end @@ -61,17 +61,17 @@ def self.disable_user_config File.stub(:exist?).with(local_guardfile) { false } File.stub(:exist?).with(home_guardfile) { false } - Guard::UI.should_receive(:error).with('No Guardfile found, please create one with `guard init`.') + expect(Guard::UI).to receive(:error).with('No Guardfile found, please create one with `guard init`.') expect { described_class.new.evaluate_guardfile }.to raise_error end it 'raises error when guardfile_content ends up empty or nil' do - Guard::UI.should_receive(:error).with('No Guard plugins found in Guardfile, please add at least one.') + expect(Guard::UI).to receive(:error).with('No Guard plugins found in Guardfile, please add at least one.') described_class.new(guardfile_contents: '').evaluate_guardfile end it 'doesn\'t raise error when guardfile_content is nil (skipped)' do - Guard::UI.should_not_receive(:error) + expect(Guard::UI).to_not receive(:error) expect { described_class.new(guardfile_contents: nil).evaluate_guardfile }.to_not raise_error end end @@ -82,26 +82,26 @@ def self.disable_user_config it 'should use a string for initializing' do guardfile_evaluator = described_class.new(guardfile_contents: valid_guardfile_string) - Guard::UI.should_not_receive(:error) + expect(Guard::UI).to_not receive(:error) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_contents.should eq valid_guardfile_string + expect(guardfile_evaluator.guardfile_contents).to eq valid_guardfile_string end it 'should use a given file over the default loc' do guardfile_evaluator = described_class.new(guardfile: '/abc/Guardfile') fake_guardfile('/abc/Guardfile', 'guard :foo') - Guard::UI.should_not_receive(:error) + expect(Guard::UI).to_not receive(:error) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_contents.should eq 'guard :foo' + expect(guardfile_evaluator.guardfile_contents).to eq 'guard :foo' end it 'should use a default file if no other options are given' do fake_guardfile(local_guardfile, 'guard :bar') - Guard::UI.should_not_receive(:error) + expect(Guard::UI).to_not receive(:error) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_contents.should eq 'guard :bar' + expect(guardfile_evaluator.guardfile_contents).to eq 'guard :bar' end it 'should use a string over any other method' do @@ -109,9 +109,9 @@ def self.disable_user_config fake_guardfile('/abc/Guardfile', 'guard :foo') fake_guardfile(local_guardfile, 'guard :bar') - Guard::UI.should_not_receive(:error) + expect(Guard::UI).to_not receive(:error) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_contents.should eq valid_guardfile_string + expect(guardfile_evaluator.guardfile_contents).to eq valid_guardfile_string end it 'should use the given Guardfile over default Guardfile' do @@ -119,9 +119,9 @@ def self.disable_user_config fake_guardfile('/abc/Guardfile', 'guard :foo') fake_guardfile(local_guardfile, 'guard :bar') - Guard::UI.should_not_receive(:error) + expect(Guard::UI).to_not receive(:error) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_contents.should eq 'guard :foo' + expect(guardfile_evaluator.guardfile_contents).to eq 'guard :foo' end it 'should append the user config file if present' do @@ -129,9 +129,9 @@ def self.disable_user_config fake_guardfile('/abc/Guardfile', 'guard :foo') fake_guardfile(home_config, 'guard :bar') - Guard::UI.should_not_receive(:error) + expect(Guard::UI).to_not receive(:error) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_contents.should eq "guard :foo\nguard :bar" + expect(guardfile_evaluator.guardfile_contents).to eq "guard :foo\nguard :bar" end end @@ -142,7 +142,7 @@ def self.disable_user_config it 'reads correctly from a string' do guardfile_evaluator = described_class.new(guardfile_contents: valid_guardfile_string) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_contents.should eq valid_guardfile_string + expect(guardfile_evaluator.guardfile_contents).to eq valid_guardfile_string end it 'reads correctly from a Guardfile' do @@ -150,7 +150,7 @@ def self.disable_user_config fake_guardfile('/abc/Guardfile', 'guard :rspec') expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_contents.should eq 'guard :rspec' + expect(guardfile_evaluator.guardfile_contents).to eq 'guard :rspec' end context 'with a local Guardfile only' do @@ -158,8 +158,8 @@ def self.disable_user_config fake_guardfile(local_guardfile, valid_guardfile_string) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_path.should eq local_guardfile - guardfile_evaluator.guardfile_contents.should eq valid_guardfile_string + expect(guardfile_evaluator.guardfile_path).to eq local_guardfile + expect(guardfile_evaluator.guardfile_contents).to eq valid_guardfile_string end end @@ -169,8 +169,8 @@ def self.disable_user_config fake_guardfile(home_guardfile, valid_guardfile_string) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_path.should eq home_guardfile - guardfile_evaluator.guardfile_contents.should eq valid_guardfile_string + expect(guardfile_evaluator.guardfile_path).to eq home_guardfile + expect(guardfile_evaluator.guardfile_contents).to eq valid_guardfile_string end end @@ -180,8 +180,8 @@ def self.disable_user_config fake_guardfile(home_guardfile, valid_guardfile_string) expect { guardfile_evaluator.evaluate_guardfile }.to_not raise_error - guardfile_evaluator.guardfile_path.should eq local_guardfile - guardfile_evaluator.guardfile_contents.should eq valid_guardfile_string + expect(guardfile_evaluator.guardfile_path).to eq local_guardfile + expect(guardfile_evaluator.guardfile_contents).to eq valid_guardfile_string end end end @@ -195,25 +195,25 @@ def self.disable_user_config let(:growl) { { name: :growl, options: {} } } it 'evaluates the Guardfile' do - guardfile_evaluator.should_receive(:evaluate_guardfile) + expect(guardfile_evaluator).to receive(:evaluate_guardfile) guardfile_evaluator.reevaluate_guardfile end it 'stops all Guards' do - ::Guard.runner.should_receive(:run).with(:stop) + expect(::Guard.runner).to receive(:run).with(:stop) guardfile_evaluator.reevaluate_guardfile end it 'reset all Guard plugins' do - ::Guard.should_receive(:reset_plugins) + expect(::Guard).to receive(:reset_plugins) guardfile_evaluator.reevaluate_guardfile end it 'resets all groups' do - ::Guard.should_receive(:reset_groups) + expect(::Guard).to receive(:reset_groups) guardfile_evaluator.reevaluate_guardfile end @@ -221,24 +221,24 @@ def self.disable_user_config it 'clears the notifications' do ::Guard::Notifier.turn_off ::Guard::Notifier.notifiers = [growl] - ::Guard::Notifier.notifiers.should_not be_empty + expect(::Guard::Notifier.notifiers).not_to be_empty guardfile_evaluator.reevaluate_guardfile - ::Guard::Notifier.notifiers.should be_empty + expect(::Guard::Notifier.notifiers).to be_empty end it 'removes the cached Guardfile content' do guardfile_evaluator.reevaluate_guardfile - guardfile_evaluator.options.guardfile_content.should be_nil + expect(guardfile_evaluator.options.guardfile_content).to be_nil end context 'with notifications enabled' do before { ::Guard::Notifier.stub(:enabled?).and_return true } it 'enables the notifications again' do - ::Guard::Notifier.should_receive(:turn_on) + expect(::Guard::Notifier).to receive(:turn_on) guardfile_evaluator.reevaluate_guardfile end @@ -248,7 +248,7 @@ def self.disable_user_config before { ::Guard::Notifier.stub(:enabled?).and_return false } it 'does not enable the notifications again' do - ::Guard::Notifier.should_not_receive(:turn_on) + expect(::Guard::Notifier).to_not receive(:turn_on) guardfile_evaluator.reevaluate_guardfile end @@ -261,19 +261,19 @@ def self.disable_user_config end it 'shows a success message' do - ::Guard::UI.should_receive(:info).with('Guardfile has been re-evaluated.') + expect(::Guard::UI).to receive(:info).with('Guardfile has been re-evaluated.') guardfile_evaluator.reevaluate_guardfile end it 'shows a success notification' do - ::Guard::Notifier.should_receive(:notify).with('Guardfile has been re-evaluated.', title: 'Guard re-evaluate') + expect(::Guard::Notifier).to receive(:notify).with('Guardfile has been re-evaluated.', title: 'Guard re-evaluate') guardfile_evaluator.reevaluate_guardfile end it 'starts all Guards' do - ::Guard.runner.should_receive(:run).with(:start) + expect(::Guard.runner).to receive(:run).with(:start) guardfile_evaluator.reevaluate_guardfile end @@ -285,7 +285,7 @@ def self.disable_user_config end it 'shows a failure notification' do - ::Guard::Notifier.should_receive(:notify).with('No plugins found in Guardfile, please add at least one.', title: 'Guard re-evaluate', image: :failed) + expect(::Guard::Notifier).to receive(:notify).with('No plugins found in Guardfile, please add at least one.', title: 'Guard re-evaluate', image: :failed) guardfile_evaluator.reevaluate_guardfile end @@ -296,25 +296,25 @@ def self.disable_user_config it 'detects a guard specified by a string with double quotes' do guardfile_evaluator.stub(_guardfile_contents_without_user_config: 'guard "test" {watch("c")}') - guardfile_evaluator.guardfile_include?('test').should be_true + expect(guardfile_evaluator.guardfile_include?('test')).to be_true end it 'detects a guard specified by a string with single quote' do guardfile_evaluator.stub(_guardfile_contents_without_user_config: 'guard \'test\' {watch("c")}') - guardfile_evaluator.guardfile_include?('test').should be_true + expect(guardfile_evaluator.guardfile_include?('test')).to be_true end it 'detects a guard specified by a symbol' do guardfile_evaluator.stub(_guardfile_contents_without_user_config: 'guard :test {watch("c")}') - guardfile_evaluator.guardfile_include?('test').should be_true + expect(guardfile_evaluator.guardfile_include?('test')).to be_true end it 'detects a guard wrapped in parentheses' do guardfile_evaluator.stub(_guardfile_contents_without_user_config: 'guard(:test) {watch("c")}') - guardfile_evaluator.guardfile_include?('test').should be_true + expect(guardfile_evaluator.guardfile_include?('test')).to be_true end end diff --git a/spec/guard/guardfile/generator_spec.rb b/spec/guard/guardfile/generator_spec.rb index ff8111018..c7766fd76 100644 --- a/spec/guard/guardfile/generator_spec.rb +++ b/spec/guard/guardfile/generator_spec.rb @@ -6,33 +6,33 @@ let(:guardfile_generator) { described_class.new } it "has a valid Guardfile template" do - File.exists?(described_class::GUARDFILE_TEMPLATE).should be_true + expect(File.exists?(described_class::GUARDFILE_TEMPLATE)).to be_true end describe '#create_guardfile' do before { Dir.stub(:pwd).and_return "/home/user" } context "with an existing Guardfile" do - before { File.should_receive(:exist?).and_return true } + before { expect(File).to receive(:exist?) { true } } it "does not copy the Guardfile template or notify the user" do - ::Guard::UI.should_not_receive(:info) - FileUtils.should_not_receive(:cp) + expect(::Guard::UI).to_not receive(:info) + expect(FileUtils).to_not receive(:cp) described_class.new.create_guardfile end it "does not display any kind of error or abort" do - ::Guard::UI.should_not_receive(:error) - described_class.should_not_receive(:abort) + expect(::Guard::UI).to_not receive(:error) + expect(described_class).to_not receive(:abort) described_class.new.create_guardfile end context "with the :abort_on_existence option set to true" do it "displays an error message and aborts the process" do guardfile_generator = described_class.new(abort_on_existence: true) - ::Guard::UI.should_receive(:error).with("Guardfile already exists at /home/user/Guardfile") - guardfile_generator.should_receive(:abort) + expect(::Guard::UI).to receive(:error).with("Guardfile already exists at /home/user/Guardfile") + expect(guardfile_generator).to receive(:abort) guardfile_generator.create_guardfile end @@ -40,11 +40,11 @@ end context "without an existing Guardfile" do - before { File.should_receive(:exist?).and_return false } + before { expect(File).to receive(:exist?) { false } } it "copies the Guardfile template and notifies the user" do - ::Guard::UI.should_receive(:info) - FileUtils.should_receive(:cp) + expect(::Guard::UI).to receive(:info) + expect(FileUtils).to receive(:cp) described_class.new.create_guardfile end @@ -54,12 +54,12 @@ describe '#initialize_template' do context 'with an installed Guard implementation' do before do - ::Guard::PluginUtil.should_receive(:new) { plugin_util } - plugin_util.should_receive(:plugin_class) { double('Guard::Foo').as_null_object } + expect(::Guard::PluginUtil).to receive(:new) { plugin_util } + expect(plugin_util).to receive(:plugin_class) { double('Guard::Foo').as_null_object } end it 'initializes the Guard' do - plugin_util.should_receive(:add_to_guardfile) + expect(plugin_util).to receive(:add_to_guardfile) described_class.new.initialize_template('foo') end end @@ -67,27 +67,27 @@ context "with a user defined template" do let(:template) { File.join(described_class::HOME_TEMPLATES, '/bar') } - before { File.should_receive(:exist?).with(template).and_return true } + before { expect(File).to receive(:exist?).with(template) { true } } it "copies the Guardfile template and initializes the Guard" do - File.should_receive(:read).with('Guardfile').and_return 'Guardfile content' - File.should_receive(:read).with(template).and_return 'Template content' + expect(File).to receive(:read).with('Guardfile').and_return 'Guardfile content' + expect(File).to receive(:read).with(template).and_return 'Template content' io = StringIO.new - File.should_receive(:open).with('Guardfile', 'wb').and_yield io + expect(File).to receive(:open).with('Guardfile', 'wb').and_yield io described_class.new.initialize_template('bar') - io.string.should eq "Guardfile content\n\nTemplate content\n" + expect(io.string).to eq "Guardfile content\n\nTemplate content\n" end end context "when the passed guard can't be found" do before do - ::Guard::PluginUtil.should_receive(:new) { plugin_util } + expect(::Guard::PluginUtil).to receive(:new) { plugin_util } plugin_util.stub(:plugin_class) { nil } - File.should_receive(:exist?).and_return false + expect(File).to receive(:exist?).and_return false end it "notifies the user about the problem" do - ::Guard::UI.should_receive(:error).with( + expect(::Guard::UI).to receive(:error).with( "Could not load 'guard/foo' or '~/.guard/templates/foo' or find class Guard::Foo" ) described_class.new.initialize_template('foo') @@ -98,12 +98,12 @@ describe '#initialize_all_templates' do let(:plugins) { ['rspec', 'spork', 'phpunit'] } - before { ::Guard::PluginUtil.should_receive(:plugin_names).and_return(plugins) } + before { expect(::Guard::PluginUtil).to receive(:plugin_names) { plugins } } it "calls Guard.initialize_template on all installed plugins" do guardfile_generator = described_class.new plugins.each do |g| - guardfile_generator.should_receive(:initialize_template).with(g) + expect(guardfile_generator).to receive(:initialize_template).with(g) end guardfile_generator.initialize_all_templates diff --git a/spec/guard/guardfile_spec.rb b/spec/guard/guardfile_spec.rb index 9391ee9b9..a909ed749 100644 --- a/spec/guard/guardfile_spec.rb +++ b/spec/guard/guardfile_spec.rb @@ -6,14 +6,14 @@ describe '.create_guardfile' do it 'displays a deprecation warning to the user' do - ::Guard::UI.should_receive(:deprecation).with(::Guard::Deprecator::CREATE_GUARDFILE_DEPRECATION) + expect(::Guard::UI).to receive(:deprecation).with(::Guard::Deprecator::CREATE_GUARDFILE_DEPRECATION) described_class.create_guardfile end it 'delegates to Guard::Guardfile::Generator' do - described_class::Generator.should_receive(:new).with(foo: 'bar') { guardfile_generator } - guardfile_generator.should_receive(:create_guardfile) + expect(described_class::Generator).to receive(:new).with(foo: 'bar') { guardfile_generator } + expect(guardfile_generator).to receive(:create_guardfile) described_class.create_guardfile(foo: 'bar') end @@ -21,18 +21,18 @@ describe '.initialize_template' do before do - described_class::Generator.should_receive(:new) { guardfile_generator } + expect(described_class::Generator).to receive(:new) { guardfile_generator } guardfile_generator.stub(:initialize_template) end it 'displays a deprecation warning to the user' do - ::Guard::UI.should_receive(:deprecation).with(::Guard::Deprecator::INITIALIZE_TEMPLATE_DEPRECATION) + expect(::Guard::UI).to receive(:deprecation).with(::Guard::Deprecator::INITIALIZE_TEMPLATE_DEPRECATION) described_class.initialize_template('rspec') end it 'delegates to Guard::Guardfile::Generator' do - guardfile_generator.should_receive(:initialize_template).with('rspec') + expect(guardfile_generator).to receive(:initialize_template).with('rspec') described_class.initialize_template('rspec') end @@ -40,18 +40,18 @@ describe '.initialize_all_templates' do before do - described_class::Generator.should_receive(:new) { guardfile_generator } + expect(described_class::Generator).to receive(:new) { guardfile_generator } guardfile_generator.stub(:initialize_all_templates) end it 'displays a deprecation warning to the user' do - ::Guard::UI.should_receive(:deprecation).with(::Guard::Deprecator::INITIALIZE_ALL_TEMPLATES_DEPRECATION) + expect(::Guard::UI).to receive(:deprecation).with(::Guard::Deprecator::INITIALIZE_ALL_TEMPLATES_DEPRECATION) described_class.initialize_all_templates end it 'delegates to Guard::Guardfile::Generator' do - guardfile_generator.should_receive(:initialize_all_templates) + expect(guardfile_generator).to receive(:initialize_all_templates) described_class.initialize_all_templates end diff --git a/spec/guard/interactor_spec.rb b/spec/guard/interactor_spec.rb index 99f36c365..7874f6c12 100644 --- a/spec/guard/interactor_spec.rb +++ b/spec/guard/interactor_spec.rb @@ -7,14 +7,14 @@ before { described_class.enabled = nil } it 'returns true by default' do - described_class.enabled.should be_true + expect(described_class.enabled).to be_true end context 'intreactor not enabled' do before { described_class.enabled = false } it 'returns false' do - described_class.enabled.should be_false + expect(described_class.enabled).to be_false end end end @@ -23,14 +23,14 @@ before { described_class.options = nil } it 'returns {} by default' do - described_class.options.should eq({}) + expect(described_class.options).to eq({}) end context 'options set to { foo: :bar }' do before { described_class.options = { foo: :bar } } it 'returns { foo: :bar }' do - described_class.options.should eq({ foo: :bar }) + expect(described_class.options).to eq({ foo: :bar }) end end end @@ -50,36 +50,36 @@ it 'returns a group scope' do scopes, _ = Guard::Interactor.convert_scope %w(backend) - scopes.should eq({ groups: [@backend_group], plugins: [] }) + expect(scopes).to eq({ groups: [@backend_group], plugins: [] }) scopes, _ = Guard::Interactor.convert_scope %w(frontend) - scopes.should eq({ groups: [@frontend_group], plugins: [] }) + expect(scopes).to eq({ groups: [@frontend_group], plugins: [] }) end it 'returns a plugin scope' do scopes, _ = Guard::Interactor.convert_scope %w(foo) - scopes.should eq({ plugins: [@foo_guard], groups: [] }) + expect(scopes).to eq({ plugins: [@foo_guard], groups: [] }) scopes, _ = Guard::Interactor.convert_scope %w(bar) - scopes.should eq({ plugins: [@bar_guard], groups: [] }) + expect(scopes).to eq({ plugins: [@bar_guard], groups: [] }) end it 'returns multiple group scopes' do scopes, _ = Guard::Interactor.convert_scope %w(backend frontend) - scopes.should eq({ groups: [@backend_group, @frontend_group], plugins: [] }) + expect(scopes).to eq({ groups: [@backend_group, @frontend_group], plugins: [] }) end it 'returns multiple plugin scopes' do scopes, _ = Guard::Interactor.convert_scope %w(foo bar) - scopes.should eq({ plugins: [@foo_guard, @bar_guard], groups: [] }) + expect(scopes).to eq({ plugins: [@foo_guard, @bar_guard], groups: [] }) end it 'returns a plugin and group scope' do scopes, _ = Guard::Interactor.convert_scope %w(foo backend) - scopes.should eq({ plugins: [@foo_guard], groups: [@backend_group] }) + expect(scopes).to eq({ plugins: [@foo_guard], groups: [@backend_group] }) end it 'returns the unkown scopes' do _, unkown = Guard::Interactor.convert_scope %w(unkown scope) - unkown.should eq %w(unkown scope) + expect(unkown).to eq %w(unkown scope) end end diff --git a/spec/guard/notifier_spec.rb b/spec/guard/notifier_spec.rb index e634917f2..60ed31b87 100644 --- a/spec/guard/notifier_spec.rb +++ b/spec/guard/notifier_spec.rb @@ -13,7 +13,7 @@ end it 'shows the used notifications' do - Guard::UI.should_receive(:info).with 'Guard is using GNTP to send notifications.' + expect(Guard::UI).to receive(:info).with 'Guard is using GNTP to send notifications.' Guard::Notifier.turn_on end @@ -21,11 +21,11 @@ it 'enables the notifications' do Guard::Notifier.turn_on - Guard::Notifier.should be_enabled + expect(Guard::Notifier).to be_enabled end it 'turns on the defined notification module' do - Guard::Notifier::GNTP.should_receive(:turn_on) + expect(Guard::Notifier::GNTP).to receive(:turn_on) Guard::Notifier.turn_on end @@ -38,37 +38,37 @@ context 'when notifications are globally enabled' do before do - ::Guard.options.should_receive(:notify).and_return true + expect(::Guard.options).to receive(:notify).and_return true end it 'tries to add each available notification silently' do - Guard::Notifier.should_receive(:add_notifier).with(:gntp, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:growl, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:growl_notify, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:terminal_notifier, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:libnotify, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:notifysend, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:notifu, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:emacs, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:terminal_title, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:tmux, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:file, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:gntp, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:growl, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:growl_notify, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:terminal_notifier, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:libnotify, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:notifysend, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:notifu, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:emacs, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:terminal_title, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:tmux, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:file, silent: true).and_return false Guard::Notifier.turn_on end it 'adds only the first notification per group' do - Guard::Notifier.should_receive(:add_notifier).with(:gntp, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:growl, silent: true).and_return false - Guard::Notifier.should_receive(:add_notifier).with(:growl_notify, silent: true).and_return true - Guard::Notifier.should_not_receive(:add_notifier).with(:terminal_notifier, silent: true) - Guard::Notifier.should_not_receive(:add_notifier).with(:libnotify, silent: true) - Guard::Notifier.should_not_receive(:add_notifier).with(:notifysend, silent: true) - Guard::Notifier.should_not_receive(:add_notifier).with(:notifu, silent: true) - Guard::Notifier.should_receive(:add_notifier).with(:emacs, silent: true) - Guard::Notifier.should_receive(:add_notifier).with(:terminal_title, silent: true) - Guard::Notifier.should_receive(:add_notifier).with(:tmux, silent: true) - Guard::Notifier.should_receive(:add_notifier).with(:file, silent: true) + expect(Guard::Notifier).to receive(:add_notifier).with(:gntp, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:growl, silent: true).and_return false + expect(Guard::Notifier).to receive(:add_notifier).with(:growl_notify, silent: true).and_return true + expect(Guard::Notifier).to_not receive(:add_notifier).with(:terminal_notifier, silent: true) + expect(Guard::Notifier).to_not receive(:add_notifier).with(:libnotify, silent: true) + expect(Guard::Notifier).to_not receive(:add_notifier).with(:notifysend, silent: true) + expect(Guard::Notifier).to_not receive(:add_notifier).with(:notifu, silent: true) + expect(Guard::Notifier).to receive(:add_notifier).with(:emacs, silent: true) + expect(Guard::Notifier).to receive(:add_notifier).with(:terminal_title, silent: true) + expect(Guard::Notifier).to receive(:add_notifier).with(:tmux, silent: true) + expect(Guard::Notifier).to receive(:add_notifier).with(:file, silent: true) Guard::Notifier.turn_on end @@ -79,7 +79,7 @@ true end Guard::Notifier.turn_on - Guard::Notifier.should be_enabled + expect(Guard::Notifier).to be_enabled end it 'does turn on the notification module for libraries that are available' do @@ -87,7 +87,7 @@ Guard::Notifier.notifiers = [{ name: :tmux, options: {} }] true end - Guard::Notifier::Tmux.should_receive(:turn_on) + expect(Guard::Notifier::Tmux).to receive(:turn_on) Guard::Notifier.turn_on end @@ -95,19 +95,19 @@ it 'does not enable the notifications when no library is available' do Guard::Notifier.stub(:add_notifier).and_return false Guard::Notifier.turn_on - Guard::Notifier.should_not be_enabled + expect(Guard::Notifier).not_to be_enabled end end context 'when notifications are globally disabled' do before do - ::Guard.options.should_receive(:notify).and_return false + expect(::Guard.options).to receive(:notify).and_return false end it 'does not try to add each available notification silently' do - Guard::Notifier.should_not_receive(:auto_detect_notification) + expect(Guard::Notifier).to_not receive(:auto_detect_notification) Guard::Notifier.turn_on - Guard::Notifier.should_not be_enabled + expect(Guard::Notifier).not_to be_enabled end end end @@ -118,7 +118,7 @@ it 'disables the notifications' do Guard::Notifier.turn_off - ENV['GUARD_NOTIFY'].should eq 'false' + expect(ENV['GUARD_NOTIFY']).to eq 'false' end context 'when turned on with available notifications' do @@ -127,7 +127,7 @@ end it 'turns off each notifier' do - Guard::Notifier::Tmux.should_receive(:turn_off) + expect(Guard::Notifier::Tmux).to receive(:turn_off) Guard::Notifier.turn_off end @@ -139,13 +139,13 @@ it 'disables the notifications when enabled' do ENV['GUARD_NOTIFY'] = 'true' - ::Guard::Notifier.should_receive(:turn_off) + expect(::Guard::Notifier).to receive(:turn_off) subject.toggle end it 'enables the notifications when disabled' do ENV['GUARD_NOTIFY'] = 'false' - ::Guard::Notifier.should_receive(:turn_on) + expect(::Guard::Notifier).to receive(:turn_on) subject.toggle end end @@ -173,37 +173,37 @@ it 'does not add the library' do Guard::Notifier.add_notifier(:unknown) - Guard::Notifier.notifiers.should be_empty + expect(Guard::Notifier.notifiers).to be_empty end end context 'for a notification library with the name :off' do it 'disables the notifier' do ENV['GUARD_NOTIFY'] = 'true' - Guard::Notifier.should be_enabled + expect(Guard::Notifier).to be_enabled Guard::Notifier.add_notifier(:off) - Guard::Notifier.should_not be_enabled + expect(Guard::Notifier).not_to be_enabled end end context 'for a supported notification library' do context 'that is available' do it 'adds the notifier to the notifications' do - Guard::Notifier::GNTP.should_receive(:available?).with(param: 1).and_return(true) + expect(Guard::Notifier::GNTP).to receive(:available?).with(param: 1).and_return(true) Guard::Notifier.add_notifier(:gntp, param: 1) - Guard::Notifier.notifiers.should eq [{ name: :gntp, options: { param: 1 } }] + expect(Guard::Notifier.notifiers).to eq [{ name: :gntp, options: { param: 1 } }] end end context 'that is not available' do it 'does not add the notifier to the notifications' do - Guard::Notifier::GNTP.should_receive(:available?).with(param: 1).and_return(false) + expect(Guard::Notifier::GNTP).to receive(:available?).with(param: 1).and_return(false) Guard::Notifier.add_notifier(:gntp, param: 1) - Guard::Notifier.notifiers.should be_empty + expect(Guard::Notifier.notifiers).to be_empty end end end @@ -216,14 +216,14 @@ before do Guard::Notifier.stub(:enabled?).and_return true - Guard::Notifier::GNTP.should_receive(:new).with({}).and_return(gntp_object) - Guard::Notifier::Growl.should_receive(:new).with({}).and_return(growl_object) + expect(Guard::Notifier::GNTP).to receive(:new).with({}).and_return(gntp_object) + expect(Guard::Notifier::Growl).to receive(:new).with({}).and_return(growl_object) end it 'sends the notification to multiple notifier' do Guard::Notifier.notifiers = [gntp, growl] - gntp_object.should_receive(:notify).with('Hi to everyone', foo: 'bar') - growl_object.should_receive(:notify).with('Hi to everyone', foo: 'bar') + expect(gntp_object).to receive(:notify).with('Hi to everyone', foo: 'bar') + expect(growl_object).to receive(:notify).with('Hi to everyone', foo: 'bar') ::Guard::Notifier.notify('Hi to everyone', foo: 'bar') end @@ -235,8 +235,8 @@ end it 'does not send any notifications to a notifier' do - gntp.should_not_receive(:notify) - growl.should_not_receive(:notify) + expect(gntp).to_not receive(:notify) + expect(growl).to_not receive(:notify) ::Guard::Notifier.notify('Hi to everyone') end diff --git a/spec/guard/notifiers/base_spec.rb b/spec/guard/notifiers/base_spec.rb index 0a1f5fa8c..e19b2ff87 100644 --- a/spec/guard/notifiers/base_spec.rb +++ b/spec/guard/notifiers/base_spec.rb @@ -14,25 +14,25 @@ def self.supported_hosts describe '.name' do it 'un-modulizes the class, replaces "xY" with "x_Y" and downcase' do - Guard::Notifier::FooBar.name.should eq 'foo_bar' + expect(Guard::Notifier::FooBar.name).to eq 'foo_bar' end end describe '#name' do it 'delegates to the class' do - Guard::Notifier::FooBar.new.name.should eq Guard::Notifier::FooBar.name + expect(Guard::Notifier::FooBar.new.name).to eq Guard::Notifier::FooBar.name end end describe '.title' do it 'un-modulize the class' do - Guard::Notifier::FooBar.title.should eq 'FooBar' + expect(Guard::Notifier::FooBar.title).to eq 'FooBar' end end describe '#title' do it 'delegates to the class' do - Guard::Notifier::FooBar.new.title.should eq Guard::Notifier::FooBar.title + expect(Guard::Notifier::FooBar.new.title).to eq Guard::Notifier::FooBar.title end end @@ -43,19 +43,19 @@ def self.supported_hosts it 'returns the Guard title image when no :title is defined' do described_class.new.normalize_standard_options!(opts) - opts[:title].should eq 'Guard' + expect(opts[:title]).to eq 'Guard' end it 'returns the :success type when no :type is defined' do described_class.new.normalize_standard_options!(opts) - opts[:type].should eq :success + expect(opts[:type]).to eq :success end it 'returns the success.png image when no image is defined' do described_class.new.normalize_standard_options!(opts) - opts[:image].should =~ /success.png/ + expect(opts[:image]).to match /success.png/ end end @@ -65,7 +65,7 @@ def self.supported_hosts it 'returns the passed :title' do described_class.new.normalize_standard_options!(opts) - opts[:title].should eq 'Hi' + expect(opts[:title]).to eq 'Hi' end end @@ -75,7 +75,7 @@ def self.supported_hosts it 'returns the passed :type' do described_class.new.normalize_standard_options!(opts) - opts[:type].should eq :foo + expect(opts[:type]).to eq :foo end end @@ -85,7 +85,7 @@ def self.supported_hosts it 'sets the "failed" type for a :failed image' do described_class.new.normalize_standard_options!(opts) - opts[:image].should =~ /failed.png/ + expect(opts[:image]).to match /failed.png/ end end @@ -95,7 +95,7 @@ def self.supported_hosts it 'sets the "pending" type for a :pending image' do described_class.new.normalize_standard_options!(opts) - opts[:image].should =~ /pending.png/ + expect(opts[:image]).to match /pending.png/ end end @@ -105,7 +105,7 @@ def self.supported_hosts it 'sets the "success" type for a :success image' do described_class.new.normalize_standard_options!(opts) - opts[:image].should =~ /success.png/ + expect(opts[:image]).to match /success.png/ end end @@ -115,7 +115,7 @@ def self.supported_hosts it 'sets the "success" type for a :success image' do described_class.new.normalize_standard_options!(opts) - opts[:image].should eq 'foo.png' + expect(opts[:image]).to eq 'foo.png' end end end @@ -123,8 +123,8 @@ def self.supported_hosts describe '.available?' do context 'without the silent option' do it 'shows an error message when not available on the host OS' do - ::Guard::UI.should_receive(:error).with 'The :foo_bar notifier runs only on FreeBSD, Solaris.' - RbConfig::CONFIG.should_receive(:[]).with('host_os').and_return 'mswin' + expect(::Guard::UI).to receive(:error).with 'The :foo_bar notifier runs only on FreeBSD, Solaris.' + expect(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return 'mswin' Guard::Notifier::FooBar.available? end @@ -134,26 +134,26 @@ def self.supported_hosts describe '.require_gem_safely' do context 'library loads normally' do it 'returns true' do - Guard::Notifier::FooBar.should_receive(:require).with('foo_bar') + expect(Guard::Notifier::FooBar).to receive(:require).with('foo_bar') - Guard::Notifier::FooBar.require_gem_safely.should be_true + expect(Guard::Notifier::FooBar.require_gem_safely).to be_true end end context 'library fails to load' do it 'shows an error message when the gem cannot be loaded' do - ::Guard::UI.should_receive(:error).with "Please add \"gem 'foo_bar'\" to your Gemfile and run Guard with \"bundle exec\"." - Guard::Notifier::FooBar.should_receive(:require).with('foo_bar').and_raise LoadError + expect(::Guard::UI).to receive(:error).with "Please add \"gem 'foo_bar'\" to your Gemfile and run Guard with \"bundle exec\"." + expect(Guard::Notifier::FooBar).to receive(:require).with('foo_bar').and_raise LoadError - Guard::Notifier::FooBar.require_gem_safely.should be_false + expect(Guard::Notifier::FooBar.require_gem_safely).to be_false end context 'with the silent option' do it 'does not show an error message when the gem cannot be loaded' do - ::Guard::UI.should_not_receive(:error).with "Please add \"gem 'growl_notify'\" to your Gemfile and run Guard with \"bundle exec\"." - Guard::Notifier::FooBar.should_receive(:require).with('foo_bar').and_raise LoadError + expect(::Guard::UI).to_not receive(:error).with "Please add \"gem 'growl_notify'\" to your Gemfile and run Guard with \"bundle exec\"." + expect(Guard::Notifier::FooBar).to receive(:require).with('foo_bar').and_raise LoadError - Guard::Notifier::FooBar.require_gem_safely(silent: true).should be_false + expect(Guard::Notifier::FooBar.require_gem_safely(silent: true)).to be_false end end end diff --git a/spec/guard/notifiers/emacs_spec.rb b/spec/guard/notifiers/emacs_spec.rb index 1fcee3684..ff7ed10cc 100644 --- a/spec/guard/notifiers/emacs_spec.rb +++ b/spec/guard/notifiers/emacs_spec.rb @@ -7,8 +7,8 @@ context 'when no color options are specified' do it 'should set modeline color to the default color using emacsclient' do notifier.should_receive(:_run_cmd).with do |*command| - command.should include("emacsclient") - command.should include(%{(set-face-attribute 'mode-line nil :background "ForestGreen" :foreground "White")}) + expect(command).to include("emacsclient") + expect(command).to include(%{(set-face-attribute 'mode-line nil :background "ForestGreen" :foreground "White")}) end notifier.notify('any message') @@ -18,8 +18,8 @@ context 'when a color option is specified for "success" notifications' do it 'should set modeline color to the specified color using emacsclient' do notifier.should_receive(:_run_cmd).with do |*command| - command.should include("emacsclient") - command.should include(%{(set-face-attribute 'mode-line nil :background "Orange" :foreground "White")}) + expect(command).to include("emacsclient") + expect(command).to include(%{(set-face-attribute 'mode-line nil :background "Orange" :foreground "White")}) end notifier.notify('any message', success: 'Orange') @@ -29,8 +29,8 @@ context 'when a color option is specified for "pending" notifications' do it 'should set modeline color to the specified color using emacsclient' do notifier.should_receive(:_run_cmd).with do |*command| - command.should include("emacsclient") - command.should include(%{(set-face-attribute 'mode-line nil :background "Yellow" :foreground "White")}) + expect(command).to include("emacsclient") + expect(command).to include(%{(set-face-attribute 'mode-line nil :background "Yellow" :foreground "White")}) end notifier.notify('any message', type: :pending, pending: 'Yellow') diff --git a/spec/guard/notifiers/file_notifier_spec.rb b/spec/guard/notifiers/file_notifier_spec.rb index accba1da3..ccaa1dfe5 100644 --- a/spec/guard/notifiers/file_notifier_spec.rb +++ b/spec/guard/notifiers/file_notifier_spec.rb @@ -5,23 +5,23 @@ describe '.available?' do it 'is true if there is a file in options' do - described_class.should be_available(path: '.guard_result') + expect(described_class).to be_available(path: '.guard_result') end it 'is false if there is no path in options' do - described_class.should_not be_available + expect(described_class).not_to be_available end end describe '.notify' do it 'writes to a file on success' do - File.should_receive(:write).with('tmp/guard_result', "success\nany title\nany message\n") + expect(File).to receive(:write).with('tmp/guard_result', "success\nany title\nany message\n") notifier.notify('any message', title: 'any title', path: 'tmp/guard_result') end it 'also writes to a file on failure' do - File.should_receive(:write).with('tmp/guard_result', "failed\nany title\nany message\n") + expect(File).to receive(:write).with('tmp/guard_result', "failed\nany title\nany message\n") notifier.notify('any message',type: :failed, title: 'any title', path: 'tmp/guard_result') end @@ -29,8 +29,8 @@ # We don't have a way to return false in .available? when no path is # specified. So, we just don't do anything in .notify if there's no path. it 'does not write to a file if no path is specified' do - File.should_not_receive(:write) - ::Guard::UI.should_receive(:error).with ":file notifier requires a :path option" + expect(File).to_not receive(:write) + expect(::Guard::UI).to receive(:error).with ":file notifier requires a :path option" notifier.notify('any message') end diff --git a/spec/guard/notifiers/gntp_spec.rb b/spec/guard/notifiers/gntp_spec.rb index 282e40b5e..0a9f45d79 100644 --- a/spec/guard/notifiers/gntp_spec.rb +++ b/spec/guard/notifiers/gntp_spec.rb @@ -10,18 +10,18 @@ end describe '.supported_hosts' do - it { described_class.supported_hosts.should eq %w[darwin linux freebsd openbsd sunos solaris mswin mingw cygwin] } + it { expect(described_class.supported_hosts).to eq %w[darwin linux freebsd openbsd sunos solaris mswin mingw cygwin] } end describe '.gem_name' do - it { described_class.gem_name.should eq 'ruby_gntp' } + it { expect(described_class.gem_name).to eq 'ruby_gntp' } end describe '.available?' do it 'requires ruby_gntp' do - described_class.should_receive(:require_gem_safely) + expect(described_class).to receive(:require_gem_safely) - described_class.should be_available + expect(described_class).to be_available end end @@ -32,15 +32,15 @@ end it 'creates a new GNTP client and memoize it' do - ::GNTP.should_receive(:new).with('Guard', '127.0.0.1', '', 23053).once.and_return(gntp) + expect(::GNTP).to receive(:new).with('Guard', '127.0.0.1', '', 23053).once.and_return(gntp) notifier.send(:_client, described_class::DEFAULTS.dup) notifier.send(:_client, described_class::DEFAULTS.dup) # 2nd call, memoized end it 'calls #register on the client and memoize it' do - ::GNTP.should_receive(:new).with('Guard', '127.0.0.1', '', 23053).once.and_return(gntp) - gntp.should_receive(:register).once + expect(::GNTP).to receive(:new).with('Guard', '127.0.0.1', '', 23053).once.and_return(gntp) + expect(gntp).to receive(:register).once notifier.send(:_client, described_class::DEFAULTS.dup) notifier.send(:_client, described_class::DEFAULTS.dup) # 2nd call, memoized @@ -53,7 +53,7 @@ context 'without additional options' do it 'shows the notification with the default options' do - gntp.should_receive(:notify).with( + expect(gntp).to receive(:notify).with( sticky: false, name: 'success', title: 'Welcome', @@ -67,7 +67,7 @@ context 'with additional options' do it 'can override the default options' do - gntp.should_receive(:notify).with( + expect(gntp).to receive(:notify).with( sticky: true, name: 'pending', title: 'Waiting', diff --git a/spec/guard/notifiers/growl_notify_spec.rb b/spec/guard/notifiers/growl_notify_spec.rb index e6e01e767..f63ca3bf1 100644 --- a/spec/guard/notifiers/growl_notify_spec.rb +++ b/spec/guard/notifiers/growl_notify_spec.rb @@ -9,7 +9,7 @@ end describe '.supported_hosts' do - it { described_class.supported_hosts.should eq %w[darwin] } + it { expect(described_class.supported_hosts).to eq %w[darwin] } end describe '.available?' do @@ -17,24 +17,24 @@ let(:config) { double('config') } it 'does configure GrowlNotify' do - RbConfig::CONFIG.should_receive(:[]).with('host_os').and_return 'darwin' - ::GrowlNotify.should_receive(:application_name).and_return nil - ::GrowlNotify.should_receive(:config).and_yield config - config.should_receive(:notifications=).with ['success', 'pending', 'failed', 'notify'] - config.should_receive(:default_notifications=).with 'notify' - config.should_receive(:application_name=).with 'Guard' + expect(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return 'darwin' + expect(::GrowlNotify).to receive(:application_name).and_return nil + expect(::GrowlNotify).to receive(:config).and_yield config + expect(config).to receive(:notifications=).with ['success', 'pending', 'failed', 'notify'] + expect(config).to receive(:default_notifications=).with 'notify' + expect(config).to receive(:application_name=).with 'Guard' - described_class.should be_available + expect(described_class).to be_available end end context 'when the application name is Guard' do it 'does not configure GrowlNotify again' do - RbConfig::CONFIG.should_receive(:[]).with('host_os').and_return 'darwin' - ::GrowlNotify.should_receive(:application_name).and_return 'Guard' - ::GrowlNotify.should_not_receive(:config) + expect(RbConfig::CONFIG).to receive(:[]).with('host_os').and_return 'darwin' + expect(::GrowlNotify).to receive(:application_name).and_return 'Guard' + expect(::GrowlNotify).to_not receive(:config) - described_class.should be_available + expect(described_class).to be_available end end end @@ -42,7 +42,7 @@ describe '#notify' do context 'without additional options' do it 'shows the notification with the default options' do - ::GrowlNotify.should_receive(:send_notification).with( + expect(::GrowlNotify).to receive(:send_notification).with( sticky: false, priority: 0, application_name: 'Guard', @@ -58,7 +58,7 @@ context 'with additional options' do it 'can override the default options' do - ::GrowlNotify.should_receive(:send_notification).with( + expect(::GrowlNotify).to receive(:send_notification).with( sticky: true, priority: -2, application_name: 'Guard', diff --git a/spec/guard/notifiers/growl_spec.rb b/spec/guard/notifiers/growl_spec.rb index 8a250a203..8d6c996fb 100644 --- a/spec/guard/notifiers/growl_spec.rb +++ b/spec/guard/notifiers/growl_spec.rb @@ -10,21 +10,21 @@ end describe '.supported_hosts' do - it { described_class.supported_hosts.should eq %w[darwin] } + it { expect(described_class.supported_hosts).to eq %w[darwin] } end describe '.available?' do it 'requires growl' do - described_class.should_receive(:require_gem_safely) + expect(described_class).to receive(:require_gem_safely) - described_class.should be_available + expect(described_class).to be_available end end describe '#notify' do context 'without additional options' do it 'shows the notification with the default options' do - ::Growl.should_receive(:notify).with('Welcome to Guard', + expect(::Growl).to receive(:notify).with('Welcome to Guard', sticky: false, priority: 0, name: 'Guard', @@ -38,7 +38,7 @@ context 'with additional options' do it 'can override the default options' do - ::Growl.should_receive(:notify).with('Waiting for something', + expect(::Growl).to receive(:notify).with('Waiting for something', sticky: true, priority: 2, name: 'Guard', diff --git a/spec/guard/notifiers/libnotify_spec.rb b/spec/guard/notifiers/libnotify_spec.rb index 28ec22b88..8d4fd3eb1 100644 --- a/spec/guard/notifiers/libnotify_spec.rb +++ b/spec/guard/notifiers/libnotify_spec.rb @@ -9,21 +9,21 @@ end describe '.supported_hosts' do - it { described_class.supported_hosts.should eq %w[linux freebsd openbsd sunos solaris] } + it { expect(described_class.supported_hosts).to eq %w[linux freebsd openbsd sunos solaris] } end describe '.available?' do it 'requires libnotify' do - described_class.should_receive(:require_gem_safely) + expect(described_class).to receive(:require_gem_safely) - described_class.should be_available + expect(described_class).to be_available end end describe '#notify' do context 'without additional options' do it 'shows the notification with the default options' do - ::Libnotify.should_receive(:show).with( + expect(::Libnotify).to receive(:show).with( transient: false, append: true, timeout: 3, @@ -39,7 +39,7 @@ context 'with additional options' do it 'can override the default options' do - ::Libnotify.should_receive(:show).with( + expect(::Libnotify).to receive(:show).with( transient: true, append: false, timeout: 5, diff --git a/spec/guard/notifiers/notifysend_spec.rb b/spec/guard/notifiers/notifysend_spec.rb index d52aab4d3..27702488e 100644 --- a/spec/guard/notifiers/notifysend_spec.rb +++ b/spec/guard/notifiers/notifysend_spec.rb @@ -8,14 +8,14 @@ end describe '.supported_hosts' do - it { described_class.supported_hosts.should eq %w[linux freebsd openbsd sunos solaris] } + it { expect(described_class.supported_hosts).to eq %w[linux freebsd openbsd sunos solaris] } end describe '.available?' do it 'checks if the binary is available' do - described_class.should_receive(:_notifysend_binary_available?) + expect(described_class).to receive(:_notifysend_binary_available?) - described_class.should be_available + expect(described_class).to be_available end end @@ -23,11 +23,11 @@ context 'without additional options' do it 'shows the notification with the default options' do notifier.should_receive(:system).with do |command, *arguments| - command.should eql 'notify-send' - arguments.should include '-i', '/tmp/welcome.png' - arguments.should include '-u', 'low' - arguments.should include '-t', '3000' - arguments.should include '-h', 'int:transient:1' + expect(command).to eql 'notify-send' + expect(arguments).to include '-i', '/tmp/welcome.png' + expect(arguments).to include '-u', 'low' + expect(arguments).to include '-t', '3000' + expect(arguments).to include '-h', 'int:transient:1' end notifier.notify('Welcome to Guard', type: 'success', title: 'Welcome', image: '/tmp/welcome.png') @@ -37,10 +37,10 @@ context 'with additional options' do it 'can override the default options' do notifier.should_receive(:system).with do |command, *arguments| - command.should eql 'notify-send' - arguments.should include '-i', '/tmp/wait.png' - arguments.should include '-u', 'critical' - arguments.should include '-t', '5' + expect(command).to eql 'notify-send' + expect(arguments).to include '-i', '/tmp/wait.png' + expect(arguments).to include '-u', 'critical' + expect(arguments).to include '-t', '5' end notifier.notify('Waiting for something', type: :pending, title: 'Waiting', image: '/tmp/wait.png', diff --git a/spec/guard/notifiers/rb_notifu_spec.rb b/spec/guard/notifiers/rb_notifu_spec.rb index f79e60332..ab9c075d0 100644 --- a/spec/guard/notifiers/rb_notifu_spec.rb +++ b/spec/guard/notifiers/rb_notifu_spec.rb @@ -9,25 +9,25 @@ end describe '.supported_hosts' do - it { described_class.supported_hosts.should eq %w[mswin mingw] } + it { expect(described_class.supported_hosts).to eq %w[mswin mingw] } end describe '.gem_name' do - it { described_class.gem_name.should eq 'rb-notifu' } + it { expect(described_class.gem_name).to eq 'rb-notifu' } end describe '.available?' do it 'requires rb-notifu' do - described_class.should_receive(:require_gem_safely) + expect(described_class).to receive(:require_gem_safely) - described_class.should be_available + expect(described_class).to be_available end end describe '#nofify' do context 'without additional options' do it 'shows the notification with the default options' do - ::Notifu.should_receive(:show).with( + expect(::Notifu).to receive(:show).with( time: 3, icon: false, baloon: false, @@ -46,7 +46,7 @@ context 'with additional options' do it 'can override the default options' do - ::Notifu.should_receive(:show).with( + expect(::Notifu).to receive(:show).with( time: 5, icon: true, baloon: true, diff --git a/spec/guard/notifiers/terminal_notifier_spec.rb b/spec/guard/notifiers/terminal_notifier_spec.rb index 443ad72a3..ce0642d93 100644 --- a/spec/guard/notifiers/terminal_notifier_spec.rb +++ b/spec/guard/notifiers/terminal_notifier_spec.rb @@ -9,24 +9,24 @@ end describe '.supported_hosts' do - it { described_class.supported_hosts.should eq %w[darwin ] } + it { expect(described_class.supported_hosts).to eq %w[darwin ] } end describe '.gem_name' do - it { described_class.gem_name.should eq 'terminal-notifier-guard' } + it { expect(described_class.gem_name).to eq 'terminal-notifier-guard' } end describe '.available?' do it 'requires terminal-notifier-guard' do - described_class.should_receive(:require_gem_safely) + expect(described_class).to receive(:require_gem_safely) - described_class.should be_available + expect(described_class).to be_available end end describe '#notify' do it 'should call the notifier.' do - ::TerminalNotifier::Guard.should_receive(:execute).with(false, + expect(::TerminalNotifier::Guard).to receive(:execute).with(false, title: 'any title', type: :success, message: 'any message') @@ -35,7 +35,7 @@ end it "should allow the title to be customized" do - ::TerminalNotifier::Guard.should_receive(:execute).with(false, + expect(::TerminalNotifier::Guard).to receive(:execute).with(false, title: 'any title', message: 'any message', type: :error) @@ -45,7 +45,7 @@ context 'without a title set' do it 'should show the app name in the title' do - ::TerminalNotifier::Guard.should_receive(:execute).with(false, + expect(::TerminalNotifier::Guard).to receive(:execute).with(false, title: 'FooBar Success', type: :success, message: 'any message') diff --git a/spec/guard/notifiers/terminal_title_spec.rb b/spec/guard/notifiers/terminal_title_spec.rb index e635b2f1c..80550c19b 100644 --- a/spec/guard/notifiers/terminal_title_spec.rb +++ b/spec/guard/notifiers/terminal_title_spec.rb @@ -5,13 +5,13 @@ describe '.available?' do it 'returns true' do - described_class.should be_available + expect(described_class).to be_available end end describe '#notify' do it 'set title + first line of message to terminal title' do - notifier.should_receive(:puts).with("\e]2;[any title] first line\a") + expect(notifier).to receive(:puts).with("\e]2;[any title] first line\a") notifier.notify("first line\nsecond line\nthird", title: 'any title') end @@ -19,7 +19,7 @@ describe '.turn_off' do it 'clears the terminal title' do - described_class.should_receive(:puts).with("\e]2;\a") + expect(described_class).to receive(:puts).with("\e]2;\a") described_class.turn_off end diff --git a/spec/guard/notifiers/tmux_spec.rb b/spec/guard/notifiers/tmux_spec.rb index e724fa745..9f837fa0c 100644 --- a/spec/guard/notifiers/tmux_spec.rb +++ b/spec/guard/notifiers/tmux_spec.rb @@ -10,7 +10,7 @@ end it 'returns true' do - described_class.should be_available + expect(described_class).to be_available end end @@ -21,15 +21,15 @@ context 'without the silent option' do it 'shows an error message when the TMUX environment variable is not set' do - ::Guard::UI.should_receive(:error).with 'The :tmux notifier runs only on when Guard is executed inside of a tmux session.' + expect(::Guard::UI).to receive(:error).with 'The :tmux notifier runs only on when Guard is executed inside of a tmux session.' - described_class.should_not be_available + expect(described_class).not_to be_available end end context 'with the silent option' do it 'returns false' do - described_class.should_not be_available(silent: true) + expect(described_class).not_to be_available(silent: true) end end end @@ -37,51 +37,51 @@ describe '#notify' do it 'should set the tmux status bar color to green on success' do - notifier.should_receive(:system).with 'tmux set status-left-bg green' + expect(notifier).to receive(:system).with 'tmux set status-left-bg green' notifier.notify('any message', type: :success) end it 'should set the tmux status bar color to black on success when black is passed in as an option' do - notifier.should_receive(:system).with "tmux set status-left-bg black" + expect(notifier).to receive(:system).with "tmux set status-left-bg black" notifier.notify('any message', type: :success, success: 'black') end it 'should set the tmux status bar color to red on failure' do - notifier.should_receive(:system).with 'tmux set status-left-bg red' + expect(notifier).to receive(:system).with 'tmux set status-left-bg red' notifier.notify('any message', type: :failed) end it 'should set the tmux status bar color to yellow on pending' do - notifier.should_receive(:system).with 'tmux set status-left-bg yellow' + expect(notifier).to receive(:system).with 'tmux set status-left-bg yellow' notifier.notify('any message', type: :pending) end it 'should set the tmux status bar color to green on notify' do - notifier.should_receive(:system).with 'tmux set status-left-bg green' + expect(notifier).to receive(:system).with 'tmux set status-left-bg green' notifier.notify('any message', type: :notify) end it 'should set the right tmux status bar color on success when the right status bar is passed in as an option' do - notifier.should_receive(:system).with 'tmux set status-right-bg green' + expect(notifier).to receive(:system).with 'tmux set status-right-bg green' notifier.notify('any message', color_location: 'status-right-bg') end it 'calls display_message if the display_message flag is set' do notifier.stub system: true - notifier.should_receive(:display_message).with('notify', 'Guard', 'any message', display_message: true) + expect(notifier).to receive(:display_message).with('notify', 'Guard', 'any message', display_message: true) notifier.notify('any message', type: :notify, display_message: true) end it 'does not call display message if the display_message flag is not set' do notifier.stub system: true - notifier.should_receive(:display_message).never + expect(notifier).to receive(:display_message).never notifier.notify('any message') end @@ -93,38 +93,38 @@ end it 'sets the display-time' do - notifier.should_receive(:system).with('tmux set display-time 3000') + expect(notifier).to receive(:system).with('tmux set display-time 3000') notifier.display_message 'success', 'any title', 'any message', timeout: 3 end it 'displays the message' do - notifier.should_receive(:system).with('tmux display-message \'any title - any message\'').once + expect(notifier).to receive(:system).with('tmux display-message \'any title - any message\'').once notifier.display_message 'success', 'any title', 'any message' end it 'handles line-breaks' do - notifier.should_receive(:system).with('tmux display-message \'any title - any message xx line two\'').once + expect(notifier).to receive(:system).with('tmux display-message \'any title - any message xx line two\'').once notifier.display_message 'success', 'any title', "any message\nline two", line_separator: ' xx ' end context 'with success message type options' do it 'formats the message' do - notifier.should_receive(:system).with('tmux display-message \'[any title] => any message - line two\'').once + expect(notifier).to receive(:system).with('tmux display-message \'[any title] => any message - line two\'').once notifier.display_message 'success', 'any title', "any message\nline two", success_message_format: '[%s] => %s', default_message_format: '(%s) -> %s' end it 'sets the foreground color based on the type for success' do - notifier.should_receive(:system).with('tmux set message-fg green') + expect(notifier).to receive(:system).with('tmux set message-fg green') notifier.display_message 'success', 'any title', 'any message', { success_message_color: 'green' } end it 'sets the background color' do - notifier.should_receive(:system).with('tmux set message-bg blue') + expect(notifier).to receive(:system).with('tmux set message-bg blue') notifier.display_message 'success', 'any title', 'any message', { success: :blue } end @@ -132,19 +132,19 @@ context 'with pending message type options' do it 'formats the message' do - notifier.should_receive(:system).with('tmux display-message \'[any title] === any message - line two\'').once + expect(notifier).to receive(:system).with('tmux display-message \'[any title] === any message - line two\'').once notifier.display_message 'pending', 'any title', "any message\nline two", pending_message_format: '[%s] === %s', default_message_format: '(%s) -> %s' end it 'sets the foreground color' do - notifier.should_receive(:system).with('tmux set message-fg blue') + expect(notifier).to receive(:system).with('tmux set message-fg blue') notifier.display_message 'pending', 'any title', 'any message', pending_message_color: 'blue' end it 'sets the background color' do - notifier.should_receive(:system).with('tmux set message-bg white') + expect(notifier).to receive(:system).with('tmux set message-bg white') notifier.display_message 'pending', 'any title', 'any message', pending: :white end @@ -152,18 +152,18 @@ context 'with failed message type options' do it 'formats the message' do - notifier.should_receive(:system).with('tmux display-message \'[any title] <=> any message - line two\'').once + expect(notifier).to receive(:system).with('tmux display-message \'[any title] <=> any message - line two\'').once notifier.display_message 'failed', 'any title', "any message\nline two", failed_message_format: '[%s] <=> %s', default_message_format: '(%s) -> %s' end it 'sets the foreground color' do - notifier.should_receive(:system).with('tmux set message-fg red') + expect(notifier).to receive(:system).with('tmux set message-fg red') notifier.display_message 'failed', 'any title', 'any message', failed_message_color: 'red' end it 'sets the background color' do - notifier.should_receive(:system).with('tmux set message-bg black') + expect(notifier).to receive(:system).with('tmux set message-bg black') notifier.display_message 'failed', 'any title', 'any message', failed: :black end end @@ -177,7 +177,7 @@ end it 'quiets the tmux output' do - notifier.should_receive(:system).with 'tmux set quiet on' + expect(notifier).to receive(:system).with 'tmux set quiet on' notifier.turn_on end @@ -188,13 +188,13 @@ end it 'resets the options store' do - notifier.should_receive(:_reset_options_store) + expect(notifier).to receive(:_reset_options_store) notifier.turn_on end it 'saves the current tmux options' do - notifier.should_receive(:`).with('tmux show') + expect(notifier).to receive(:`).with('tmux show') notifier.turn_on end @@ -206,13 +206,13 @@ end it 'does not reset the options store' do - notifier.should_not_receive(:_reset_options_store) + expect(notifier).to_not receive(:_reset_options_store) notifier.turn_on end it 'does not save the current tmux options' do - notifier.should_not_receive(:`).with('tmux show') + expect(notifier).to_not receive(:`).with('tmux show') notifier.turn_on end @@ -231,26 +231,26 @@ end it 'restores the tmux options' do - notifier.should_receive(:system).with('tmux set option2 setting2') - notifier.should_receive(:system).with('tmux set -u status-left-bg') - notifier.should_receive(:system).with('tmux set option1 setting1') - notifier.should_receive(:system).with('tmux set -u status-right-bg') - notifier.should_receive(:system).with('tmux set -u status-right-fg') - notifier.should_receive(:system).with('tmux set -u status-left-fg') - notifier.should_receive(:system).with('tmux set -u message-fg') - notifier.should_receive(:system).with('tmux set -u message-bg') + expect(notifier).to receive(:system).with('tmux set option2 setting2') + expect(notifier).to receive(:system).with('tmux set -u status-left-bg') + expect(notifier).to receive(:system).with('tmux set option1 setting1') + expect(notifier).to receive(:system).with('tmux set -u status-right-bg') + expect(notifier).to receive(:system).with('tmux set -u status-right-fg') + expect(notifier).to receive(:system).with('tmux set -u status-left-fg') + expect(notifier).to receive(:system).with('tmux set -u message-fg') + expect(notifier).to receive(:system).with('tmux set -u message-bg') notifier.turn_off end it 'resets the options store' do - notifier.should_receive(:_reset_options_store) + expect(notifier).to receive(:_reset_options_store) notifier.turn_off end it 'unquiets the tmux output' do - notifier.should_receive(:system).with 'tmux set quiet off' + expect(notifier).to receive(:system).with 'tmux set quiet off' notifier.turn_off end @@ -262,24 +262,24 @@ end it 'does not restore the tmux options' do - notifier.should_not_receive(:system).with('tmux set -u status-left-bg') - notifier.should_not_receive(:system).with('tmux set -u status-right-bg') - notifier.should_not_receive(:system).with('tmux set -u status-right-fg') - notifier.should_not_receive(:system).with('tmux set -u status-left-fg') - notifier.should_not_receive(:system).with('tmux set -u message-fg') - notifier.should_not_receive(:system).with('tmux set -u message-bg') + expect(notifier).to_not receive(:system).with('tmux set -u status-left-bg') + expect(notifier).to_not receive(:system).with('tmux set -u status-right-bg') + expect(notifier).to_not receive(:system).with('tmux set -u status-right-fg') + expect(notifier).to_not receive(:system).with('tmux set -u status-left-fg') + expect(notifier).to_not receive(:system).with('tmux set -u message-fg') + expect(notifier).to_not receive(:system).with('tmux set -u message-bg') notifier.turn_off end it 'does not reset the options store' do - notifier.should_not_receive(:_reset_options_store) + expect(notifier).to_not receive(:_reset_options_store) notifier.turn_off end it 'unquiets the tmux output' do - notifier.should_receive(:system).with 'tmux set quiet off' + expect(notifier).to receive(:system).with 'tmux set quiet off' notifier.turn_off end diff --git a/spec/guard/options_spec.rb b/spec/guard/options_spec.rb index d11103f6f..106da1b93 100644 --- a/spec/guard/options_spec.rb +++ b/spec/guard/options_spec.rb @@ -6,32 +6,32 @@ it 'behaves as an OpenStruct' do options = described_class.new(plugin: ['foo'], group: ['bar']) - options.plugin.should eq ['foo'] - options.group.should eq ['bar'] + expect(options.plugin).to eq ['foo'] + expect(options.group).to eq ['bar'] end it 'can be passed defaults' do options = described_class.new({}, ::Guard::Setuper::DEFAULT_OPTIONS) - options.clear.should eq false - options.notify.should eq true - options.debug.should eq false - options.group.should eq [] - options.plugin.should eq [] - options.watchdir.should eq nil - options.guardfile.should eq nil - options.no_interactions.should eq false - options.no_bundler_warning.should eq false - options.show_deprecations.should eq false - options.latency.should eq nil - options.force_polling.should eq false + expect(options.clear).to eq false + expect(options.notify).to eq true + expect(options.debug).to eq false + expect(options.group).to eq [] + expect(options.plugin).to eq [] + expect(options.watchdir).to eq nil + expect(options.guardfile).to eq nil + expect(options.no_interactions).to eq false + expect(options.no_bundler_warning).to eq false + expect(options.show_deprecations).to eq false + expect(options.latency).to eq nil + expect(options.force_polling).to eq false end it 'merges the sensible defaults to the given options' do options = described_class.new({ plugin: ['rspec'] }, ::Guard::Setuper::DEFAULT_OPTIONS) - options.plugin.should eq ['rspec'] - options.group.should eq [] + expect(options.plugin).to eq ['rspec'] + expect(options.group).to eq [] end end diff --git a/spec/guard/plugin/base_spec.rb b/spec/guard/plugin/base_spec.rb index c0ce4201a..24b802596 100644 --- a/spec/guard/plugin/base_spec.rb +++ b/spec/guard/plugin/base_spec.rb @@ -8,13 +8,13 @@ describe '.non_namespaced_classname' do it 'remove the Guard:: namespace' do - Guard::DuMmy.non_namespaced_classname.should eq 'DuMmy' + expect(Guard::DuMmy.non_namespaced_classname).to eq 'DuMmy' end end describe '.non_namespaced_name' do it 'remove the Guard:: namespace and downcase' do - Guard::DuMmy.non_namespaced_name.should eq 'dummy' + expect(Guard::DuMmy.non_namespaced_name).to eq 'dummy' end end @@ -24,7 +24,7 @@ end it 'reads the default template' do - File.should_receive(:read).with('/guard-dummy/lib/guard/dummy/templates/Guardfile') { true } + expect(File).to receive(:read).with('/guard-dummy/lib/guard/dummy/templates/Guardfile') { true } Guard::DuMmy.template('/guard-dummy') end @@ -32,19 +32,19 @@ describe '#name' do it 'outputs the short plugin name' do - Guard::DuMmy.new.name.should eq 'dummy' + expect(Guard::DuMmy.new.name).to eq 'dummy' end end describe '#title' do it 'outputs the plugin title' do - Guard::DuMmy.new.title.should eq 'DuMmy' + expect(Guard::DuMmy.new.title).to eq 'DuMmy' end end describe '#to_s' do it 'output the short plugin name' do - Guard::DuMmy.new.to_s.should eq '# @watchers=[] @callbacks=[] @options={}>' + expect(Guard::DuMmy.new.to_s).to eq '# @watchers=[] @callbacks=[] @options={}>' end end diff --git a/spec/guard/plugin/hooker_spec.rb b/spec/guard/plugin/hooker_spec.rb index f5f3fee45..2122439fa 100644 --- a/spec/guard/plugin/hooker_spec.rb +++ b/spec/guard/plugin/hooker_spec.rb @@ -34,51 +34,51 @@ def stop describe '.add_callback' do it 'can add a single callback' do - described_class.has_callback?(listener, dummy1, :start_begin).should be_true + expect(described_class.has_callback?(listener, dummy1, :start_begin)).to be_true end it 'can add multiple callbacks' do described_class.add_callback(listener, dummy1, [:event1, :event2]) - described_class.has_callback?(listener, dummy1, :event1).should be_true - described_class.has_callback?(listener, dummy1, :event2).should be_true + expect(described_class.has_callback?(listener, dummy1, :event1)).to be_true + expect(described_class.has_callback?(listener, dummy1, :event2)).to be_true end end describe '.notify' do it "sends :call to the given Guard class's callbacks" do - listener.should_receive(:call).with(dummy1, :start_begin, 'args') + expect(listener).to receive(:call).with(dummy1, :start_begin, 'args') described_class.notify(dummy1, :start_begin, 'args') end it 'runs only the given callbacks' do listener2 = double('listener2') described_class.add_callback(listener2, dummy1, :start_end) - listener2.should_not_receive(:call).with(dummy1, :start_end) + expect(listener2).to_not receive(:call).with(dummy1, :start_end) described_class.notify(dummy1, :start_begin) end it 'runs callbacks only for the guard given' do described_class.add_callback(listener, dummy2, :start_begin) - listener.should_not_receive(:call).with(dummy2, :start_begin) + expect(listener).to_not receive(:call).with(dummy2, :start_begin) described_class.notify(dummy1, :start_begin) end end describe '#hook' do it 'notifies the hooks' do - described_class.should_receive(:notify).with(dummy1, :run_all_begin) - described_class.should_receive(:notify).with(dummy1, :run_all_end) + expect(described_class).to receive(:notify).with(dummy1, :run_all_begin) + expect(described_class).to receive(:notify).with(dummy1, :run_all_end) dummy1.run_all end it 'passes the hooks name' do - described_class.should_receive(:notify).with(dummy1, :my_hook) + expect(described_class).to receive(:notify).with(dummy1, :my_hook) dummy1.start end it 'accepts extra arguments' do - described_class.should_receive(:notify).with(dummy1, :stop_begin, 'args') - described_class.should_receive(:notify).with(dummy1, :special_sauce, 'first_arg', 'second_arg') + expect(described_class).to receive(:notify).with(dummy1, :stop_begin, 'args') + expect(described_class).to receive(:notify).with(dummy1, :special_sauce, 'first_arg', 'second_arg') dummy1.stop end end diff --git a/spec/guard/plugin_spec.rb b/spec/guard/plugin_spec.rb index 54b4fecf4..f1037174e 100644 --- a/spec/guard/plugin_spec.rb +++ b/spec/guard/plugin_spec.rb @@ -6,23 +6,23 @@ describe '#initialize' do it 'assigns the defined watchers' do watchers = [Guard::Watcher.new('*')] - Guard::Plugin.new(watchers: watchers).watchers.should eq watchers + expect(Guard::Plugin.new(watchers: watchers).watchers).to eq watchers end it 'assigns the defined options' do options = { a: 1, b: 2 } - Guard::Plugin.new(options).options.should eq options + expect(Guard::Plugin.new(options).options).to eq options end context 'with a group in the options' do it 'assigns the given group' do - Guard::Plugin.new(group: :test).group.should eq Guard.group(:test) + expect(Guard::Plugin.new(group: :test).group).to eq Guard.group(:test) end end context 'without a group in the options' do it 'assigns a default group' do - Guard::Plugin.new.group.should eq Guard.group(:default) + expect(Guard::Plugin.new.group).to eq Guard.group(:default) end end end diff --git a/spec/guard/plugin_util_spec.rb b/spec/guard/plugin_util_spec.rb index 45c74b69e..6f7db3358 100644 --- a/spec/guard/plugin_util_spec.rb +++ b/spec/guard/plugin_util_spec.rb @@ -17,22 +17,22 @@ describe '.plugin_names' do context 'Rubygems < 1.8.0' do before do - Gem::Version.should_receive(:create).with(Gem::VERSION) { rubygems_version_1_7_2 } - Gem::Version.should_receive(:create).with('1.8.0') { rubygems_version_1_8_0 } + expect(Gem::Version).to receive(:create).with(Gem::VERSION) { rubygems_version_1_7_2 } + expect(Gem::Version).to receive(:create).with('1.8.0') { rubygems_version_1_8_0 } gems_source_index = double - Gem.should_receive(:source_index) { gems_source_index } - gems_source_index.should_receive(:find_name).with(/^guard-/) { [double(name: 'guard-rspec'), double(name: 'guard-rspec')] } + expect(Gem).to receive(:source_index) { gems_source_index } + expect(gems_source_index).to receive(:find_name).with(/^guard-/) { [double(name: 'guard-rspec'), double(name: 'guard-rspec')] } end it 'returns the list of guard gems' do - described_class.plugin_names.should eq ['rspec'] + expect(described_class.plugin_names).to eq ['rspec'] end end context 'Rubygems >= 1.8.0' do before do - Gem::Version.should_receive(:create).with(Gem::VERSION) { rubygems_version_1_8_0 } - Gem::Version.should_receive(:create).with('1.8.0') { rubygems_version_1_8_0 } + expect(Gem::Version).to receive(:create).with(Gem::VERSION) { rubygems_version_1_8_0 } + expect(Gem::Version).to receive(:create).with('1.8.0') { rubygems_version_1_8_0 } gems = [ double(name: 'guard'), double(name: 'guard-rspec'), @@ -41,26 +41,26 @@ ] File.stub(:exists?).with('/gem1/lib/guard/gem1.rb') { false } File.stub(:exists?).with('/gem2/lib/guard/gem2.rb') { true } - Gem::Specification.should_receive(:find_all) { gems } + expect(Gem::Specification).to receive(:find_all) { gems } end it "returns the list of guard gems" do - described_class.plugin_names.should include('rspec') + expect(described_class.plugin_names).to include('rspec') end it "returns the list of embedded guard gems" do - described_class.plugin_names.should include('gem2') + expect(described_class.plugin_names).to include('gem2') end end end describe '#initialize' do it 'accepts a name without guard-' do - described_class.new('rspec').name.should eq 'rspec' + expect(described_class.new('rspec').name).to eq 'rspec' end it 'accepts a name with guard-' do - described_class.new('guard-rspec').name.should eq 'rspec' + expect(described_class.new('guard-rspec').name).to eq 'rspec' end end @@ -72,22 +72,22 @@ end context 'with a plugin inheriting from Guard::Guard (deprecated)' do - before { guard_rspec_class.should_receive(:superclass) { ::Guard::Guard } } + before { expect(guard_rspec_class).to receive(:superclass) { ::Guard::Guard } } it 'instantiate the plugin using the old API' do - guard_rspec_class.should_receive(:new).with(['watcher'], group: 'foo').and_return(guard_rspec) + expect(guard_rspec_class).to receive(:new).with(['watcher'], group: 'foo').and_return(guard_rspec) - plugin_util.initialize_plugin(watchers: ['watcher'], group: 'foo').should eq guard_rspec + expect(plugin_util.initialize_plugin(watchers: ['watcher'], group: 'foo')).to eq guard_rspec end end context 'with a plugin inheriting from Guard::Plugin' do - before { guard_rspec_class.should_receive(:superclass) { ::Guard::Plugin } } + before { expect(guard_rspec_class).to receive(:superclass) { ::Guard::Plugin } } it 'instantiate the plugin using the new API' do - guard_rspec_class.should_receive(:new).with(watchers: ['watcher'], group: 'foo').and_return(guard_rspec) + expect(guard_rspec_class).to receive(:new).with(watchers: ['watcher'], group: 'foo').and_return(guard_rspec) - plugin_util.initialize_plugin(watchers: ['watcher'], group: 'foo').should eq guard_rspec + expect(plugin_util.initialize_plugin(watchers: ['watcher'], group: 'foo')).to eq guard_rspec end end end @@ -95,30 +95,30 @@ describe '#plugin_location' do context 'Rubygems < 1.8.0' do before do - Gem::Version.should_receive(:create).with(Gem::VERSION) { rubygems_version_1_7_2 } - Gem::Version.should_receive(:create).with('1.8.0') { rubygems_version_1_8_0 } + expect(Gem::Version).to receive(:create).with(Gem::VERSION) { rubygems_version_1_7_2 } + expect(Gem::Version).to receive(:create).with('1.8.0') { rubygems_version_1_8_0 } end it "returns the path of a Guard gem" do gems_source_index = double gems_found = [double(full_gem_path: 'gems/guard-rspec')] - Gem.should_receive(:source_index) { gems_source_index } - gems_source_index.should_receive(:find_name).with('guard-rspec') { gems_found } + expect(Gem).to receive(:source_index) { gems_source_index } + expect(gems_source_index).to receive(:find_name).with('guard-rspec') { gems_found } - described_class.new('rspec').plugin_location.should eq 'gems/guard-rspec' + expect(described_class.new('rspec').plugin_location).to eq 'gems/guard-rspec' end end context 'Rubygems >= 1.8.0' do before do - Gem::Version.should_receive(:create).with(Gem::VERSION) { rubygems_version_1_8_0 } - Gem::Version.should_receive(:create).with('1.8.0') { rubygems_version_1_8_0 } + expect(Gem::Version).to receive(:create).with(Gem::VERSION) { rubygems_version_1_8_0 } + expect(Gem::Version).to receive(:create).with('1.8.0') { rubygems_version_1_8_0 } end it "returns the path of a Guard gem" do - Gem::Specification.should_receive(:find_by_name).with('guard-rspec') { double(full_gem_path: 'gems/guard-rspec') } + expect(Gem::Specification).to receive(:find_by_name).with('guard-rspec') { double(full_gem_path: 'gems/guard-rspec') } - described_class.new('rspec').plugin_location.should eq 'gems/guard-rspec' + expect(described_class.new('rspec').plugin_location).to eq 'gems/guard-rspec' end end end @@ -131,65 +131,65 @@ end it "reports an error if the class is not found" do - ::Guard::UI.should_receive(:error).twice + expect(::Guard::UI).to receive(:error).twice described_class.new('notAGuardClass').plugin_class end context 'with a nested Guard class' do it "resolves the Guard class from string" do plugin = described_class.new('classname') - plugin.should_receive(:require) do |classname| - classname.should eq 'guard/classname' + expect(plugin).to receive(:require) do |classname| + expect(classname).to eq 'guard/classname' class Guard::Classname; end end - plugin.plugin_class.should eq Guard::Classname + expect(plugin.plugin_class).to eq Guard::Classname end it "resolves the Guard class from symbol" do plugin = described_class.new(:classname) - plugin.should_receive(:require) do |classname| - classname.should eq 'guard/classname' + expect(plugin).to receive(:require) do |classname| + expect(classname).to eq 'guard/classname' class Guard::Classname; end end - plugin.plugin_class.should eq Guard::Classname + expect(plugin.plugin_class).to eq Guard::Classname end end context 'with a name with dashes' do it "returns the Guard class" do plugin = described_class.new('dashed-class-name') - plugin.should_receive(:require) do |classname| - classname.should eq 'guard/dashed-class-name' + expect(plugin).to receive(:require) do |classname| + expect(classname).to eq 'guard/dashed-class-name' class Guard::DashedClassName; end end - plugin.plugin_class.should eq Guard::DashedClassName + expect(plugin.plugin_class).to eq Guard::DashedClassName end end context 'with a name with underscores' do it "returns the Guard class" do plugin = described_class.new('underscore_class_name') - plugin.should_receive(:require) do |classname| - classname.should eq 'guard/underscore_class_name' + expect(plugin).to receive(:require) do |classname| + expect(classname).to eq 'guard/underscore_class_name' class Guard::UnderscoreClassName; end end - plugin.plugin_class.should eq Guard::UnderscoreClassName + expect(plugin.plugin_class).to eq Guard::UnderscoreClassName end end context 'with a name where its class does not follow the strict case rules' do it "returns the Guard class" do plugin = described_class.new('vspec') - plugin.should_receive(:require) do |classname| - classname.should eq 'guard/vspec' + expect(plugin).to receive(:require) do |classname| + expect(classname).to eq 'guard/vspec' class Guard::VSpec; end end - plugin.plugin_class.should eq Guard::VSpec + expect(plugin.plugin_class).to eq Guard::VSpec end end @@ -201,15 +201,15 @@ class Inline < Guard end end - plugin.should_not_receive(:require) - plugin.plugin_class.should eq Guard::Inline + expect(plugin).to_not receive(:require) + expect(plugin.plugin_class).to eq Guard::Inline end end context 'when set to fail gracefully' do it 'does not print error messages on fail' do - ::Guard::UI.should_not_receive(:error) - described_class.new('notAGuardClass').plugin_class(fail_gracefully: true).should be_nil + expect(::Guard::UI).to_not receive(:error) + expect(described_class.new('notAGuardClass').plugin_class(fail_gracefully: true)).to be_nil end end end @@ -225,7 +225,7 @@ class Inline < Guard end it 'shows an info message' do - ::Guard::UI.should_receive(:info).with 'Guardfile already includes myguard guard' + expect(::Guard::UI).to receive(:info).with 'Guardfile already includes myguard guard' described_class.new('myguard').add_to_guardfile end @@ -236,19 +236,19 @@ class Inline < Guard before do stub_const 'Guard::Myguard', Class.new(Guard::Plugin) plugin_util.stub(:plugin_class) { Guard::Myguard } - plugin_util.should_receive(:plugin_location) { '/Users/me/projects/guard-myguard' } + expect(plugin_util).to receive(:plugin_location) { '/Users/me/projects/guard-myguard' } guardfile_evaluator.stub(:guardfile_include?).and_return(false) end it 'appends the template to the Guardfile' do - File.should_receive(:read).with('Guardfile') { 'Guardfile content' } - File.should_receive(:read).with('/Users/me/projects/guard-myguard/lib/guard/myguard/templates/Guardfile') { 'Template content' } + expect(File).to receive(:read).with('Guardfile') { 'Guardfile content' } + expect(File).to receive(:read).with('/Users/me/projects/guard-myguard/lib/guard/myguard/templates/Guardfile') { 'Template content' } io = StringIO.new - File.should_receive(:open).with('Guardfile', 'wb').and_yield io + expect(File).to receive(:open).with('Guardfile', 'wb').and_yield io plugin_util.add_to_guardfile - io.string.should eq "Guardfile content\n\nTemplate content\n" + expect(io.string).to eq "Guardfile content\n\nTemplate content\n" end end end diff --git a/spec/guard/runner_spec.rb b/spec/guard/runner_spec.rb index ff0f835d4..632ebfcd6 100644 --- a/spec/guard/runner_spec.rb +++ b/spec/guard/runner_spec.rb @@ -26,13 +26,13 @@ describe '#run' do it 'executes a supervised task on all registered plugins implementing that task' do [@foo_guard, @bar_guard].each do |plugin| - subject.should_receive(:run_supervised_task).with(plugin, :my_hard_task) + expect(subject).to receive(:run_supervised_task).with(plugin, :my_hard_task) end subject.run(:my_hard_task) end it 'marks an action as unit of work' do - Lumberjack.should_receive(:unit_of_work) + expect(Lumberjack).to receive(:unit_of_work) subject.run(:my_task) end @@ -51,10 +51,10 @@ let(:scope) { { plugin: :bar } } it 'executes the supervised task on the specified plugin only' do - subject.should_receive(:run_supervised_task).with(@bar_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@bar_guard, :my_task) - subject.should_not_receive(:run_supervised_task).with(@foo_guard, :my_task) - subject.should_not_receive(:run_supervised_task).with(@baz_guard, :my_task) + expect(subject).to_not receive(:run_supervised_task).with(@foo_guard, :my_task) + expect(subject).to_not receive(:run_supervised_task).with(@baz_guard, :my_task) subject.run(:my_task, scope) end @@ -64,10 +64,10 @@ let(:scope) { { plugin: @bar_guard } } it 'executes the supervised task on the specified plugin only' do - subject.should_receive(:run_supervised_task).with(@bar_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@bar_guard, :my_task) - subject.should_not_receive(:run_supervised_task).with(@foo_guard, :my_task) - subject.should_not_receive(:run_supervised_task).with(@baz_guard, :my_task) + expect(subject).to_not receive(:run_supervised_task).with(@foo_guard, :my_task) + expect(subject).to_not receive(:run_supervised_task).with(@baz_guard, :my_task) subject.run(:my_task, scope) end @@ -80,10 +80,10 @@ it 'executes the supervised task on the specified plugins only' do @bar_guard.stub(:my_task) - subject.should_receive(:run_supervised_task).with(@foo_guard, :my_task) - subject.should_receive(:run_supervised_task).with(@bar_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@foo_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@bar_guard, :my_task) - subject.should_not_receive(:run_supervised_task).with(@baz_guard, :my_task) + expect(subject).to_not receive(:run_supervised_task).with(@baz_guard, :my_task) subject.run(:my_task, scope) end @@ -93,10 +93,10 @@ let(:scope) { { plugins: [@foo_guard, @bar_guard] } } it 'executes the supervised task on the specified plugins only' do - subject.should_receive(:run_supervised_task).with(@foo_guard, :my_task) - subject.should_receive(:run_supervised_task).with(@bar_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@foo_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@bar_guard, :my_task) - subject.should_not_receive(:run_supervised_task).with(@baz_guard, :my_task) + expect(subject).to_not receive(:run_supervised_task).with(@baz_guard, :my_task) subject.run(:my_task, scope) end @@ -108,10 +108,10 @@ let(:scope) { { group: :frontend } } it 'executes the supervised task on the specified plugin only' do - subject.should_receive(:run_supervised_task).with(@bar_guard, :my_task) - subject.should_receive(:run_supervised_task).with(@baz_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@bar_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@baz_guard, :my_task) - subject.should_not_receive(:run_supervised_task).with(@foo_guard, :my_task) + expect(subject).to_not receive(:run_supervised_task).with(@foo_guard, :my_task) subject.run(:my_task, scope) end @@ -121,10 +121,10 @@ let(:scope) { { group: @frontend_group } } it 'executes the supervised task on the specified plugin only' do - subject.should_receive(:run_supervised_task).with(@bar_guard, :my_task) - subject.should_receive(:run_supervised_task).with(@baz_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@bar_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@baz_guard, :my_task) - subject.should_not_receive(:run_supervised_task).with(@foo_guard, :my_task) + expect(subject).to_not receive(:run_supervised_task).with(@foo_guard, :my_task) subject.run(:my_task, scope) end @@ -136,9 +136,9 @@ let(:scope) { { groups: [:frontend, :backend] } } it 'executes the supervised task on the specified plugins only' do - subject.should_receive(:run_supervised_task).with(@foo_guard, :my_task) - subject.should_receive(:run_supervised_task).with(@bar_guard, :my_task) - subject.should_receive(:run_supervised_task).with(@baz_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@foo_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@bar_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@baz_guard, :my_task) subject.run(:my_task, scope) end @@ -148,9 +148,9 @@ let(:scope) { { groups: [@frontend_group, @backend_group] } } it 'executes the supervised task on the specified plugins only' do - subject.should_receive(:run_supervised_task).with(@foo_guard, :my_task) - subject.should_receive(:run_supervised_task).with(@bar_guard, :my_task) - subject.should_receive(:run_supervised_task).with(@baz_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@foo_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@bar_guard, :my_task) + expect(subject).to receive(:run_supervised_task).with(@baz_guard, :my_task) subject.run(:my_task, scope) end @@ -169,7 +169,7 @@ end it "always calls UI.clearable" do - Guard::UI.should_receive(:clearable) + expect(Guard::UI).to receive(:clearable) subject.run_on_changes(*changes) end @@ -177,7 +177,7 @@ before { subject.stub(:_clearable?) { true } } it "clear UI" do - Guard::UI.should_receive(:clear) + expect(Guard::UI).to receive(:clear) subject.run_on_changes(*changes) end end @@ -185,7 +185,7 @@ context 'with no changes' do it 'does not run any task' do %w[run_on_modifications run_on_change run_on_additions run_on_removals run_on_deletion].each do |task| - @foo_guard.should_not_receive(task.to_sym) + expect(@foo_guard).to_not receive(task.to_sym) end subject.run_on_changes(*changes) end @@ -196,11 +196,11 @@ before do changes[0] = modified - watcher_module.should_receive(:match_files).once.with(@foo_guard, modified).and_return([]) + expect(watcher_module).to receive(:match_files).once.with(@foo_guard, modified).and_return([]) end it 'does not call run_first_task_found' do - subject.should_not_receive(:_run_first_task_found) + expect(subject).to_not receive(:_run_first_task_found) subject.run_on_changes(*changes) end end @@ -210,11 +210,11 @@ before do changes[0] = modified - watcher_module.should_receive(:match_files).with(@foo_guard, modified).and_return(modified) + expect(watcher_module).to receive(:match_files).with(@foo_guard, modified).and_return(modified) end it 'executes the :run_first_task_found task' do - subject.should_receive(:_run_first_task_found).with(@foo_guard, [:run_on_modifications, :run_on_changes, :run_on_change], modified) + expect(subject).to receive(:_run_first_task_found).with(@foo_guard, [:run_on_modifications, :run_on_changes, :run_on_change], modified) subject.run_on_changes(*changes) end end @@ -224,11 +224,11 @@ before do changes[0] = added - watcher_module.should_receive(:match_files).once.with(@foo_guard, added).and_return([]) + expect(watcher_module).to receive(:match_files).once.with(@foo_guard, added).and_return([]) end it 'does not call run_first_task_found' do - subject.should_not_receive(:_run_first_task_found) + expect(subject).to_not receive(:_run_first_task_found) subject.run_on_changes(*changes) end end @@ -238,11 +238,11 @@ before do changes[1] = added - watcher_module.should_receive(:match_files).with(@foo_guard, added).and_return(added) + expect(watcher_module).to receive(:match_files).with(@foo_guard, added).and_return(added) end it 'executes the :run_on_additions task' do - subject.should_receive(:_run_first_task_found).with(@foo_guard, [:run_on_additions, :run_on_changes, :run_on_change], added) + expect(subject).to receive(:_run_first_task_found).with(@foo_guard, [:run_on_additions, :run_on_changes, :run_on_change], added) subject.run_on_changes(*changes) end end @@ -252,11 +252,11 @@ before do changes[0] = removed - watcher_module.should_receive(:match_files).once.with(@foo_guard, removed).and_return([]) + expect(watcher_module).to receive(:match_files).once.with(@foo_guard, removed).and_return([]) end it 'does not call run_first_task_found' do - subject.should_not_receive(:_run_first_task_found) + expect(subject).to_not receive(:_run_first_task_found) subject.run_on_changes(*changes) end end @@ -266,11 +266,11 @@ before do changes[2] = removed - watcher_module.should_receive(:match_files).with(@foo_guard, removed).and_return(removed) + expect(watcher_module).to receive(:match_files).with(@foo_guard, removed).and_return(removed) end it 'executes the :run_on_removals task' do - subject.should_receive(:_run_first_task_found).with(@foo_guard, [:run_on_removals, :run_on_changes, :run_on_deletion], removed) + expect(subject).to receive(:_run_first_task_found).with(@foo_guard, [:run_on_removals, :run_on_changes, :run_on_deletion], removed) subject.run_on_changes(*changes) end end @@ -278,7 +278,7 @@ describe '#run_supervised_task' do it 'executes the task on the passed guard' do - @foo_guard.should_receive(:my_task) + expect(@foo_guard).to receive(:my_task) subject.run_supervised_task(@foo_guard, :my_task) end @@ -295,17 +295,17 @@ end it 'returns the result of the task' do - subject.run_supervised_task(@foo_guard, :regular_without_arg).should be_true + expect(subject.run_supervised_task(@foo_guard, :regular_without_arg)).to be_true end it 'passes the args to the :begin hook' do - @foo_guard.should_receive(:hook).with('regular_without_arg_begin', 'given_path') + expect(@foo_guard).to receive(:hook).with('regular_without_arg_begin', 'given_path') subject.run_supervised_task(@foo_guard, :regular_without_arg, 'given_path') end it 'passes the result of the supervised method to the :end hook' do - @foo_guard.should_receive(:hook).with('regular_without_arg_begin', 'given_path') - @foo_guard.should_receive(:hook).with('regular_without_arg_end', true) + expect(@foo_guard).to receive(:hook).with('regular_without_arg_begin', 'given_path') + expect(@foo_guard).to receive(:hook).with('regular_without_arg_end', true) subject.run_supervised_task(@foo_guard, :regular_without_arg, 'given_path') end end @@ -322,12 +322,12 @@ end it 'returns the result of the task' do - subject.run_supervised_task(@foo_guard, :regular_with_arg, "given_path").should eq "I'm a success" + expect(subject.run_supervised_task(@foo_guard, :regular_with_arg, "given_path")).to eq "I'm a success" end it 'calls the default begin hook but not the default end hook' do - @foo_guard.should_receive(:hook).with('failing_begin') - @foo_guard.should_not_receive(:hook).with('failing_end') + expect(@foo_guard).to receive(:hook).with('failing_begin') + expect(@foo_guard).to_not receive(:hook).with('failing_end') subject.run_supervised_task(@foo_guard, :failing) end end @@ -365,20 +365,20 @@ subject.run_supervised_task(@foo_guard, :failing) }.to change(::Guard.plugins, :size).by(-1) - ::Guard.plugins.should_not include(@foo_guard) + expect(::Guard.plugins).not_to include(@foo_guard) end it 'display an error to the user' do - ::Guard::UI.should_receive :error - ::Guard::UI.should_receive :info + expect(::Guard::UI).to receive :error + expect(::Guard::UI).to receive :info subject.run_supervised_task(@foo_guard, :failing) end it 'returns the exception' do failing_result = subject.run_supervised_task(@foo_guard, :failing) - failing_result.should be_kind_of(Exception) - failing_result.message.should eq 'I break your system' + expect(failing_result).to be_kind_of(Exception) + expect(failing_result.message).to eq 'I break your system' end end end @@ -392,7 +392,7 @@ end it 'returns :no_catch' do - described_class.stopping_symbol_for(guard_plugin).should eq :no_catch + expect(described_class.stopping_symbol_for(guard_plugin)).to eq :no_catch end end @@ -402,7 +402,7 @@ end it 'returns :task_has_failed' do - described_class.stopping_symbol_for(guard_plugin).should eq :task_has_failed + expect(described_class.stopping_symbol_for(guard_plugin)).to eq :task_has_failed end end end diff --git a/spec/guard/setuper_spec.rb b/spec/guard/setuper_spec.rb index c064d54e0..423aeb9f3 100644 --- a/spec/guard/setuper_spec.rb +++ b/spec/guard/setuper_spec.rb @@ -16,72 +16,72 @@ subject { Guard.setup(options) } it "returns itself for chaining" do - subject.should be Guard + expect(subject).to be Guard end it "initializes the plugins" do - subject.plugins.should eq [] + expect(subject.plugins).to eq [] end it "initializes the groups" do - subject.groups[0].name.should eq :default - subject.groups[0].options.should eq({}) + expect(subject.groups[0].name).to eq :default + expect(subject.groups[0].options).to eq({}) end it "initializes the options" do - subject.options.my_opts.should be_true + expect(subject.options.my_opts).to be_true end it "initializes the listener" do - subject.listener.should be_kind_of(Listen::Listener) + expect(subject.listener).to be_kind_of(Listen::Listener) end it "respect the watchdir option" do Guard.setup(watchdir: '/usr') - Guard.listener.directories.should eq [Pathname.new('/usr')] + expect(Guard.listener.directories).to eq [Pathname.new('/usr')] end it "respect the watchdir option with multiple directories" do ::Guard.setup(watchdir: ['/usr', '/bin']) - ::Guard.listener.directories.should eq [Pathname.new('/usr'), Pathname.new('/bin')] + expect(::Guard.listener.directories).to eq [Pathname.new('/usr'), Pathname.new('/bin')] end it 'call setup_signal_traps' do - Guard.should_receive(:_setup_signal_traps) + expect(Guard).to receive(:_setup_signal_traps) subject end it 'create the evaluator and evaluate the Guardfile' do - Guard::Guardfile::Evaluator.should_receive(:new).with(options) - Guard.should_receive(:evaluate_guardfile) + expect(Guard::Guardfile::Evaluator).to receive(:new).with(options) + expect(Guard).to receive(:evaluate_guardfile) subject end it 'displays an error message when no guard are defined in Guardfile' do - Guard::UI.should_receive(:error).with('No plugins found in Guardfile, please add at least one.') + expect(Guard::UI).to receive(:error).with('No plugins found in Guardfile, please add at least one.') subject end it 'call setup_notifier' do - Guard.should_receive(:_setup_notifier) + expect(Guard).to receive(:_setup_notifier) subject end it 'call setup_interactor' do - Guard.should_receive(:_setup_interactor) + expect(Guard).to receive(:_setup_interactor) subject end context 'without the group or plugin option' do it "initializes the empty scope" do - subject.scope.should eq({ groups: [], plugins: [] }) + expect(subject.scope).to eq({ groups: [], plugins: [] }) end end @@ -92,10 +92,10 @@ } } it 'initializes the group scope' do - subject.scope[:plugins].should be_empty - subject.scope[:groups].count.should be 2 - subject.scope[:groups][0].name.should eq :backend - subject.scope[:groups][1].name.should eq :frontend + expect(subject.scope[:plugins]).to be_empty + expect(subject.scope[:groups].count).to be 2 + expect(subject.scope[:groups][0].name).to eq :backend + expect(subject.scope[:groups][1].name).to eq :frontend end end @@ -114,10 +114,10 @@ end it 'initializes the plugin scope' do - subject.scope[:groups].should be_empty - subject.scope[:plugins].count.should be 2 - subject.scope[:plugins][0].class.should eq ::Guard::Cucumber - subject.scope[:plugins][1].class.should eq ::Guard::Jasmine + expect(subject.scope[:groups]).to be_empty + expect(subject.scope[:plugins].count).to be 2 + expect(subject.scope[:plugins][0].class).to eq ::Guard::Cucumber + expect(subject.scope[:plugins][1].class).to eq ::Guard::Jasmine end end @@ -130,13 +130,13 @@ end it "logs command execution if the debug option is true" do - ::Guard.should_receive(:_debug_command_execution) + expect(::Guard).to receive(:_debug_command_execution) subject end it "sets the log level to :debug if the debug option is true" do subject - ::Guard::UI.options.level.should eq :debug + expect(::Guard::UI.options.level).to eq :debug end end end @@ -152,9 +152,9 @@ it "initializes a default group" do subject.reset_groups - subject.groups.should have(1).item - subject.groups[0].name.should eq :default - subject.groups[0].options.should eq({}) + expect(subject.groups).to have(1).item + expect(subject.groups[0].name).to eq :default + expect(subject.groups[0].options).to eq({}) end end @@ -172,18 +172,18 @@ class Guard::FooBar < Guard::Plugin; end end it "return clear the plugins array" do - subject.plugins.should have(1).item + expect(subject.plugins).to have(1).item subject.reset_plugins - subject.plugins.should be_empty + expect(subject.plugins).to be_empty end end describe '.evaluate_guardfile' do it 'evaluates the Guardfile' do Guard.stub(:evaluator) { guardfile_evaluator } - guardfile_evaluator.should_receive(:evaluate_guardfile) + expect(guardfile_evaluator).to receive(:evaluate_guardfile) Guard.evaluate_guardfile end @@ -198,20 +198,20 @@ class Guard::FooBar < Guard::Plugin; end unless windows? || defined?(JRUBY_VERSION) context 'when receiving SIGUSR1' do context 'when Guard is running' do - before { ::Guard.listener.should_receive(:paused?).and_return false } + before { expect(::Guard.listener).to receive(:paused?).and_return false } it 'pauses Guard' do - ::Guard.should_receive(:pause) + expect(::Guard).to receive(:pause) Process.kill :USR1, Process.pid sleep 1 end end context 'when Guard is already paused' do - before { ::Guard.listener.should_receive(:paused?).and_return true } + before { expect(::Guard.listener).to receive(:paused?).and_return true } it 'does not pauses Guard' do - ::Guard.should_not_receive(:pause) + expect(::Guard).to_not receive(:pause) Process.kill :USR1, Process.pid sleep 1 end @@ -220,20 +220,20 @@ class Guard::FooBar < Guard::Plugin; end context 'when receiving SIGUSR2' do context 'when Guard is paused' do - before { Guard.listener.should_receive(:paused?).and_return true } + before { expect(Guard.listener).to receive(:paused?).and_return true } it 'un-pause Guard' do - Guard.should_receive(:pause) + expect(Guard).to receive(:pause) Process.kill :USR2, Process.pid sleep 1 end end context 'when Guard is already running' do - before { ::Guard.listener.should_receive(:paused?).and_return false } + before { expect(::Guard.listener).to receive(:paused?).and_return false } it 'does not un-pause Guard' do - ::Guard.should_not_receive(:pause) + expect(::Guard).to_not receive(:pause) Process.kill :USR2, Process.pid sleep 1 end @@ -242,10 +242,10 @@ class Guard::FooBar < Guard::Plugin; end context 'when receiving SIGINT' do context 'without an interactor' do - before { Guard.should_receive(:interactor).and_return nil } + before { expect(Guard).to receive(:interactor).and_return nil } it 'stops Guard' do - Guard.should_receive(:stop) + expect(Guard).to receive(:stop) Process.kill :INT, Process.pid sleep 1 end @@ -256,7 +256,7 @@ class Guard::FooBar < Guard::Plugin; end before { allow(Guard).to receive(:interactor).and_return(interactor) } it 'delegates to the Pry thread' do - Guard.interactor.thread.should_receive(:raise).with Interrupt + expect(Guard.interactor.thread).to receive(:raise).with Interrupt Process.kill :INT, Process.pid sleep 1 end @@ -271,7 +271,7 @@ class Guard::FooBar < Guard::Plugin; end before { ENV["GUARD_NOTIFY"] = nil } it "turns on the notifier on" do - ::Guard::Notifier.should_receive(:turn_on) + expect(::Guard::Notifier).to receive(:turn_on) ::Guard.setup(notify: true) end @@ -281,7 +281,7 @@ class Guard::FooBar < Guard::Plugin; end before { ENV["GUARD_NOTIFY"] = 'true' } it "turns on the notifier on" do - ::Guard::Notifier.should_receive(:turn_on) + expect(::Guard::Notifier).to receive(:turn_on) ::Guard.setup(notify: true) end @@ -291,7 +291,7 @@ class Guard::FooBar < Guard::Plugin; end before { ENV["GUARD_NOTIFY"] = 'false' } it "turns on the notifier off" do - ::Guard::Notifier.should_receive(:turn_off) + expect(::Guard::Notifier).to receive(:turn_off) ::Guard.setup(notify: true) end @@ -303,7 +303,7 @@ class Guard::FooBar < Guard::Plugin; end before { ENV["GUARD_NOTIFY"] = nil } it "turns on the notifier off" do - ::Guard::Notifier.should_receive(:turn_off) + expect(::Guard::Notifier).to receive(:turn_off) ::Guard.setup(notify: false) end @@ -313,7 +313,7 @@ class Guard::FooBar < Guard::Plugin; end before { ENV["GUARD_NOTIFY"] = 'true' } it "turns on the notifier on" do - ::Guard::Notifier.should_receive(:turn_off) + expect(::Guard::Notifier).to receive(:turn_off) ::Guard.setup(notify: false) end @@ -323,7 +323,7 @@ class Guard::FooBar < Guard::Plugin; end before { ENV["GUARD_NOTIFY"] = 'false' } it "turns on the notifier off" do - ::Guard::Notifier.should_receive(:turn_off) + expect(::Guard::Notifier).to receive(:turn_off) ::Guard.setup(notify: false) end @@ -339,7 +339,7 @@ class Guard::FooBar < Guard::Plugin; end before { ::Guard.stub(:options).and_return(Guard::Options.new(latency: 1.5)) } it "pass option to listener" do - Listen.should_receive(:to).with(anything, { latency: 1.5 }) { listener } + expect(Listen).to receive(:to).with(anything, { latency: 1.5 }) { listener } ::Guard.send :_setup_listener end @@ -349,7 +349,7 @@ class Guard::FooBar < Guard::Plugin; end before { ::Guard.stub(:options).and_return(Guard::Options.new(force_polling: true)) } it "pass option to listener" do - Listen.should_receive(:to).with(anything, { force_polling: true }) { listener } + expect(Listen).to receive(:to).with(anything, { force_polling: true }) { listener } ::Guard.send :_setup_listener end @@ -466,19 +466,19 @@ class Guard::FooBar < Guard::Plugin; end end it "outputs Kernel.#system method parameters" do - ::Guard::UI.should_receive(:debug).with("Command execution: echo test") + expect(::Guard::UI).to receive(:debug).with("Command execution: echo test") subject.send :_debug_command_execution - Kernel.should_receive(:original_system).with('echo', 'test').and_return true + expect(Kernel).to receive(:original_system).with('echo', 'test').and_return true - system('echo', 'test').should be_true + expect(system('echo', 'test')).to be_true end it "outputs Kernel.#` method parameters" do - ::Guard::UI.should_receive(:debug).with("Command execution: echo test") + expect(::Guard::UI).to receive(:debug).with("Command execution: echo test") subject.send :_debug_command_execution - Kernel.should_receive(:original_backtick).with('echo test').and_return "test\n" + expect(Kernel).to receive(:original_backtick).with('echo test').and_return "test\n" - `echo test`.should eq "test\n" + expect(`echo test`).to eq "test\n" end end diff --git a/spec/guard/ui_spec.rb b/spec/guard/ui_spec.rb index fefa6b74f..4442daaca 100644 --- a/spec/guard/ui_spec.rb +++ b/spec/guard/ui_spec.rb @@ -34,29 +34,29 @@ describe '.logger' do it 'returns the logger instance' do - Guard::UI.logger.should be_an_instance_of Lumberjack::Logger + expect(Guard::UI.logger).to be_an_instance_of Lumberjack::Logger end it 'sets the logger device' do - Guard::UI.logger.device.send(:stream).should be $stderr + expect(Guard::UI.logger.device.send(:stream)).to be $stderr end end describe '.options=' do it 'sets the logger options' do Guard::UI.options = { hi: :ho } - Guard::UI.options.hi.should eq :ho + expect(Guard::UI.options.hi).to eq :ho end end describe '.info' do it 'resets the line with the :reset option' do - Guard::UI.should_receive :reset_line + expect(Guard::UI).to receive :reset_line Guard::UI.info('Info message', { reset: true }) end it 'logs the message to with the info severity' do - Guard::UI.logger.should_receive(:info).with('Info message', 'Guard::Ui') + expect(Guard::UI.logger).to receive(:info).with('Info message', 'Guard::Ui') Guard::UI.info 'Info message' end @@ -64,9 +64,9 @@ before { Guard::UI.options.only = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_receive(:info).with('Info message', 'A') - Guard::UI.logger.should_not_receive(:info).with('Info message', 'B') - Guard::UI.logger.should_not_receive(:info).with('Info message', 'C') + expect(Guard::UI.logger).to receive(:info).with('Info message', 'A') + expect(Guard::UI.logger).to_not receive(:info).with('Info message', 'B') + expect(Guard::UI.logger).to_not receive(:info).with('Info message', 'C') Guard::UI.info 'Info message', plugin: 'A' Guard::UI.info 'Info message', plugin: 'B' @@ -78,9 +78,9 @@ before { Guard::UI.options.except = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_not_receive(:info).with('Info message', 'A') - Guard::UI.logger.should_receive(:info).with('Info message', 'B') - Guard::UI.logger.should_receive(:info).with('Info message', 'C') + expect(Guard::UI.logger).to_not receive(:info).with('Info message', 'A') + expect(Guard::UI.logger).to receive(:info).with('Info message', 'B') + expect(Guard::UI.logger).to receive(:info).with('Info message', 'C') Guard::UI.info 'Info message', plugin: 'A' Guard::UI.info 'Info message', plugin: 'B' @@ -91,12 +91,12 @@ describe '.warning' do it 'resets the line with the :reset option' do - Guard::UI.should_receive :reset_line + expect(Guard::UI).to receive :reset_line Guard::UI.warning('Warn message', { reset: true }) end it 'logs the message to with the warn severity' do - Guard::UI.logger.should_receive(:warn).with("\e[0;33mWarn message\e[0m", 'Guard::Ui') + expect(Guard::UI.logger).to receive(:warn).with("\e[0;33mWarn message\e[0m", 'Guard::Ui') Guard::UI.warning 'Warn message' end @@ -104,9 +104,9 @@ before { Guard::UI.options.only = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_receive(:warn).with("\e[0;33mWarn message\e[0m", 'A') - Guard::UI.logger.should_not_receive(:warn).with("\e[0;33mWarn message\e[0m", 'B') - Guard::UI.logger.should_not_receive(:warn).with("\e[0;33mWarn message\e[0m", 'C') + expect(Guard::UI.logger).to receive(:warn).with("\e[0;33mWarn message\e[0m", 'A') + expect(Guard::UI.logger).to_not receive(:warn).with("\e[0;33mWarn message\e[0m", 'B') + expect(Guard::UI.logger).to_not receive(:warn).with("\e[0;33mWarn message\e[0m", 'C') Guard::UI.warning 'Warn message', plugin: 'A' Guard::UI.warning 'Warn message', plugin: 'B' @@ -118,9 +118,9 @@ before { Guard::UI.options.except = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_not_receive(:warn).with("\e[0;33mWarn message\e[0m", 'A') - Guard::UI.logger.should_receive(:warn).with("\e[0;33mWarn message\e[0m", 'B') - Guard::UI.logger.should_receive(:warn).with("\e[0;33mWarn message\e[0m", 'C') + expect(Guard::UI.logger).to_not receive(:warn).with("\e[0;33mWarn message\e[0m", 'A') + expect(Guard::UI.logger).to receive(:warn).with("\e[0;33mWarn message\e[0m", 'B') + expect(Guard::UI.logger).to receive(:warn).with("\e[0;33mWarn message\e[0m", 'C') Guard::UI.warning 'Warn message', plugin: 'A' Guard::UI.warning 'Warn message', plugin: 'B' @@ -131,12 +131,12 @@ describe '.error' do it 'resets the line with the :reset option' do - Guard::UI.should_receive :reset_line + expect(Guard::UI).to receive :reset_line Guard::UI.error('Error message', { reset: true }) end it 'logs the message to with the error severity' do - Guard::UI.logger.should_receive(:error).with("\e[0;31mError message\e[0m", 'Guard::Ui') + expect(Guard::UI.logger).to receive(:error).with("\e[0;31mError message\e[0m", 'Guard::Ui') Guard::UI.error 'Error message' end @@ -144,9 +144,9 @@ before { Guard::UI.options.only = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_receive(:error).with("\e[0;31mError message\e[0m", 'A') - Guard::UI.logger.should_not_receive(:error).with("\e[0;31mError message\e[0m", 'B') - Guard::UI.logger.should_not_receive(:error).with("\e[0;31mError message\e[0m", 'C') + expect(Guard::UI.logger).to receive(:error).with("\e[0;31mError message\e[0m", 'A') + expect(Guard::UI.logger).to_not receive(:error).with("\e[0;31mError message\e[0m", 'B') + expect(Guard::UI.logger).to_not receive(:error).with("\e[0;31mError message\e[0m", 'C') Guard::UI.error 'Error message', plugin: 'A' Guard::UI.error 'Error message', plugin: 'B' @@ -158,9 +158,9 @@ before { Guard::UI.options.except = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_not_receive(:error).with("\e[0;31mError message\e[0m", 'A') - Guard::UI.logger.should_receive(:error).with("\e[0;31mError message\e[0m", 'B') - Guard::UI.logger.should_receive(:error).with("\e[0;31mError message\e[0m", 'C') + expect(Guard::UI.logger).to_not receive(:error).with("\e[0;31mError message\e[0m", 'A') + expect(Guard::UI.logger).to receive(:error).with("\e[0;31mError message\e[0m", 'B') + expect(Guard::UI.logger).to receive(:error).with("\e[0;31mError message\e[0m", 'C') Guard::UI.error 'Error message', plugin: 'A' Guard::UI.error 'Error message', plugin: 'B' @@ -174,7 +174,7 @@ before { Guard.setup(show_deprecations: false) } it 'do not log' do - Guard::UI.logger.should_not_receive(:warn) + expect(Guard::UI.logger).to_not receive(:warn) Guard::UI.deprecation 'Deprecator message' end end @@ -183,12 +183,12 @@ before { Guard.setup(show_deprecations: true) } it 'resets the line with the :reset option' do - Guard::UI.should_receive :reset_line + expect(Guard::UI).to receive :reset_line Guard::UI.deprecation('Deprecator message', { reset: true }) end it 'logs the message to with the warn severity' do - Guard::UI.logger.should_receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'Guard::Ui') + expect(Guard::UI.logger).to receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'Guard::Ui') Guard::UI.deprecation 'Deprecator message' end @@ -196,9 +196,9 @@ before { Guard::UI.options.only = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'A') - Guard::UI.logger.should_not_receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'B') - Guard::UI.logger.should_not_receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'C') + expect(Guard::UI.logger).to receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'A') + expect(Guard::UI.logger).to_not receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'B') + expect(Guard::UI.logger).to_not receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'C') Guard::UI.deprecation 'Deprecator message', plugin: 'A' Guard::UI.deprecation 'Deprecator message', plugin: 'B' @@ -210,9 +210,9 @@ before { Guard::UI.options.except = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_not_receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'A') - Guard::UI.logger.should_receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'B') - Guard::UI.logger.should_receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'C') + expect(Guard::UI.logger).to_not receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'A') + expect(Guard::UI.logger).to receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'B') + expect(Guard::UI.logger).to receive(:warn).with("\e[0;33mDeprecator message\e[0m", 'C') Guard::UI.deprecation 'Deprecator message', plugin: 'A' Guard::UI.deprecation 'Deprecator message', plugin: 'B' @@ -224,12 +224,12 @@ describe '.debug' do it 'resets the line with the :reset option' do - Guard::UI.should_receive :reset_line + expect(Guard::UI).to receive :reset_line Guard::UI.debug('Debug message', { reset: true }) end it 'logs the message to with the debug severity' do - Guard::UI.logger.should_receive(:debug).with("\e[0;33mDebug message\e[0m", 'Guard::Ui') + expect(Guard::UI.logger).to receive(:debug).with("\e[0;33mDebug message\e[0m", 'Guard::Ui') Guard::UI.debug 'Debug message' end @@ -237,9 +237,9 @@ before { Guard::UI.options.only = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_receive(:debug).with("\e[0;33mDebug message\e[0m", 'A') - Guard::UI.logger.should_not_receive(:debug).with("\e[0;33mDebug message\e[0m", 'B') - Guard::UI.logger.should_not_receive(:debug).with("\e[0;33mDebug message\e[0m", 'C') + expect(Guard::UI.logger).to receive(:debug).with("\e[0;33mDebug message\e[0m", 'A') + expect(Guard::UI.logger).to_not receive(:debug).with("\e[0;33mDebug message\e[0m", 'B') + expect(Guard::UI.logger).to_not receive(:debug).with("\e[0;33mDebug message\e[0m", 'C') Guard::UI.debug 'Debug message', plugin: 'A' Guard::UI.debug 'Debug message', plugin: 'B' @@ -251,9 +251,9 @@ before { Guard::UI.options.except = /A/ } it 'shows only the matching messages' do - Guard::UI.logger.should_not_receive(:debug).with("\e[0;33mDebug message\e[0m", 'A') - Guard::UI.logger.should_receive(:debug).with("\e[0;33mDebug message\e[0m", 'B') - Guard::UI.logger.should_receive(:debug).with("\e[0;33mDebug message\e[0m", 'C') + expect(Guard::UI.logger).to_not receive(:debug).with("\e[0;33mDebug message\e[0m", 'A') + expect(Guard::UI.logger).to receive(:debug).with("\e[0;33mDebug message\e[0m", 'B') + expect(Guard::UI.logger).to receive(:debug).with("\e[0;33mDebug message\e[0m", 'C') Guard::UI.debug 'Debug message', plugin: 'A' Guard::UI.debug 'Debug message', plugin: 'B' @@ -268,21 +268,21 @@ it 'clears the outputs if clearable' do Guard::UI.clearable - Guard::UI.should_receive(:system).with('clear;') + expect(Guard::UI).to receive(:system).with('clear;') Guard::UI.clear end it 'doesn not clear the output if already cleared' do Guard::UI.stub(:system) Guard::UI.clear - Guard::UI.should_not_receive(:system).with('clear;') + expect(Guard::UI).to_not receive(:system).with('clear;') Guard::UI.clear end it 'clears the outputs if forced' do Guard::UI.stub(:system) Guard::UI.clear - Guard::UI.should_receive(:system).with('clear;') + expect(Guard::UI).to receive(:system).with('clear;') Guard::UI.clear(force: true) end end @@ -291,7 +291,7 @@ before { Guard.setup(clear: false) } it 'does not clear the output' do - Guard::UI.should_not_receive(:system).with('clear;') + expect(Guard::UI).to_not receive(:system).with('clear;') Guard::UI.clear end end @@ -306,14 +306,14 @@ context 'with a plugins scope' do it 'shows the plugin scoped action' do - Guard::UI.should_receive(:info).with('Reload Rspec, Jasmine') + expect(Guard::UI).to receive(:info).with('Reload Rspec, Jasmine') Guard::UI.action_with_scopes('Reload', { plugins: [rspec, jasmine] }) end end context 'with a groups scope' do it 'shows the group scoped action' do - Guard::UI.should_receive(:info).with('Reload Frontend') + expect(Guard::UI).to receive(:info).with('Reload Frontend') Guard::UI.action_with_scopes('Reload', { groups: [group] }) end end @@ -322,7 +322,7 @@ context 'with a global plugin scope' do it 'shows the global plugin scoped action' do Guard.scope = { plugins: [rspec, jasmine] } - Guard::UI.should_receive(:info).with('Reload Rspec, Jasmine') + expect(Guard::UI).to receive(:info).with('Reload Rspec, Jasmine') Guard::UI.action_with_scopes('Reload', {}) end end @@ -330,7 +330,7 @@ context 'with a global group scope' do it 'shows the global group scoped action' do Guard.scope = { groups: [group] } - Guard::UI.should_receive(:info).with('Reload Frontend') + expect(Guard::UI).to receive(:info).with('Reload Frontend') Guard::UI.action_with_scopes('Reload', {}) end end diff --git a/spec/guard/watcher_spec.rb b/spec/guard/watcher_spec.rb index 9e768d4c3..eeb5ce02d 100644 --- a/spec/guard/watcher_spec.rb +++ b/spec/guard/watcher_spec.rb @@ -11,13 +11,13 @@ context "with a pattern parameter" do context "that is a string" do it "keeps the string pattern unmodified" do - described_class.new('spec_helper.rb').pattern.should eq 'spec_helper.rb' + expect(described_class.new('spec_helper.rb').pattern).to eq 'spec_helper.rb' end end context "that is a regexp" do it "keeps the regex pattern unmodified" do - described_class.new(/spec_helper\.rb/).pattern.should eq /spec_helper\.rb/ + expect(described_class.new(/spec_helper\.rb/).pattern).to eq /spec_helper\.rb/ end end @@ -25,10 +25,10 @@ before(:each) { Guard::UI.stub(:info) } it "converts the string automatically to a regex" do - described_class.new('^spec_helper.rb').pattern.should eq(/^spec_helper.rb/) - described_class.new('spec_helper.rb$').pattern.should eq(/spec_helper.rb$/) - described_class.new('spec_helper\.rb').pattern.should eq(/spec_helper\.rb/) - described_class.new('.*_spec.rb').pattern.should eq(/.*_spec.rb/) + expect(described_class.new('^spec_helper.rb').pattern).to eq(/^spec_helper.rb/) + expect(described_class.new('spec_helper.rb$').pattern).to eq(/spec_helper.rb$/) + expect(described_class.new('spec_helper\.rb').pattern).to eq(/spec_helper\.rb/) + expect(described_class.new('.*_spec.rb').pattern).to eq(/.*_spec.rb/) end end end @@ -36,12 +36,12 @@ describe "#action" do it "sets the action to nothing by default" do - described_class.new(/spec_helper\.rb/).action.should be_nil + expect(described_class.new(/spec_helper\.rb/).action).to be_nil end it "sets the action to the supplied block" do action = lambda { |m| "spec/#{m[1]}_spec.rb" } - described_class.new(%r{^lib/(.*).rb}, action).action.should eq action + expect(described_class.new(%r{^lib/(.*).rb}, action).action).to eq action end end @@ -57,7 +57,7 @@ before(:all) { @guard_plugin.watchers = [described_class.new(/.*_spec\.rb/)] } it "returns the paths that matches the regex" do - described_class.match_files(@guard_plugin, ['guard_rocks_spec.rb', 'guard_rocks.rb']).should eq ['guard_rocks_spec.rb'] + expect(described_class.match_files(@guard_plugin, ['guard_rocks_spec.rb', 'guard_rocks.rb'])).to eq ['guard_rocks_spec.rb'] end end @@ -65,7 +65,7 @@ before(:all) { @guard_plugin.watchers = [described_class.new('guard_rocks_spec.rb')] } it "returns the path that matches the string" do - described_class.match_files(@guard_plugin, ['guard_rocks_spec.rb', 'guard_rocks.rb']).should eq ['guard_rocks_spec.rb'] + expect(described_class.match_files(@guard_plugin, ['guard_rocks_spec.rb', 'guard_rocks.rb'])).to eq ['guard_rocks_spec.rb'] end end end @@ -84,27 +84,27 @@ end it "returns a single file specified within the action" do - described_class.match_files(@guard_plugin, ['spec_helper.rb']).should eq ['spec'] + expect(described_class.match_files(@guard_plugin, ['spec_helper.rb'])).to eq ['spec'] end it "returns multiple files specified within the action" do - described_class.match_files(@guard_plugin, ['hash.rb']).should eq ['foo', 'bar'] + expect(described_class.match_files(@guard_plugin, ['hash.rb'])).to eq ['foo', 'bar'] end it "returns multiple files by combining the results of different actions" do - described_class.match_files(@guard_plugin, ['spec_helper.rb', 'array.rb']).should eq ['spec', 'foo', 'bar'] + expect(described_class.match_files(@guard_plugin, ['spec_helper.rb', 'array.rb'])).to eq ['spec', 'foo', 'bar'] end it "returns nothing if the action returns something other than a string or an array of strings" do - described_class.match_files(@guard_plugin, ['addition.rb']).should eq [] + expect(described_class.match_files(@guard_plugin, ['addition.rb'])).to eq [] end it "returns nothing if the action response is empty" do - described_class.match_files(@guard_plugin, ['blank.rb']).should eq [] + expect(described_class.match_files(@guard_plugin, ['blank.rb'])).to eq [] end it "returns nothing if the action returns nothing" do - described_class.match_files(@guard_plugin, ['uptime.rb']).should eq [] + expect(described_class.match_files(@guard_plugin, ['uptime.rb'])).to eq [] end end @@ -121,29 +121,29 @@ end it "returns a single file specified within the action" do - described_class.match_files(@guard_plugin_any_return, ['spec_helper.rb']).class.should be Array - described_class.match_files(@guard_plugin_any_return, ['spec_helper.rb']).empty?.should be_false + expect(described_class.match_files(@guard_plugin_any_return, ['spec_helper.rb']).class).to be Array + expect(described_class.match_files(@guard_plugin_any_return, ['spec_helper.rb']).empty?).to be_false end it "returns multiple files specified within the action" do - described_class.match_files(@guard_plugin_any_return, ['hash.rb']).should eq [{foo: 'bar'}] + expect(described_class.match_files(@guard_plugin_any_return, ['hash.rb'])).to eq [{foo: 'bar'}] end it "returns multiple files by combining the results of different actions" do - described_class.match_files(@guard_plugin_any_return, ['spec_helper.rb', 'array.rb']).should eq ['spec', ['foo', 'bar']] + expect(described_class.match_files(@guard_plugin_any_return, ['spec_helper.rb', 'array.rb'])).to eq ['spec', ['foo', 'bar']] end it "returns the evaluated addition argument in an array" do - described_class.match_files(@guard_plugin_any_return, ['addition.rb']).class.should be Array - described_class.match_files(@guard_plugin_any_return, ['addition.rb'])[0].should eq 2 + expect(described_class.match_files(@guard_plugin_any_return, ['addition.rb']).class).to be Array + expect(described_class.match_files(@guard_plugin_any_return, ['addition.rb'])[0]).to eq 2 end it "returns nothing if the action response is empty string" do - described_class.match_files(@guard_plugin_any_return, ['blank.rb']).should eq [''] + expect(described_class.match_files(@guard_plugin_any_return, ['blank.rb'])).to eq [''] end it "returns nothing if the action returns is DEV_NULL" do - described_class.match_files(@guard_plugin_any_return, ['uptime.rb']).should eq [nil] + expect(described_class.match_files(@guard_plugin_any_return, ['uptime.rb'])).to eq [nil] end end end @@ -162,27 +162,27 @@ end it "returns a substituted single file specified within the action" do - described_class.match_files(@guard_plugin, ['lib/my_wonderful_lib.rb']).should eq ['spec/my_wonderful_lib_spec.rb'] + expect(described_class.match_files(@guard_plugin, ['lib/my_wonderful_lib.rb'])).to eq ['spec/my_wonderful_lib_spec.rb'] end it "returns multiple files specified within the action" do - described_class.match_files(@guard_plugin, ['hash.rb']).should eq ['foo', 'bar'] + expect(described_class.match_files(@guard_plugin, ['hash.rb'])).to eq ['foo', 'bar'] end it "returns multiple files by combining the results of different actions" do - described_class.match_files(@guard_plugin, ['lib/my_wonderful_lib.rb', 'array.rb']).should eq ['spec/my_wonderful_lib_spec.rb', 'foo', 'bar'] + expect(described_class.match_files(@guard_plugin, ['lib/my_wonderful_lib.rb', 'array.rb'])).to eq ['spec/my_wonderful_lib_spec.rb', 'foo', 'bar'] end it "returns nothing if the action returns something other than a string or an array of strings" do - described_class.match_files(@guard_plugin, ['addition.rb']).should eq [] + expect(described_class.match_files(@guard_plugin, ['addition.rb'])).to eq [] end it "returns nothing if the action response is empty" do - described_class.match_files(@guard_plugin, ['blank.rb']).should eq [] + expect(described_class.match_files(@guard_plugin, ['blank.rb'])).to eq [] end it "returns nothing if the action returns nothing" do - described_class.match_files(@guard_plugin, ['uptime.rb']).should eq [] + expect(described_class.match_files(@guard_plugin, ['uptime.rb'])).to eq [] end end @@ -199,27 +199,27 @@ end it "returns a substituted single file specified within the action" do - described_class.match_files(@guard_plugin_any_return, ['lib/my_wonderful_lib.rb']).should eq ['spec/my_wonderful_lib_spec.rb'] + expect(described_class.match_files(@guard_plugin_any_return, ['lib/my_wonderful_lib.rb'])).to eq ['spec/my_wonderful_lib_spec.rb'] end it "returns a hash specified within the action" do - described_class.match_files(@guard_plugin_any_return, ['hash.rb']).should eq [{foo: 'bar', file_name: 'hash.rb'}] + expect(described_class.match_files(@guard_plugin_any_return, ['hash.rb'])).to eq [{foo: 'bar', file_name: 'hash.rb'}] end it "returns multiple files by combining the results of different actions" do - described_class.match_files(@guard_plugin_any_return, ['lib/my_wonderful_lib.rb', 'array.rb']).should eq ['spec/my_wonderful_lib_spec.rb', ['foo', 'bar', "array.rb"]] + expect(described_class.match_files(@guard_plugin_any_return, ['lib/my_wonderful_lib.rb', 'array.rb'])).to eq ['spec/my_wonderful_lib_spec.rb', ['foo', 'bar', "array.rb"]] end it "returns the evaluated addition argument + the path" do - described_class.match_files(@guard_plugin_any_return, ['addition.rb']).should eq ["2addition.rb"] + expect(described_class.match_files(@guard_plugin_any_return, ['addition.rb'])).to eq ["2addition.rb"] end it "returns nothing if the action response is empty string" do - described_class.match_files(@guard_plugin_any_return, ['blank.rb']).should eq [''] + expect(described_class.match_files(@guard_plugin_any_return, ['blank.rb'])).to eq [''] end it "returns nothing if the action returns is DEV_NULL" do - described_class.match_files(@guard_plugin_any_return, ['uptime.rb']).should eq [nil] + expect(described_class.match_files(@guard_plugin_any_return, ['uptime.rb'])).to eq [nil] end end end @@ -228,9 +228,9 @@ before(:all) { @guard_plugin.watchers = [described_class.new('evil.rb', lambda { raise "EVIL" })] } it "displays the error and backtrace" do - Guard::UI.should_receive(:error) do |msg| - msg.should include("Problem with watch action!") - msg.should include("EVIL") + expect(Guard::UI).to receive(:error) do |msg| + expect(msg).to include("Problem with watch action!") + expect(msg).to include("EVIL") end described_class.match_files(@guard_plugin, ['evil.rb']) @@ -246,11 +246,11 @@ end context "with a watcher that matches a file" do - specify { described_class.match_files?(@plugins, ['lib/my_wonderful_lib.rb', 'guard_rocks_spec.rb']).should be_true } + specify { expect(described_class.match_files?(@plugins, ['lib/my_wonderful_lib.rb', 'guard_rocks_spec.rb'])).to be_true } end context "with no watcher that matches a file" do - specify { described_class.match_files?(@plugins, ['lib/my_wonderful_lib.rb']).should be_false } + specify { expect(described_class.match_files?(@plugins, ['lib/my_wonderful_lib.rb'])).to be_false } end end @@ -260,17 +260,17 @@ subject { described_class.new('guard_rocks_spec.rb') } context "with a watcher that matches a file" do - specify { subject.match('guard_rocks_spec.rb').should eq ['guard_rocks_spec.rb'] } + specify { expect(subject.match('guard_rocks_spec.rb')).to eq ['guard_rocks_spec.rb'] } end context "with a file containing a $" do subject { described_class.new('lib$/guard_rocks_spec.rb') } - specify { subject.match('lib$/guard_rocks_spec.rb').should eq ['lib$/guard_rocks_spec.rb'] } + specify { expect(subject.match('lib$/guard_rocks_spec.rb')).to eq ['lib$/guard_rocks_spec.rb'] } end context "with no watcher that matches a file" do - specify { subject.match('lib/my_wonderful_lib.rb').should be_nil } + specify { expect(subject.match('lib/my_wonderful_lib.rb')).to be_nil } end end @@ -278,11 +278,11 @@ subject { described_class.new('^guard_(rocks)_spec\.rb$') } context "with a watcher that matches a file" do - specify { subject.match('guard_rocks_spec.rb').should eq ['guard_rocks_spec.rb', 'rocks'] } + specify { expect(subject.match('guard_rocks_spec.rb')).to eq ['guard_rocks_spec.rb', 'rocks'] } end context "with no watcher that matches a file" do - specify { subject.match('lib/my_wonderful_lib.rb').should be_nil } + specify { expect(subject.match('lib/my_wonderful_lib.rb')).to be_nil } end end end @@ -291,15 +291,15 @@ subject { described_class.new(/(.*)_spec\.rb/) } context "with a watcher that matches a file" do - specify { subject.match('guard_rocks_spec.rb').should eq ['guard_rocks_spec.rb', 'guard_rocks'] } + specify { expect(subject.match('guard_rocks_spec.rb')).to eq ['guard_rocks_spec.rb', 'guard_rocks'] } end context "with a file containing a $" do - specify { subject.match('lib$/guard_rocks_spec.rb').should eq ['lib$/guard_rocks_spec.rb', 'lib$/guard_rocks'] } + specify { expect(subject.match('lib$/guard_rocks_spec.rb')).to eq ['lib$/guard_rocks_spec.rb', 'lib$/guard_rocks'] } end context "with no watcher that matches a file" do - specify { subject.match('lib/my_wonderful_lib.rb').should be_nil } + specify { expect(subject.match('lib/my_wonderful_lib.rb')).to be_nil } end end @@ -308,11 +308,11 @@ subject { described_class.new('guard_rocks_spec.rb') } context "with a watcher that matches a file" do - specify { subject.match('!guard_rocks_spec.rb').should eq ['!guard_rocks_spec.rb'] } + specify { expect(subject.match('!guard_rocks_spec.rb')).to eq ['!guard_rocks_spec.rb'] } end context "with no watcher that matches a file" do - specify { subject.match('!lib/my_wonderful_lib.rb').should be_nil } + specify { expect(subject.match('!lib/my_wonderful_lib.rb')).to be_nil } end end @@ -320,11 +320,11 @@ subject { described_class.new(/(.*)_spec\.rb/) } context "with a watcher that matches a file" do - specify { subject.match('!guard_rocks_spec.rb').should eq ['!guard_rocks_spec.rb', 'guard_rocks'] } + specify { expect(subject.match('!guard_rocks_spec.rb')).to eq ['!guard_rocks_spec.rb', 'guard_rocks'] } end context "with no watcher that matches a file" do - specify { subject.match('!lib/my_wonderful_lib.rb').should be_nil } + specify { expect(subject.match('!lib/my_wonderful_lib.rb')).to be_nil } end end end @@ -334,11 +334,11 @@ before { Guard.stub(:evaluator) { double(guardfile_path: Dir.pwd + '/Guardfile') } } context "with files that match the Guardfile" do - specify { described_class.match_guardfile?(['Guardfile', 'guard_rocks_spec.rb']).should be_true } + specify { expect(described_class.match_guardfile?(['Guardfile', 'guard_rocks_spec.rb'])).to be_true } end context "with no files that match the Guardfile" do - specify { described_class.match_guardfile?(['guard_rocks.rb', 'guard_rocks_spec.rb']).should be_false } + specify { expect(described_class.match_guardfile?(['guard_rocks.rb', 'guard_rocks_spec.rb'])).to be_false } end end diff --git a/spec/guard_spec.rb b/spec/guard_spec.rb index 46838978b..e263ea283 100644 --- a/spec/guard_spec.rb +++ b/spec/guard_spec.rb @@ -13,58 +13,58 @@ end it "return @plugins without any argument" do - described_class.plugins.should eq subject.instance_variable_get("@plugins") + expect(described_class.plugins).to eq subject.instance_variable_get("@plugins") end context "find a plugin by as string" do it "returns an array of plugins if plugins are found" do - described_class.plugins('foo-bar').should eq [@guard_foo_bar_backend, @guard_foo_bar_frontend] + expect(described_class.plugins('foo-bar')).to eq [@guard_foo_bar_backend, @guard_foo_bar_frontend] end end context "find a plugin by as symbol" do it "returns an array of plugins if plugins are found" do - described_class.plugins(:'foo-bar').should eq [@guard_foo_bar_backend, @guard_foo_bar_frontend] + expect(described_class.plugins(:'foo-bar')).to eq [@guard_foo_bar_backend, @guard_foo_bar_frontend] end it "returns an empty array when no plugin is found" do - described_class.plugins('foo-foo').should be_empty + expect(described_class.plugins('foo-foo')).to be_empty end end context "find plugins matching a regexp" do it "returns an array of plugins if plugins are found" do - described_class.plugins(/^foobar/).should eq [@guard_foo_bar_backend, @guard_foo_bar_frontend] + expect(described_class.plugins(/^foobar/)).to eq [@guard_foo_bar_backend, @guard_foo_bar_frontend] end it "returns an empty array when no plugin is found" do - described_class.plugins(/foo$/).should be_empty + expect(described_class.plugins(/foo$/)).to be_empty end end context "find plugins by their group as a string" do it "returns an array of plugins if plugins are found" do - described_class.plugins(group: 'backend').should eq [@guard_foo_bar_backend, @guard_foo_baz_backend] + expect(described_class.plugins(group: 'backend')).to eq [@guard_foo_bar_backend, @guard_foo_baz_backend] end end context "find plugins by their group as a symbol" do it "returns an array of plugins if plugins are found" do - described_class.plugins(group: :frontend).should eq [@guard_foo_bar_frontend, @guard_foo_baz_frontend] + expect(described_class.plugins(group: :frontend)).to eq [@guard_foo_bar_frontend, @guard_foo_baz_frontend] end it "returns an empty array when no plugin is found" do - described_class.plugins(group: :unknown).should be_empty + expect(described_class.plugins(group: :unknown)).to be_empty end end context "find plugins by their group & name" do it "returns an array of plugins if plugins are found" do - described_class.plugins(group: 'backend', name: 'foo-bar').should eq [@guard_foo_bar_backend] + expect(described_class.plugins(group: 'backend', name: 'foo-bar')).to eq [@guard_foo_bar_backend] end it "returns an empty array when no plugin is found" do - described_class.plugins(group: :unknown, name: :'foo-baz').should be_empty + expect(described_class.plugins(group: :unknown, name: :'foo-baz')).to be_empty end end end @@ -81,53 +81,53 @@ context "find a plugin by a string" do it "returns the first plugin found" do - described_class.plugin('foo-bar').should eq @guard_foo_bar_backend + expect(described_class.plugin('foo-bar')).to eq @guard_foo_bar_backend end end context "find a plugin by a symbol" do it "returns the first plugin found" do - described_class.plugin(:'foo-bar').should eq @guard_foo_bar_backend + expect(described_class.plugin(:'foo-bar')).to eq @guard_foo_bar_backend end it "returns nil when no plugin is found" do - described_class.plugin('foo-foo').should be_nil + expect(described_class.plugin('foo-foo')).to be_nil end end context "find plugins matching a regexp" do it "returns the first plugin found" do - described_class.plugin(/^foobar/).should eq @guard_foo_bar_backend + expect(described_class.plugin(/^foobar/)).to eq @guard_foo_bar_backend end it "returns nil when no plugin is found" do - described_class.plugin(/foo$/).should be_nil + expect(described_class.plugin(/foo$/)).to be_nil end end context "find a plugin by its group as a string" do it "returns the first plugin found" do - described_class.plugin(group: 'backend').should eq @guard_foo_bar_backend + expect(described_class.plugin(group: 'backend')).to eq @guard_foo_bar_backend end end context "find plugins by their group as a symbol" do it "returns the first plugin found" do - described_class.plugin(group: :frontend).should eq @guard_foo_bar_frontend + expect(described_class.plugin(group: :frontend)).to eq @guard_foo_bar_frontend end it "returns nil when no plugin is found" do - described_class.plugin(group: :unknown).should be_nil + expect(described_class.plugin(group: :unknown)).to be_nil end end context "find plugins by their group & name" do it "returns the first plugin found" do - described_class.plugin(group: 'backend', name: 'foo-bar').should eq @guard_foo_bar_backend + expect(described_class.plugin(group: 'backend', name: 'foo-bar')).to eq @guard_foo_bar_backend end it "returns nil when no plugin is found" do - described_class.plugin(group: :unknown, name: :'foo-baz').should be_nil + expect(described_class.plugin(group: :unknown, name: :'foo-baz')).to be_nil end end end @@ -142,37 +142,37 @@ context 'without no argument' do it 'returns all groups' do - subject.groups.should eq subject.instance_variable_get("@groups") + expect(subject.groups).to eq subject.instance_variable_get("@groups") end end context 'with a string argument' do it "returns an array of groups if plugins are found" do - subject.groups('backend').should eq [@group_backend] + expect(subject.groups('backend')).to eq [@group_backend] end end context 'with a symbol argument matching a group' do it "returns an array of groups if plugins are found" do - subject.groups(:backend).should eq [@group_backend] + expect(subject.groups(:backend)).to eq [@group_backend] end end context 'with a symbol argument not matching a group' do it "returns an empty array when no group is found" do - subject.groups(:foo).should be_empty + expect(subject.groups(:foo)).to be_empty end end context 'with a regexp argument matching a group' do it 'returns an array of groups' do - subject.groups(/^back/).should eq [@group_backend, @group_backflip] + expect(subject.groups(/^back/)).to eq [@group_backend, @group_backflip] end end context 'with a regexp argument not matching a group' do it "returns an empty array when no group is found" do - subject.groups(/back$/).should be_empty + expect(subject.groups(/back$/)).to be_empty end end end @@ -187,31 +187,31 @@ context 'with a string argument' do it "returns the first group found" do - subject.group('backend').should eq @group_backend + expect(subject.group('backend')).to eq @group_backend end end context 'with a symbol argument' do it "returns the first group found" do - subject.group(:backend).should eq @group_backend + expect(subject.group(:backend)).to eq @group_backend end end context 'with a symbol argument not matching a group' do it "returns nil when no group is found" do - subject.group(:foo).should be_nil + expect(subject.group(:foo)).to be_nil end end context 'with a regexp argument matching a group' do it "returns the first group found" do - subject.group(/^back/).should eq @group_backend + expect(subject.group(/^back/)).to eq @group_backend end end context 'with a regexp argument not matching a group' do it "returns nil when no group is found" do - subject.group(/back$/).should be_nil + expect(subject.group(/back$/)).to be_nil end end end @@ -221,14 +221,14 @@ let(:guard_rspec) { double('Guard::RSpec instance') } before do - ::Guard::PluginUtil.should_receive(:new).with('rspec') { plugin_util } + expect(::Guard::PluginUtil).to receive(:new).with('rspec') { plugin_util } plugin_util.stub(:initialize_plugin) { guard_rspec } ::Guard.reset_plugins end it 'delegates the plugin instantiation to Guard::PluginUtil' do - plugin_util.should_receive(:initialize_plugin).with(watchers: ['watcher'], group: 'foo') + expect(plugin_util).to receive(:initialize_plugin).with(watchers: ['watcher'], group: 'foo') ::Guard.add_plugin('rspec', watchers: ['watcher'], group: 'foo') end @@ -236,7 +236,7 @@ it "adds guard to the @plugins array" do ::Guard.add_plugin('rspec') - ::Guard.plugins.should eq [guard_rspec] + expect(::Guard.plugins).to eq [guard_rspec] end end @@ -245,22 +245,22 @@ it "accepts group name as string" do ::Guard.add_group('backend') - ::Guard.groups[0].name.should eq :default - ::Guard.groups[1].name.should eq :backend + expect(::Guard.groups[0].name).to eq :default + expect(::Guard.groups[1].name).to eq :backend end it "accepts group name as symbol" do ::Guard.add_group(:backend) - ::Guard.groups[0].name.should eq :default - ::Guard.groups[1].name.should eq :backend + expect(::Guard.groups[0].name).to eq :default + expect(::Guard.groups[1].name).to eq :backend end it "accepts options" do ::Guard.add_group(:backend, { halt_on_fail: true }) - ::Guard.groups[0].options.should eq({}) - ::Guard.groups[1].options.should eq({ halt_on_fail: true }) + expect(::Guard.groups[0].options).to eq({}) + expect(::Guard.groups[1].options).to eq({ halt_on_fail: true }) end end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index f328f9719..78ffc1836 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -16,6 +16,9 @@ config.filter_run focus: ENV['CI'] != 'true' config.treat_symbols_as_metadata_keys_with_true_values = true config.run_all_when_everything_filtered = true + config.expect_with :rspec do |c| + c.syntax = :expect + end config.before(:each) do @fixture_path = Pathname.new(File.expand_path('../fixtures/', __FILE__)) diff --git a/spec/support/guard_helper.rb b/spec/support/guard_helper.rb index 88259ae30..790d5b988 100644 --- a/spec/support/guard_helper.rb +++ b/spec/support/guard_helper.rb @@ -1,27 +1,27 @@ shared_examples_for 'interactor enabled' do it 'enables the interactor' do - Guard::Interactor.should_receive(:new) + expect(Guard::Interactor).to receive(:new) Guard.send :_setup_interactor end end shared_examples_for 'interactor disabled' do it 'disables the interactor' do - Guard::Interactor.should_not_receive(:new) + expect(Guard::Interactor).to_not receive(:new) Guard.send :_setup_interactor end end shared_examples_for 'notifier enabled' do it 'enables the notifier' do - Guard::Notifier.should_receive(:turn_on) + expect(Guard::Notifier).to receive(:turn_on) Guard.send :_setup_notifier end end shared_examples_for 'notifier disabled' do it 'disables the notifier' do - Guard::Notifier.should_receive(:turn_off) + expect(Guard::Notifier).to receive(:turn_off) Guard.send :_setup_notifier end end