Skip to content

Instantly share code, notes, and snippets.

@camelpunch
Created July 22, 2010 08:35
Show Gist options
  • Save camelpunch/485734 to your computer and use it in GitHub Desktop.
Save camelpunch/485734 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe Invoice do
describe "scopes" do
subject { @invoices }
describe "arrears" do
before :all do
@tutorial_passed_1 = Tutorial.make :starts_at => 2.seconds.ago
@tutorial_passed_2 = Tutorial.make :starts_at => 1.second.ago
@tutorial_not_passed_1 = Tutorial.make :starts_at => 1.hour.from_now
@tutorial_not_passed_2 = Tutorial.make :starts_at => 2.hours.from_now
@paid_invoice_with_past_tutorial =
Invoice.make(:paid_on => 2.days.ago,
:student_tutorials => [@tutorial_passed_2])
@unpaid_invoice_with_past_tutorial =
Invoice.make(:student_tutorials => [@tutorial_passed_1])
@paid_invoice_with_future_tutorial =
Invoice.make(:paid_on => 1.second.ago,
:student_tutorials => [@tutorial_not_passed_1])
@unpaid_invoice_with_future_tutorial =
Invoice.make(:student_tutorials => [@tutorial_not_passed_2])
@invoice_without_tutorial = Invoice.make
@invoices = Invoice.arrears
end
it { should_not include(@invoice_without_tutorial) }
it { should_not include(@paid_invoice_with_future_tutorial) }
it { should_not include(@unpaid_invoice_with_future_tutorial) }
it { should_not include(@paid_invoice_with_past_tutorial) }
it { should include(@unpaid_invoice_with_past_tutorial) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment