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.0.3 with the following command:
    transpec

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

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

* 3 conversions
    from: be_true
      to: be_truthy

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

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

* 1 conversion
    from: be_false
      to: be_falsey

* 1 conversion
    from: collection.should have(n).items
      to: expect(collection.size).to eq(n)

For more details: https://github.com/yujinakayama/transpec#supported-conversions
  • Loading branch information
e2 committed Dec 20, 2014
1 parent 6be5f2b commit 074fb34
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 51 deletions.
8 changes: 4 additions & 4 deletions spec/guard/haml/notifier_spec.rb
Expand Up @@ -3,18 +3,18 @@

describe '#image' do
context 'when recieves true' do
specify { subject.image(true).should be :success }
specify { expect(subject.image(true)).to be :success }
end

context 'when recieves false' do
specify { subject.image(false).should be :failed }
specify { expect(subject.image(false)).to be :failed }
end
end

describe '#notify' do
context 'when recieves true with message' do
it 'should call Guard::Notifier with success image' do
::Guard::Notifier.should_receive(:notify).with(
expect(::Guard::Notifier).to receive(:notify).with(
'Successful compilation!',
title: 'Guard::Haml',
image: :success
Expand All @@ -25,7 +25,7 @@

context 'when recieves false with message' do
it 'should call Guard::Notifier with failed image' do
::Guard::Notifier.should_receive(:notify).with(
expect(::Guard::Notifier).to receive(:notify).with(
'Compilation failed!',
title: 'Guard::Haml',
image: :failed
Expand Down
94 changes: 47 additions & 47 deletions spec/guard/haml_spec.rb
Expand Up @@ -11,37 +11,37 @@

describe '#new' do
context 'notifications option by default' do
specify { subject.options[:notifications].should be_true }
specify { expect(subject.options[:notifications]).to be_truthy }
end

context "when receives options hash" do
it 'should merge it to @options instance variable' do
subject_with_options.options[:notifications].should be_false
subject_with_options.options[:run_at_start].should be_true
expect(subject_with_options.options[:notifications]).to be_falsey
expect(subject_with_options.options[:run_at_start]).to be_truthy
end
end

context 'with no watchers and the :input option' do
let(:plugin) { described_class.new(input: 'markup') }

it 'generates watchers automatically' do
plugin.watchers.should have(1).item
plugin.watchers[0].pattern.should eq %r{^markup/([\w\-_]+(\.html)?\.haml)$}
expect(plugin.watchers.size).to eq(1)
expect(plugin.watchers[0].pattern).to eq %r{^markup/([\w\-_]+(\.html)?\.haml)$}
end
end
end

describe '#start' do
context 'by default' do
it 'should not call #run_all' do
subject.should_not_receive(:run_all)
expect(subject).not_to receive(:run_all)
subject.start
end
end

context 'when run_on_start option set to true' do
it 'should call #run_all' do
subject_with_options.should_receive(:run_all)
expect(subject_with_options).to receive(:run_all)
subject_with_options.start
end
end
Expand All @@ -52,46 +52,46 @@
end

it 'should not call #run_all' do
subject.should_not_receive(:run_all)
expect(subject).not_to receive(:run_all)
subject.start
end
end
end

describe '#stop' do
specify { subject.stop.should be_true }
specify { expect(subject.stop).to be_truthy }
end

describe '#reload' do
it 'should call #run_all' do
subject.should_receive(:run_all).and_return(true)
expect(subject).to receive(:run_all).and_return(true)
subject.reload
end
end

describe '#run_all' do
it 'should rebuild all files being watched' do
Guard::Haml.stub(:run_on_change).with([]).and_return([])
Guard.stub(:guards).and_return([subject])
allow(Guard::Haml).to receive(:run_on_change).with([]).and_return([])
allow(Guard).to receive(:guards).and_return([subject])
subject.run_all
end
end

describe '#_output_paths' do
context 'by default' do
it 'should return test/index.html.haml as [test/index.html]' do
subject.send(:_output_paths, 'test/index.html.haml').
should eq(['test/index.html'])
expect(subject.send(:_output_paths, 'test/index.html.haml')).
to eq(['test/index.html'])
end

it 'should return test/index.htm.haml as [test/index.htm]' do
subject.send(:_output_paths, 'test/index.htm.haml').
should eq(['test/index.htm'])
expect(subject.send(:_output_paths, 'test/index.htm.haml')).
to eq(['test/index.htm'])
end

it 'should return test/index.haml as [test/index.html]' do
subject.send(:_output_paths, 'test/index.haml').
should eq(['test/index.html'])
expect(subject.send(:_output_paths, 'test/index.haml')).
to eq(['test/index.html'])
end
end

Expand All @@ -101,8 +101,8 @@
end

it 'should return test/index.html.haml as [demo/output/test/index.html.haml]' do
subject.send(:_output_paths, 'test/index.html.haml').
should eq(['demo/output/test/index.html'])
expect(subject.send(:_output_paths, 'test/index.html.haml')).
to eq(['demo/output/test/index.html'])
end
end

Expand All @@ -112,8 +112,8 @@
end

it 'should return test/index.html.haml as [demo1/output/test/index.html.haml, demo2/output/test/index.html.haml]' do
subject.send(:_output_paths, 'test/index.html.haml').
should eq(['demo1/output/test/index.html', 'demo2/output/test/index.html'])
expect(subject.send(:_output_paths, 'test/index.html.haml')).
to eq(['demo1/output/test/index.html', 'demo2/output/test/index.html'])
end
end

Expand All @@ -123,13 +123,13 @@
end

it 'should return test/index.haml as test/index.txt' do
subject.send(:_output_paths, 'test/index.haml').
should eq(['test/index.txt'])
expect(subject.send(:_output_paths, 'test/index.haml')).
to eq(['test/index.txt'])
end

it 'should return test/index.php.haml as test/index.php due to the second extension' do
subject.send(:_output_paths, 'test/index.php.haml').
should eq(['test/index.php'])
expect(subject.send(:_output_paths, 'test/index.php.haml')).
to eq(['test/index.php'])
end
end

Expand All @@ -139,8 +139,8 @@
end

it 'should return test/ignore/index.html.haml as [index.html]' do
subject.send(:_output_paths, 'test/ignore/index.html.haml').
should eq(['index.html'])
expect(subject.send(:_output_paths, 'test/ignore/index.html.haml')).
to eq(['index.html'])
end

context 'when the output option is set to "demo/output"' do
Expand All @@ -149,46 +149,46 @@
end

it 'should return test/ignore/abc/index.html.haml as [demo/output/abc/index.html]' do
subject.send(:_output_paths, 'test/ignore/abc/index.html.haml').
should eq(['demo/output/abc/index.html'])
expect(subject.send(:_output_paths, 'test/ignore/abc/index.html.haml')).
to eq(['demo/output/abc/index.html'])
end
end
end

context 'when the input file contains a second extension"' do
it 'should return test/index.php.haml as [test/index.php]' do
subject.send(:_output_paths, 'test/index.php.haml').
should eq(['test/index.php'])
expect(subject.send(:_output_paths, 'test/index.php.haml')).
to eq(['test/index.php'])
end
end
end

describe '#_output_filename' do
context 'by default (if a ".haml" extension has been defined)' do
it 'should return the file name with the default extension ".html"' do
subject.send(:_output_filename, 'test/index.haml').
should eq('index.html')
expect(subject.send(:_output_filename, 'test/index.haml')).
to eq('index.html')
end
end

context 'if no extension has been defined at all' do
it 'should return the file name with the default extension ".html"' do
subject.send(:_output_filename, 'test/index').
should eq('index.html')
expect(subject.send(:_output_filename, 'test/index')).
to eq('index.html')
end
end

context 'if an extension other than ".haml" has been defined' do
it 'should return the file name with the default extension ".html"' do
subject.send(:_output_filename, 'test/index.foo').
should eq('index.foo.html')
expect(subject.send(:_output_filename, 'test/index.foo')).
to eq('index.foo.html')
end
end

context 'if multiple extensions including ".haml" have been defined' do
it 'should return the file name with the extension second to last' do
subject.send(:_output_filename, 'test/index.foo.haml').
should eq('index.foo')
expect(subject.send(:_output_filename, 'test/index.foo.haml')).
to eq('index.foo')
end
end
end
Expand All @@ -204,21 +204,21 @@

it 'should call Notifier.notify with 1 output' do
message = success_message + "# spec/fixtures/test.html.haml -> spec/fixtures/test.html"
notifier.should_receive(:notify).with(true, message)
expect(notifier).to receive(:notify).with(true, message)
subject_notifiable.run_on_changes(["#{@fixture_path}/test.html.haml"])
end
end

it 'should call Notifier.notify' do
message = "Successfully compiled haml to html!\n"
message += "# spec/fixtures/test.html.haml -> spec/fixtures/test.html"
notifier.should_receive(:notify).with(true, message)
expect(notifier).to receive(:notify).with(true, message)
subject_notifiable.run_on_changes(["#{@fixture_path}/test.html.haml"])
end

context 'with two outputs' do
before do
subject_notifiable.stub(:_output_paths).and_return(["#{@fixture_path}/test.html", "#{@fixture_path}/test2.html"])
allow(subject_notifiable).to receive(:_output_paths).and_return(["#{@fixture_path}/test.html", "#{@fixture_path}/test2.html"])
end

after do
Expand All @@ -228,7 +228,7 @@

it 'should call Notifier.notify with 2 outputs' do
message = success_message + "# spec/fixtures/test.html.haml -> spec/fixtures/test.html, spec/fixtures/test2.html"
notifier.should_receive(:notify).with(true, message)
expect(notifier).to receive(:notify).with(true, message)
subject_notifiable.run_on_changes(["#{@fixture_path}/test.html.haml"])
end
end
Expand All @@ -245,10 +245,10 @@
it 'should call Notifier.notify when an error occurs' do
message = "HAML compilation of #{@fixture_path}/fail_test.html.haml failed!\n"
message += "Error: Illegal nesting: content can't be both given on the same line as %p and nested within it."
notifier.should_receive(:notify).with(false, message)
catch(:task_has_failed) do
expect(notifier).to receive(:notify).with(false, message)
expect(catch(:task_has_failed) do
subject_notifiable.send(:compile_haml, "#{@fixture_path}/fail_test.html.haml")
end.should be_nil
end).to be_nil

end
end
Expand Down

0 comments on commit 074fb34

Please sign in to comment.