Skip to content

Commit

Permalink
assert_template depends on AV::Template monkey patches in action_view…
Browse files Browse the repository at this point in the history
…/test_case
  • Loading branch information
josh committed Jan 5, 2010
1 parent 2dc5aee commit 8ff4faf
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
9 changes: 9 additions & 0 deletions actionpack/lib/action_dispatch/testing/assertions/response.rb
Expand Up @@ -2,6 +2,15 @@ module ActionDispatch
module Assertions module Assertions
# A small suite of assertions that test responses from Rails applications. # A small suite of assertions that test responses from Rails applications.
module ResponseAssertions module ResponseAssertions
extend ActiveSupport::Concern

included do
# TODO: Need to pull in AV::Template monkey patches that track which
# templates are rendered. assert_template should probably be part
# of AV instead of AD.
require 'action_view/test_case'
end

# Asserts that the response is one of the following types: # Asserts that the response is one of the following types:
# #
# * <tt>:success</tt> - Status code was 200 # * <tt>:success</tt> - Status code was 200
Expand Down
25 changes: 25 additions & 0 deletions railties/test/application/test_test.rb
Expand Up @@ -23,6 +23,31 @@ def test_truth
run_test 'unit/foo_test.rb' run_test 'unit/foo_test.rb'
end end


test "integration test" do
controller 'posts', <<-RUBY
class PostsController < ActionController::Base
end
RUBY

app_file 'app/views/posts/index.html.erb', <<-HTML
Posts#index
HTML

app_file 'test/integration/posts_test.rb', <<-RUBY
require 'test_helper'
class PostsTest < ActionController::IntegrationTest
def test_index
get '/posts'
assert_response :success
assert_template "index"
end
end
RUBY

run_test 'integration/posts_test.rb'
end

private private
def run_test(name) def run_test(name)
result = ruby '-Itest', "#{app_path}/test/#{name}" result = ruby '-Itest', "#{app_path}/test/#{name}"
Expand Down

0 comments on commit 8ff4faf

Please sign in to comment.