Skip to content

Commit

Permalink
Convert specs to RSpec 2.99.2 syntax with Transpec
Browse files Browse the repository at this point in the history
This conversion is done by Transpec 3.3.0 with the following command:
    transpec --force --convert stub_with_hash

* 396 conversions
    from: obj.should_receive(:message)
      to: expect(obj).to receive(:message)

* 239 conversions
    from: obj.should
      to: expect(obj).to

* 113 conversions
    from: obj.stub(:message)
      to: allow(obj).to receive(:message)

* 94 conversions
    from: obj.should_not_receive(:message)
      to: expect(obj).not_to receive(:message)

* 86 conversions
    from: == expected
      to: eq(expected)

* 16 conversions
    from: obj.stub(:message => value)
      to: allow(obj).to receive(:message).and_return(value)

* 16 conversions
    from: stub('something')
      to: double('something')

* 15 conversions
    from: be_true
      to: be_truthy

* 15 conversions
    from: obj.stub!(:message)
      to: allow(obj).to receive(:message)

* 13 conversions
    from: mock('something')
      to: double('something')

* 10 conversions
    from: lambda { }.should_not
      to: expect { }.not_to

* 10 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 7 conversions
    from: be_false
      to: be_falsey

* 7 conversions
    from: obj.unstub(:message)
      to: allow(obj).to receive(:message).and_call_original

* 5 conversions
    from: pending
      to: skip

* 4 conversions
    from: lambda { }.should
      to: expect { }.to

* 4 conversions
    from: obj.should_receive(:message).any_number_of_times
      to: allow(obj).to receive(:message)

* 3 conversions
    from: collection.should have(n).items
      to: expect(collection.size).to eq(n)

* 1 conversion
    from: RSpec.configure { |c| c.color_enabled = something }
      to: RSpec.configure { |c| c.color = something }

* 1 conversion
    from: it { should ... }
      to: it { is_expected.to ... }

* 1 conversion
    from: it { should_not ... }
      to: it { is_expected.not_to ... }

For more details: https://github.com/yujinakayama/transpec#supported-conversions
  • Loading branch information
yujinakayama committed Jan 21, 2018
1 parent cd9aeb0 commit c756ab8
Show file tree
Hide file tree
Showing 33 changed files with 940 additions and 940 deletions.
48 changes: 24 additions & 24 deletions spec/guard/cli_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
let(:ui) { Guard::UI }

describe '#start' do
before { Guard.stub(:start) }
before { allow(Guard).to receive(:start) }

it 'delegates to Guard.start' do
guard.should_receive(:start)
expect(guard).to receive(:start)
subject.start
end

context 'with a Gemfile in the project dir' do
before do
File.stub(:exists?).with('Gemfile').and_return true
allow(File).to receive(:exists?).with('Gemfile').and_return true
end

context 'when running with Bundler' do
Expand All @@ -27,7 +27,7 @@
after { ENV['BUNDLE_GEMFILE'] = @bundler_env }

it 'does not show the Bundler warning' do
ui.should_not_receive(:info).with(/Guard here!/)
expect(ui).not_to receive(:info).with(/Guard here!/)
subject.start
end
end
Expand All @@ -41,12 +41,12 @@
after { ENV['BUNDLE_GEMFILE'] = @bundler_env }

it 'does show the Bundler warning' do
ui.should_receive(:info).with(/Guard here!/)
expect(ui).to receive(:info).with(/Guard here!/)
subject.start
end

it 'does not show the Bundler warning with the :no_bundler_warning flag' do
ui.should_not_receive(:info).with(/Guard here!/)
expect(ui).not_to receive(:info).with(/Guard here!/)
subject.options = { :no_bundler_warning => true }
subject.start
end
Expand All @@ -55,30 +55,30 @@

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

after { ENV['BUNDLE_GEMFILE'] = @bundler_env }

it 'does not show the Bundler warning' do
ui.should_not_receive(:info).with(/Guard here!/)
expect(ui).not_to receive(:info).with(/Guard here!/)
subject.start
end
end
end

describe '#list' do
it 'outputs the Guard::DslDescriber.list result' do
::Guard::DslDescriber.should_receive(:list)
expect(::Guard::DslDescriber).to receive(:list)
subject.list
end
end

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
end
Expand All @@ -87,31 +87,31 @@
let(:options) { { :bare => false } }

before do
subject.stub(:options => options)
Guard::Guardfile.stub(:create_guardfile)
Guard::Guardfile.stub(:initialize_all_templates)
allow(subject).to receive(:options).and_return(options)
allow(Guard::Guardfile).to receive(:create_guardfile)
allow(Guard::Guardfile).to receive(:initialize_all_templates)
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
end
Expand All @@ -120,9 +120,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).not_to receive(:initialize_template)
expect(Guard::Guardfile).not_to receive(:initialize_all_templates)

subject.init
end
Expand All @@ -137,7 +137,7 @@
after { ENV['BUNDLE_GEMFILE'] = @bundler_env }

it 'does not show the Bundler warning' do
ui.should_not_receive(:info).with(/Guard here!/)
expect(ui).not_to receive(:info).with(/Guard here!/)
subject.init
end
end
Expand All @@ -151,15 +151,15 @@
after { ENV['BUNDLE_GEMFILE'] = @bundler_env }

it 'does not show the Bundler warning' do
ui.should_receive(:info).with(/Guard here!/)
expect(ui).to receive(:info).with(/Guard here!/)
subject.init
end
end
end

describe '#show' do
it 'outputs the Guard::DslDescriber.list result' do
::Guard::DslDescriber.should_receive(:list)
expect(::Guard::DslDescriber).to receive(:list)
subject.list
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/guard/commands/all_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,37 @@
let(:bar_guard) { guard.add_guard(:bar, [], [], { :group => :foo }) }

before do
Guard.stub(:run_all)
Guard.stub(:setup_interactor)
Pry.output.stub(:puts)
allow(Guard).to receive(:run_all)
allow(Guard).to receive(:setup_interactor)
allow(Pry.output).to receive(:puts)
stub_const 'Guard::Bar', Class.new(Guard::Guard)
end

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).not_to receive(:run_all)
Pry.run_command 'all baz'
end
end
Expand Down
10 changes: 5 additions & 5 deletions spec/guard/commands/change_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,28 @@
let!(:guard) { ::Guard.setup }

before do
Guard.runner.stub(:run_on_changes)
Pry.output.stub(:puts)
allow(Guard.runner).to receive(:run_on_changes)
allow(Pry.output).to receive(:puts)
end

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).not_to receive(:run_on_changes)
Pry.run_command 'change'
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/guard/commands/notification_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
describe 'Guard::Interactor::NOTIFICATION' do

before do
::Guard::Notifier.stub(:toggle)
allow(::Guard::Notifier).to receive(:toggle)
end

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
Expand Down
4 changes: 2 additions & 2 deletions spec/guard/commands/pause_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
describe 'Guard::Interactor::PAUSE' do

before do
::Guard::stub(:pause)
allow(::Guard)::to receive(:pause)
end

describe '#perform' do
it 'pauses Guard' do
::Guard.should_receive(:pause)
expect(::Guard).to receive(:pause)
Pry.run_command 'pause'
end
end
Expand Down
14 changes: 7 additions & 7 deletions spec/guard/commands/reload_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
describe 'Guard::Interactor::RELOAD' do

before do
Guard.stub(:reload)
Guard.stub(:setup_interactor)
Pry.output.stub(:puts)
allow(Guard).to receive(:reload)
allow(Guard).to receive(:setup_interactor)
allow(Pry.output).to receive(:puts)
stub_const 'Guard::Bar', Class.new(Guard::Guard)
end

Expand All @@ -16,28 +16,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).not_to receive(:reload)
Pry.run_command 'reload baz'
end
end
Expand Down
16 changes: 8 additions & 8 deletions spec/guard/commands/scope_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
describe 'Guard::Interactor::SCOPE' do

before do
Guard.stub(:scope=)
Guard.stub(:setup_interactor)
Pry.output.stub(:puts => true)
allow(Guard).to receive(:scope=)
allow(Guard).to receive(:setup_interactor)
allow(Pry.output).to receive(:puts).and_return(true)
stub_const 'Guard::Bar', Class.new(Guard::Guard)
end

Expand All @@ -16,29 +16,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 <scope>'
expect(Guard).not_to receive(:scope=)
expect(Pry.output).to receive(:puts).with 'Usage: scope <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).not_to receive(:scope=)
Pry.run_command 'scope baz'
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/guard/commands/show_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit c756ab8

Please sign in to comment.