From 54bdcf7679e0a26db10896bb7748ec80148ddd58 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 29 May 2018 16:53:18 +1000 Subject: [PATCH] Convert specs to RSpec 3.7.0 syntax with Transpec This conversion is done by Transpec 3.3.0 with the following command: transpec spec/lib/open_food_network/xero_invoices_report_spec.rb * 15 conversions from: obj.stub(:message) to: allow(obj).to receive(:message) * 10 conversions from: obj.should to: expect(obj).to * 4 conversions from: == expected to: eq(expected) * 3 conversions from: obj.should_not to: expect(obj).not_to For more details: https://github.com/yujinakayama/transpec#supported-conversions --- .../xero_invoices_report_spec.rb | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/spec/lib/open_food_network/xero_invoices_report_spec.rb b/spec/lib/open_food_network/xero_invoices_report_spec.rb index a8c45bd7d7..d119d26964 100644 --- a/spec/lib/open_food_network/xero_invoices_report_spec.rb +++ b/spec/lib/open_food_network/xero_invoices_report_spec.rb @@ -13,10 +13,10 @@ module OpenFoodNetwork around { |example| Timecop.travel(Time.zone.local(2015, 5, 5, 14, 0, 0)) { example.run } } it "uses defaults when blank params are passed" do - report.instance_variable_get(:@opts).should == {invoice_date: Date.civil(2015, 5, 5), + expect(report.instance_variable_get(:@opts)).to eq({invoice_date: Date.civil(2015, 5, 5), due_date: Date.civil(2015, 6, 5), account_code: 'food sales', - report_type: 'summary'} + report_type: 'summary'}) end end @@ -26,53 +26,53 @@ module OpenFoodNetwork let(:summary_rows) { report.send(:summary_rows_for_order, order, 1, {}) } before do - report.stub(:produce_summary_rows) { ['produce'] } - report.stub(:fee_summary_rows) { ['fee'] } - report.stub(:shipping_summary_rows) { ['shipping'] } - report.stub(:payment_summary_rows) { ['payment'] } - report.stub(:admin_adjustment_summary_rows) { ['admin'] } - order.stub(:account_invoice?) { false } + allow(report).to receive(:produce_summary_rows) { ['produce'] } + allow(report).to receive(:fee_summary_rows) { ['fee'] } + allow(report).to receive(:shipping_summary_rows) { ['shipping'] } + allow(report).to receive(:payment_summary_rows) { ['payment'] } + allow(report).to receive(:admin_adjustment_summary_rows) { ['admin'] } + allow(order).to receive(:account_invoice?) { false } end it "displays produce summary rows when summary report" do - report.stub(:detail?) { false } - summary_rows.should include 'produce' + allow(report).to receive(:detail?) { false } + expect(summary_rows).to include 'produce' end it "does not display produce summary rows when detail report" do - report.stub(:detail?) { true } - summary_rows.should_not include 'produce' + allow(report).to receive(:detail?) { true } + expect(summary_rows).not_to include 'produce' end it "displays fee summary rows when summary report" do - report.stub(:detail?) { false } - order.stub(:account_invoice?) { true } - summary_rows.should include 'fee' + allow(report).to receive(:detail?) { false } + allow(order).to receive(:account_invoice?) { true } + expect(summary_rows).to include 'fee' end it "displays fee summary rows when this is not an account invoice" do - report.stub(:detail?) { true } - order.stub(:account_invoice?) { false } - summary_rows.should include 'fee' + allow(report).to receive(:detail?) { true } + allow(order).to receive(:account_invoice?) { false } + expect(summary_rows).to include 'fee' end it "does not display fee summary rows when this is a detail report for an account invoice" do - report.stub(:detail?) { true } - order.stub(:account_invoice?) { true } - summary_rows.should_not include 'fee' + allow(report).to receive(:detail?) { true } + allow(order).to receive(:account_invoice?) { true } + expect(summary_rows).not_to include 'fee' end it "always displays shipping summary rows" do - summary_rows.should include 'shipping' + expect(summary_rows).to include 'shipping' end it "displays admin adjustment summary rows when summary report" do - summary_rows.should include 'admin' + expect(summary_rows).to include 'admin' end it "does not display admin adjustment summary rows when detail report" do - report.stub(:detail?) { true } - summary_rows.should_not include 'admin' + allow(report).to receive(:detail?) { true } + expect(summary_rows).not_to include 'admin' end end @@ -85,12 +85,12 @@ module OpenFoodNetwork let!(:adj_shipping) { create(:adjustment, adjustable: order, label: "Shipping", originator: shipping_method) } it "returns BillablePeriod adjustments only" do - report.send(:account_invoice_adjustments, order).should == [adj_invoice] + expect(report.send(:account_invoice_adjustments, order)).to eq([adj_invoice]) end it "excludes adjustments where the source is missing" do billable_period.destroy - report.send(:account_invoice_adjustments, order).should be_empty + expect(report.send(:account_invoice_adjustments, order)).to be_empty end end @@ -99,7 +99,7 @@ module OpenFoodNetwork describe "when no initial invoice number is given" do it "returns the order number" do - subject.send(:invoice_number_for, order, 123).should == 'R731032860' + expect(subject.send(:invoice_number_for, order, 123)).to eq('R731032860') end end @@ -107,7 +107,7 @@ module OpenFoodNetwork subject { XeroInvoicesReport.new user, {initial_invoice_number: '123'} } it "increments the number by the index" do - subject.send(:invoice_number_for, order, 456).should == 579 + expect(subject.send(:invoice_number_for, order, 456)).to eq(579) end end end