Skip to content

Instantly share code, notes, and snippets.

@norman
Created March 22, 2010 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save norman/340373 to your computer and use it in GitHub Desktop.
Save norman/340373 to your computer and use it in GitHub Desktop.
require "mocha"
Factory.define :post do |p|
p.title "first post"
p.after_build do |post|
slug = Slug.new(:name => "first-post", :sequence => 1, :sluggable => post)
post.stubs(:slug).returns(slug)
end
end
class PostTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "should have a slug" do
post = Factory.build(:post)
assert post.slug
assert_equal post, post.slug.sluggable
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment