From 5b7a7ac200822d4578fcba95ce2a539a3f6158e7 Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Thu, 12 Jun 2014 16:02:42 +0200 Subject: [PATCH] Convert specs to RSpec 2.99.0 syntax with Transpec This conversion is done by Transpec 1.12.0 with the following command: transpec * 23 conversions from: obj.should to: expect(obj).to * 17 conversions from: == expected to: eq(expected) * 5 conversions from: obj.should_not to: expect(obj).not_to * 4 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 3 conversions from: pending to: skip * 2 conversions from: > expected to: be > expected * 1 conversion from: pending 'is an example' { } to: skip 'is an example' { } --- spec/lib/spreadsheet_builder_spec.rb | 32 +++++++++---------- .../cost_reports_controller_patch_spec.rb | 12 +++---- .../work_packages_controller_patch_spec.rb | 28 ++++++++-------- 3 files changed, 36 insertions(+), 36 deletions(-) diff --git a/spec/lib/spreadsheet_builder_spec.rb b/spec/lib/spreadsheet_builder_spec.rb index bf24a80aa8..82bf1fd379 100644 --- a/spec/lib/spreadsheet_builder_spec.rb +++ b/spec/lib/spreadsheet_builder_spec.rb @@ -8,78 +8,78 @@ describe "SpreadsheetBuilder" do it "should add a single title in the first row" do @spreadsheet.add_title("A fancy title") - @sheet.last_row_index.should == 0 + expect(@sheet.last_row_index).to eq(0) end it "should add the title complety in the first cell" do title = "A fancy title" @spreadsheet.add_title(title) - @sheet.last_row[0].should == title - @sheet.last_row[1].should == nil + expect(@sheet.last_row[0]).to eq(title) + expect(@sheet.last_row[1]).to eq(nil) end it "should overwrite titles in consecutive calls" do title = "A fancy title" @spreadsheet.add_title(title) @spreadsheet.add_title(title) - @sheet.last_row_index.should == 0 + expect(@sheet.last_row_index).to eq(0) end it "should do some formatting on the title" do @spreadsheet.add_title("A fancy title") - @sheet.last_row.format(0).should_not == @sheet.last_row.format(1) + expect(@sheet.last_row.format(0)).not_to eq(@sheet.last_row.format(1)) end it "should add empty rows starting in the second line" do @spreadsheet.add_empty_row - @sheet.last_row_index.should == 1 + expect(@sheet.last_row_index).to eq(1) end it "should add empty rows at the next sequential row" do @spreadsheet.add_empty_row first = @sheet.last_row_index @spreadsheet.add_empty_row - @sheet.last_row_index.should == (first + 1) + expect(@sheet.last_row_index).to eq(first + 1) end it "should add headers in the second line per default" do @spreadsheet.add_headers((1..3).to_a) - @sheet.last_row_index.should == 1 + expect(@sheet.last_row_index).to eq(1) end it "should allow adding headers in the first line" do @spreadsheet.add_headers((1..3).to_a, 0) - @sheet.last_row_index.should == 0 + expect(@sheet.last_row_index).to eq(0) end it "should add headers with some formatting" do @spreadsheet.add_headers([1], 0) - @sheet.last_row.format(0).should_not == @sheet.last_row.format(2) + expect(@sheet.last_row.format(0)).not_to eq(@sheet.last_row.format(2)) end it "should start adding rows in the first line" do @spreadsheet.add_row((1..3).to_a) - @sheet.last_row_index.should == 1 + expect(@sheet.last_row_index).to eq(1) end it "should add rows sequentially" do @spreadsheet.add_row((1..3).to_a) first = @sheet.last_row_index @spreadsheet.add_row((1..3).to_a) - @sheet.last_row_index.should == (first + 1) + expect(@sheet.last_row_index).to eq(first + 1) end it "should apply no formatting on rows" do @spreadsheet.add_row([1]) - @sheet.last_row.format(0).should == @sheet.last_row.format(1) + expect(@sheet.last_row.format(0)).to eq(@sheet.last_row.format(1)) end it "should always use unix newlines" do @spreadsheet.add_row(["Some text including a windows newline (\r\n)", "And an old-style mac os newline (\r)"]) 2.times do |i| - @spreadsheet.send("raw_sheet").last_row[i].should_not include("\r") - @spreadsheet.send("raw_sheet").last_row[i].should_not include("\r\n") - @spreadsheet.send("raw_sheet").last_row[i].should include("\n") + expect(@spreadsheet.send("raw_sheet").last_row[i]).not_to include("\r") + expect(@spreadsheet.send("raw_sheet").last_row[i]).not_to include("\r\n") + expect(@spreadsheet.send("raw_sheet").last_row[i]).to include("\n") end end end \ No newline at end of file diff --git a/spec/patches/cost_reports_controller_patch_spec.rb b/spec/patches/cost_reports_controller_patch_spec.rb index 27fb9fa508..ead956322b 100644 --- a/spec/patches/cost_reports_controller_patch_spec.rb +++ b/spec/patches/cost_reports_controller_patch_spec.rb @@ -1,22 +1,22 @@ require 'spec_helper' describe 'CostReportsController', "rendering to xls" do - pending 'XlsExport: CostReports support not yet migrated to Rails 3' + skip 'XlsExport: CostReports support not yet migrated to Rails 3' it "should respond with the xls if requested in the index" do - pending + skip render :action => :index - response.should be_redirect + expect(response).to be_redirect end it "should not respond with the xls if requested in a detail view" do - pending + skip render :action => :show - response.should be_redirect + expect(response).to be_redirect end it "should generate xls from issues" do - pending + skip end end diff --git a/spec/patches/work_packages_controller_patch_spec.rb b/spec/patches/work_packages_controller_patch_spec.rb index fb75ebbaa3..650581186e 100644 --- a/spec/patches/work_packages_controller_patch_spec.rb +++ b/spec/patches/work_packages_controller_patch_spec.rb @@ -6,7 +6,7 @@ describe WorkPackagesController, "rendering to xls", :type => :controller do :description => '!DESCRIPTION!') } before do - User.stub(:current).and_return current_user + allow(User).to receive(:current).and_return current_user end describe "should respond with the xls if requested in the index" do @@ -15,23 +15,23 @@ describe WorkPackagesController, "rendering to xls", :type => :controller do end it 'should respond with 200 OK' do - response.response_code.should == 200 + expect(response.response_code).to eq(200) end it 'should have a length > 100 bytes' do - response.body.length.should > 100 + expect(response.body.length).to be > 100 end it 'should not contain a description' do - response.body.should_not include('!DESCRIPTION!') + expect(response.body).not_to include('!DESCRIPTION!') end it 'should contain a subject' do - response.body.should include('!SUBJECT!') + expect(response.body).to include('!SUBJECT!') end context 'the mime type' do - it { response.header['Content-Type'].should == 'application/vnd.ms-excel' } + it { expect(response.header['Content-Type']).to eq('application/vnd.ms-excel') } end end @@ -56,15 +56,15 @@ describe WorkPackagesController, "rendering to xls", :type => :controller do end before do - OpenProject::XlsExport::Formatters::TimeFormatter.stub(:apply?) do |column| + allow(OpenProject::XlsExport::Formatters::TimeFormatter).to receive(:apply?) do |column| column.caption =~ /time/i end - OpenProject::XlsExport::Formatters::CostFormatter.stub(:apply?) do |column| + allow(OpenProject::XlsExport::Formatters::CostFormatter).to receive(:apply?) do |column| column.caption =~ /cost/i end - Setting.stub(:plugin_openproject_costs).and_return({ 'costs_currency' => 'EUR','costs_currency_format' => '%n %u' }) + allow(Setting).to receive(:plugin_openproject_costs).and_return({ 'costs_currency' => 'EUR','costs_currency_format' => '%n %u' }) get 'index', :format => 'xls', @@ -113,23 +113,23 @@ describe WorkPackagesController, "rendering to xls", :type => :controller do end it 'should respond with 200 OK' do - response.response_code.should == 200 + expect(response.response_code).to eq(200) end it 'should have a length > 100 bytes' do - response.body.length.should > 100 + expect(response.body.length).to be > 100 end it 'should contain a description' do - response.body.should include('!DESCRIPTION!') + expect(response.body).to include('!DESCRIPTION!') end it 'should contain a subject' do - response.body.should include('!SUBJECT!') + expect(response.body).to include('!SUBJECT!') end context 'the mime type' do - it { response.header['Content-Type'].should == 'application/vnd.ms-excel' } + it { expect(response.header['Content-Type']).to eq('application/vnd.ms-excel') } end end