Note that there are some explanatory texts on larger screens.

plurals
  1. PORspec no Method error assignment
    text
    copied!<p>I apparently added a new field to my Customer model known as ct_ratio before running tests. When I now run tests on my invoice spec, they fail with a "No method error,ct_ratio="</p> <p>Customer.rb</p> <pre><code>class Customer &lt; ActiveRecord::Base attr_accessible :billing_address, :customer_currency, :email, :first_name, :last_name, :mobile, :name, :payment_terms, :phase_type, :readings_attributes, :pays_vat, :ct_ratio before_validation do self.ct_ratio ||= 1 end end </code></pre> <p>Invoice_spec</p> <pre><code>describe Invoice do context 'create_item_from_readings' do before :each do @customer = FactoryGirl.create :customer @reading1 = @customer.readings.create! reading1: 100, date_of_reading: 30.days.ago @reading2 = @customer.readings.create! reading1: 200, date_of_reading: 20.days.ago @reading3 = @customer.readings.create! reading1: 500, date_of_reading: 10.days.ago @customer.stub(:unit_cost).and_return(100) end it "should create an invoice item for all reading" do invoice = Invoice.new customer: @customer, invoice_date: 15.days.ago, due_date: Date.today item = invoice.create_item_from_readings item.rate.should == 100 item.amount.should == 100 * 100 item.description.should == "Electricity used from #{@reading1.date_of_reading.strftime('%d/%m/%Y')} to #{@reading2.date_of_reading.strftime('%d/%m/%Y')} - 100 units" end </code></pre> <p>I added ct_ratio to Factory Girl</p> <pre><code>require 'factory_girl' FactoryGirl.define do factory :customer do name 'Test Test' first_name "Test" last_name "Test" mobile "00000000" billing_address "Kampala" payment_terms "Immediate" phase_type "Single Phase" customer_currency "UGX" pays_vat false email "test@test.com" ct_ratio 1 end factory :reading do |f| f.reading1 100 f.reading2 150 f.reading3 200 f.date_of_reading 30.days.ago end end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload