Skip to content

Instantly share code, notes, and snippets.

@wadtech
Created November 23, 2012 21:14
Show Gist options
  • Save wadtech/4137352 to your computer and use it in GitHub Desktop.
Save wadtech/4137352 to your computer and use it in GitHub Desktop.
example spec and result
require 'spec_helper'
describe Page do
it "has a valid factory" do
FactoryGirl.create(:page)
end
it "is invalid without a permalink" do
page = FactoryGirl.build(:page, :permalink => nil).should_not be_valid
end
it "is invalid without content" do
page = FactoryGirl.build(:page, :content => nil).should_not be_valid
end
it "must have a unique permalink" do
FactoryGirl.create(:page, :permalink => "Duplicate")
FactoryGirl.build(:page, :permalink => "Duplicate").should_not be_valid
end
context "URL" do
it "should match the permalink" do
page = FactoryGirl.build(:page)
page.to_param.should eq page.permalink
end
end
end
Page
is invalid without a permalink
is invalid without content
has a valid factory
must have a unique permalink
URL
should match the permalink
# coloured by pass/fail/pending
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment