Skip to content

Instantly share code, notes, and snippets.

@ashmoran
Created December 16, 2011 16:45
Show Gist options
  • Save ashmoran/1486811 to your computer and use it in GitHub Desktop.
Save ashmoran/1486811 to your computer and use it in GitHub Desktop.
Nesting contexts to build up a "when"
describe "#current_report" do
its(:current_report) { should be == report }
context "with a new" do
let(:new_report) { Report.make(state: new_report_state, project_date: new_report_date) }
before(:each) do
subject.reports << new_report
end
context "published" do
let(:new_report_state) { :published }
context "more recent report" do
let(:new_report_date) { Date.today + 1 }
its(:current_report) { should be == new_report }
end
context "older report" do
let(:new_report_date) { Date.today - 1 }
its(:current_report) { should be == report }
end
end
context "unpublished more recent report" do
let(:new_report_state) { :approved }
let(:new_report_date) { Date.today + 1 }
its(:current_report) { should be == report }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment