Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save batasrki/1241239 to your computer and use it in GitHub Desktop.
Example model spec
require 'spec_helper.rb'
describe Job do
before :each do
@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 "basic validations" do
it "should not be valid without a name" do
@job.name = nil
@job.should_not be_valid
end
it "should not be valid without a category" do
@job.category = nil
@job.should_not be_valid
end
it "should not be valid without a client" do
@job.client = nil
@job.should_not be_valid
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment