Skip to content

Instantly share code, notes, and snippets.

@rbarazi
Created April 7, 2010 02:16
Show Gist options
  • Save rbarazi/358403 to your computer and use it in GitHub Desktop.
Save rbarazi/358403 to your computer and use it in GitHub Desktop.
[Beginning Rails 3] Listing 10-7. Test case for updating an article, in test/unit/article_test.rb
require 'test_helper'
class ArticleTest < ActiveSupport::TestCase
test "should create article" do
article = Article.new
article.user = users(:eugene)
article.title = "Test article"
article.body = "Test body"
assert article.save
end
test "should find article" do
article_id = articles(:welcome_to_rails).id
assert_nothing_raised { Article.find(article_id) }
end
test "should update article" do
article = articles(:welcome_to_rails)
assert article.update_attributes(:title => 'New title')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment