Skip to content

Instantly share code, notes, and snippets.

@batasrki
Created September 25, 2011 22:52
Show Gist options
  • Select an option

  • Save batasrki/1241284 to your computer and use it in GitHub Desktop.

Select an option

Save batasrki/1241284 to your computer and use it in GitHub Desktop.
Example model display spec
describe Job do
before :each do
@mock_job_category = JobCategory.create!({:name => "Tester"})
@mock_client = mock_model(Client, {:name => "Test Client"})
@job = Job.new(:name => "test job", :client => @mock_client,
:category => @mock_job_category)
end
describe "display name" do
it "should display the name according to business rules" do
@job.display_name.should == "Job#: 00000 / Tester : test job"
end
it "should display the short name according to its business rules when the name exists" do
@job.display_shortname.should == "test job(Tester)"
end
it "should display a default short name if a name hasn't been set" do
@job.name = nil
@job.display_shortname.should == "Job#: 00000"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment