Create a gist now

Instantly share code, notes, and snippets.

@bogdan /source_spec.rb Secret
Created Apr 23, 2011

shared_examples_for "Traits::Tracker::Source" do
describe "as Traits::Tracker::Source" do
context "after #save!" do
before(:each) do
subject.stub!(:issue_options).and_return({"a" => "b"})
subject.save!
end
let(:issue) { subject.current_issue }
it { issue.should be_new}
it { issue.options["a"].should == "b"}
it { should be_blocked }
context "if it's issue proccessed by andrew" do
let(:andrew) do
Factory.create(:user)
end
before(:each) do
issue.proccess_by!(andrew)
end
it { should be_blocked }
context "after issue approval" do
before(:each) do
issue.approve!
end
it { should_not be_blocked }
end
context "if it's issue has been declined" do
enable_test_mail_delivery
before(:each) do
issue.body = "No reason decline"
issue.decline!
end
it { should_not be_blocked }
end
end
end
context "on after_create" do
before(:each) do
subject.save!
end
it "should have an issue" do
subject.issues.should_not be_empty
end
context "on second #save!" do
before(:each) do
subject.save!
end
it "should not have second issue" do
subject.issues(true).size.should == 1
end
context "and issue is approved" do
before(:each) do
subject.current_issue.proccess_by!(Factory.create(:user))
subject.current_issue.approve!
end
context "on change" do
before(:each) do
subject.touch
end
it "should spawn new issue" do
subject.issues(true).size.should == 2
end
end
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment