0

我有一个 rspec 文件,看起来它缺少两个“末端”,但是当我把这些末端放在上面时,我的测试会抛出一个错误“意外结束”......这是文件:

require File.dirname(__FILE__) + '/../spec_helper'

describe Invoice do

  describe 'creation' do

    before(:each) do
      @invoice = FactoryGirl.build(:invoice)
    end

    it 'is invalid without a user'  do
      invoice = @invoice
      invoice.user = nil
      invoice.should_not be_valid
    end

    it 'is invalid without a client'  do
      invoice = @invoice
      invoice.client = nil
      invoice.should_not be_valid
    end

    it 'is invalid without a public_id'  do
      invoice = @invoice
      invoice.public_id = nil
      invoice.should_not be_valid
    end

    it 'is invalid without a payment_term'  do
      invoice = @invoice
      invoice.payment_term = nil
      invoice.should_not be_valid
    end

    it 'is invalid without an issue_date'  do
      invoice = @invoice
      invoice.issue_date = nil
      invoice.should_not be_valid
    end

    it 'is invalid without a client_invoice_id'  do
      invoice = @invoice
      invoice.client_invoice_id = nil
      invoice.should_not be_valid
    end
  end

  describe 'method has_payment_date?' do

    it "should return true when payment_term is not 'None'"
      @invoice = FactoryGirl.build(:invoice)
      @invoice.payment_term = "Net 15"
      @invoice.has_payment_date?.should == true
    end

    it "should return false when payment_term is 'None'"
      @invoice = FactoryGirl.build(:invoice)
      @invoice.payment_term = "Net 15"
      @invoice.has_payment_date?.should == true
    end

现在看来上面的代码缺少两个“结束”但是当它像这样时它通过并且当我把结束放回去时抛出一个错误。我错过了什么?

4

1 回答 1

0

您在最后两个示例中缺少两个“do”,在“Invoice”和“method has_payment_date?”中缺少两个“end”。描述。

于 2013-04-13T23:18:33.570 回答