Skip to content

Instantly share code, notes, and snippets.

@bryanaknight
Created November 4, 2013 01:05
Show Gist options
  • Save bryanaknight/7296659 to your computer and use it in GitHub Desktop.
Save bryanaknight/7296659 to your computer and use it in GitHub Desktop.
Blogger controller test
require 'test_helper'
class ArticlesControllerTest < ActionController::TestCase
test "index method lists all articles" do
Article.create(title: "First", body: "Body")
Article.create(title: "Second", body: "Body")
articles = Article.all
assert_equal 2, articles.count
#when I run rake, getting 4 articles instead of 2
end
end
#TEST HELPER
ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
class ActiveSupport::TestCase
ActiveRecord::Migration.check_pending!
fixtures :all
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment