mirror of
https://github.com/TracksApp/tracks.git
synced 2025-12-16 15:20:13 +01:00
Update assert_select for Nokogiri compatibility
assert_select has been moved into the rails-dom-testing gem and is now based on Nokogiri. * Remove assert_tag and assert_xml_select * Quote CSS attribute selector values * Use decoded versions of HTML in assert_select. Nokogiri decodes elements prior to matching. * Add a test helper for entities such as ` ` for which it's difficult or confusing to include the decoded version directly in the assertion. * Assert directly on Atom feeds' XML namespace because it isn't selectable as an attribute
This commit is contained in:
parent
d7d86446c0
commit
689db4c9c3
9 changed files with 66 additions and 64 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
require 'support/html_entity_helper'
|
||||||
|
|
||||||
class ContextsControllerTest < ActionController::TestCase
|
class ContextsControllerTest < ActionController::TestCase
|
||||||
|
include HTMLEntityHelper
|
||||||
|
|
||||||
fixtures :users, :preferences, :contexts
|
fixtures :users, :preferences, :contexts
|
||||||
|
|
||||||
def test_contexts_list
|
def test_contexts_list
|
||||||
|
|
@ -96,7 +99,7 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :show, { :id => "0", :format => 'xml' }
|
get :show, { :id => "0", :format => 'xml' }
|
||||||
assert_response 404
|
assert_response 404
|
||||||
assert_xml_select 'error', 'Context not found'
|
assert_select 'error', 'Context not found'
|
||||||
end
|
end
|
||||||
|
|
||||||
# RSS
|
# RSS
|
||||||
|
|
@ -107,7 +110,7 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
assert_equal 'application/rss+xml', @response.content_type
|
assert_equal 'application/rss+xml', @response.content_type
|
||||||
#puts @response.body
|
#puts @response.body
|
||||||
|
|
||||||
assert_xml_select 'rss[version="2.0"]' do
|
assert_select 'rss[version="2.0"]' do
|
||||||
assert_select 'channel' do
|
assert_select 'channel' do
|
||||||
assert_select '>title', 'Tracks Contexts'
|
assert_select '>title', 'Tracks Contexts'
|
||||||
assert_select '>description', "Lists all the contexts for #{users(:admin_user).display_name}"
|
assert_select '>description', "Lists all the contexts for #{users(:admin_user).display_name}"
|
||||||
|
|
@ -118,7 +121,7 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
assert_select 'title', /.+/
|
assert_select 'title', /.+/
|
||||||
assert_select 'description' do
|
assert_select 'description' do
|
||||||
assert_select_encoded do
|
assert_select_encoded do
|
||||||
assert_select 'p', /\d+ actions. Context is (Active|Hidden)./
|
assert_select 'p', /\d+#{nbsp}actions. Context is (Active|Hidden)./
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
%w(guid link).each do |node|
|
%w(guid link).each do |node|
|
||||||
|
|
@ -153,16 +156,15 @@ class ContextsControllerTest < ActionController::TestCase
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, { :format => "atom" }
|
get :index, { :format => "atom" }
|
||||||
assert_equal 'application/atom+xml', @response.content_type
|
assert_equal 'application/atom+xml', @response.content_type
|
||||||
#puts @response.body
|
assert_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
|
||||||
|
assert_select 'feed' do
|
||||||
assert_xml_select 'feed[xmlns="http://www.w3.org/2005/Atom"]' do
|
|
||||||
assert_select '>title', 'Tracks Contexts'
|
assert_select '>title', 'Tracks Contexts'
|
||||||
assert_select '>subtitle', "Lists all the contexts for #{users(:admin_user).display_name}"
|
assert_select '>subtitle', "Lists all the contexts for #{users(:admin_user).display_name}"
|
||||||
assert_select 'entry', 10 do
|
assert_select 'entry', 10 do
|
||||||
assert_select 'title', /.+/
|
assert_select 'title', /.+/
|
||||||
assert_select 'content[type="html"]' do
|
assert_select 'content[type="html"]' do
|
||||||
assert_select_encoded do
|
assert_select_encoded do
|
||||||
assert_select 'p', /\d+ actions. Context is (Active|Hidden)./
|
assert_select 'p', /\d+#{nbsp}actions. Context is (Active|Hidden)./
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_select 'published', /(#{Regexp.escape(contexts(:agenda).created_at.xmlschema)}|#{Regexp.escape(contexts(:library).created_at.xmlschema)})/
|
assert_select 'published', /(#{Regexp.escape(contexts(:agenda).created_at.xmlschema)}|#{Regexp.escape(contexts(:library).created_at.xmlschema)})/
|
||||||
|
|
|
||||||
|
|
@ -26,4 +26,4 @@ class FeedlistControllerTest < ActionController::TestCase
|
||||||
assert_response 200
|
assert_response 200
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
require 'support/html_entity_helper'
|
||||||
|
|
||||||
class ProjectsControllerTest < ActionController::TestCase
|
class ProjectsControllerTest < ActionController::TestCase
|
||||||
|
include HTMLEntityHelper
|
||||||
|
|
||||||
def setup
|
def setup
|
||||||
end
|
end
|
||||||
|
|
@ -83,7 +85,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
assert_equal 'application/rss+xml', @response.content_type
|
assert_equal 'application/rss+xml', @response.content_type
|
||||||
#puts @response.body
|
#puts @response.body
|
||||||
|
|
||||||
assert_xml_select 'rss[version="2.0"]' do
|
assert_select 'rss[version="2.0"]' do
|
||||||
assert_select 'channel' do
|
assert_select 'channel' do
|
||||||
assert_select '>title', 'Tracks Projects'
|
assert_select '>title', 'Tracks Projects'
|
||||||
assert_select '>description', "Lists all the projects for #{users(:admin_user).display_name}"
|
assert_select '>description', "Lists all the projects for #{users(:admin_user).display_name}"
|
||||||
|
|
@ -94,7 +96,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
assert_select 'title', /.+/
|
assert_select 'title', /.+/
|
||||||
assert_select 'description' do
|
assert_select 'description' do
|
||||||
assert_select_encoded do
|
assert_select_encoded do
|
||||||
assert_select 'p', /^\d+ actions\. Project is (active|hidden|completed)\.$/
|
assert_select 'p', /^\d+#{nbsp}actions\. Project is (active|hidden|completed)\.$/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
%w(guid link).each do |node|
|
%w(guid link).each do |node|
|
||||||
|
|
@ -127,16 +129,15 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, { :format => "atom" }
|
get :index, { :format => "atom" }
|
||||||
assert_equal 'application/atom+xml', @response.content_type
|
assert_equal 'application/atom+xml', @response.content_type
|
||||||
# puts @response.body
|
assert_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
|
||||||
|
assert_select 'feed' do
|
||||||
assert_xml_select 'feed[xmlns="http://www.w3.org/2005/Atom"]' do
|
|
||||||
assert_select '>title', 'Tracks Projects'
|
assert_select '>title', 'Tracks Projects'
|
||||||
assert_select '>subtitle', "Lists all the projects for #{users(:admin_user).display_name}"
|
assert_select '>subtitle', "Lists all the projects for #{users(:admin_user).display_name}"
|
||||||
assert_select 'entry', 3 do
|
assert_select 'entry', 3 do
|
||||||
assert_select 'title', /.+/
|
assert_select 'title', /.+/
|
||||||
assert_select 'content[type="html"]' do
|
assert_select 'content[type="html"]' do
|
||||||
assert_select_encoded do
|
assert_select_encoded do
|
||||||
assert_select 'p', /\d+ actions. Project is (active|hidden|completed)./
|
assert_select 'p', /\d+#{nbsp}actions. Project is (active|hidden|completed)./
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
assert_select 'published', /(#{Regexp.escape(projects(:timemachine).updated_at.xmlschema)}|#{Regexp.escape(projects(:moremoney).updated_at.xmlschema)})/
|
assert_select 'published', /(#{Regexp.escape(projects(:timemachine).updated_at.xmlschema)}|#{Regexp.escape(projects(:moremoney).updated_at.xmlschema)})/
|
||||||
|
|
@ -239,7 +240,7 @@ class ProjectsControllerTest < ActionController::TestCase
|
||||||
get :index, { :format => "xml" }
|
get :index, { :format => "xml" }
|
||||||
assert_equal 'application/xml', @response.content_type
|
assert_equal 'application/xml', @response.content_type
|
||||||
|
|
||||||
assert_xml_select 'projects' do
|
assert_select 'projects' do
|
||||||
assert_select 'project', 3 do
|
assert_select 'project', 3 do
|
||||||
assert_select 'name', /.+/
|
assert_select 'name', /.+/
|
||||||
assert_select 'state', 'active'
|
assert_select 'state', 'active'
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
require 'test_helper'
|
require 'test_helper'
|
||||||
|
|
||||||
class TodosControllerTest < ActionController::TestCase
|
class TodosControllerTest < ActionController::TestCase
|
||||||
|
|
||||||
def test_get_index_when_not_logged_in
|
def test_get_index_when_not_logged_in
|
||||||
get :index
|
get :index
|
||||||
assert_redirected_to login_url
|
assert_redirected_to login_url
|
||||||
|
|
@ -235,8 +234,8 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
"project_name"=>"Build a working time machine",
|
"project_name"=>"Build a working time machine",
|
||||||
"todo"=>{"notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar" }
|
"todo"=>{"notes"=>"", "description"=>"Call Warren Buffet to find out how much he makes per day", "due"=>"30/11/2006"}, "tag_list"=>"foo bar" }
|
||||||
assert_response 409
|
assert_response 409
|
||||||
assert_xml_select "errors" do
|
assert_select "errors" do
|
||||||
assert_xml_select "error", "Context can't be blank"
|
assert_select "error", "Context can't be blank"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -467,7 +466,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
assert_equal 'application/rss+xml', @response.content_type
|
assert_equal 'application/rss+xml', @response.content_type
|
||||||
# puts @response.body
|
# puts @response.body
|
||||||
|
|
||||||
assert_xml_select 'rss[version="2.0"]' do
|
assert_select 'rss[version="2.0"]' do
|
||||||
assert_select 'channel' do
|
assert_select 'channel' do
|
||||||
assert_select '>title', 'Tracks Actions'
|
assert_select '>title', 'Tracks Actions'
|
||||||
assert_select '>description', "Actions for #{users(:admin_user).display_name}"
|
assert_select '>description', "Actions for #{users(:admin_user).display_name}"
|
||||||
|
|
@ -488,7 +487,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
login_as(:admin_user)
|
login_as(:admin_user)
|
||||||
get :index, { :format => "rss", :limit => '5' }
|
get :index, { :format => "rss", :limit => '5' }
|
||||||
|
|
||||||
assert_xml_select 'rss[version="2.0"]' do
|
assert_select 'rss[version="2.0"]' do
|
||||||
assert_select 'channel' do
|
assert_select 'channel' do
|
||||||
assert_select '>title', 'Tracks Actions'
|
assert_select '>title', 'Tracks Actions'
|
||||||
assert_select '>description', "Actions for #{users(:admin_user).display_name}"
|
assert_select '>description', "Actions for #{users(:admin_user).display_name}"
|
||||||
|
|
@ -522,15 +521,14 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
login_as :admin_user
|
login_as :admin_user
|
||||||
get :index, { :format => "atom" }
|
get :index, { :format => "atom" }
|
||||||
assert_equal 'application/atom+xml', @response.content_type
|
assert_equal 'application/atom+xml', @response.content_type
|
||||||
# #puts @response.body
|
assert_equal 'http://www.w3.org/2005/Atom', html_document.children[0].namespace.href
|
||||||
|
assert_select 'feed' do
|
||||||
assert_xml_select 'feed[xmlns="http://www.w3.org/2005/Atom"]' do
|
assert_select '>title', 'Tracks Actions'
|
||||||
assert_xml_select '>title', 'Tracks Actions'
|
assert_select '>subtitle', "Actions for #{users(:admin_user).display_name}"
|
||||||
assert_xml_select '>subtitle', "Actions for #{users(:admin_user).display_name}"
|
assert_select 'entry', 17 do
|
||||||
assert_xml_select 'entry', 17 do
|
assert_select 'title', /.+/
|
||||||
assert_xml_select 'title', /.+/
|
assert_select 'content[type="html"]', /.*/
|
||||||
assert_xml_select 'content[type="html"]', /.*/
|
assert_select 'published', /(#{Regexp.escape(todos(:book).updated_at.xmlschema)}|#{Regexp.escape(projects(:moremoney).updated_at.xmlschema)})/
|
||||||
assert_xml_select 'published', /(#{Regexp.escape(todos(:book).updated_at.xmlschema)}|#{Regexp.escape(projects(:moremoney).updated_at.xmlschema)})/
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -846,7 +844,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
todo.notes = "foo #{url} bar"
|
todo.notes = "foo #{url} bar"
|
||||||
todo.save!
|
todo.save!
|
||||||
get :index
|
get :index
|
||||||
assert_select "a[href=#{url}]"
|
assert_select "a[href='#{url}']"
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_link_opened_in_new_window
|
def test_link_opened_in_new_window
|
||||||
|
|
@ -886,7 +884,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
todo.save!
|
todo.save!
|
||||||
get :index
|
get :index
|
||||||
assert_select("div#notes_todo_#{todo.id}", 'A link to http://github.com/.')
|
assert_select("div#notes_todo_#{todo.id}", 'A link to http://github.com/.')
|
||||||
assert_select("div#notes_todo_#{todo.id} a[href=http://github.com/]", 'http://github.com/')
|
assert_select("div#notes_todo_#{todo.id} a[href='http://github.com/']", 'http://github.com/')
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_format_note_link_message
|
def test_format_note_link_message
|
||||||
|
|
@ -895,9 +893,9 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
todo.raw_notes = "A Mail.app message://<ABCDEF-GHADB-123455-FOO-BAR@example.com> link"
|
todo.raw_notes = "A Mail.app message://<ABCDEF-GHADB-123455-FOO-BAR@example.com> link"
|
||||||
todo.save!
|
todo.save!
|
||||||
get :index
|
get :index
|
||||||
assert_select("div#notes_todo_#{todo.id}", 'A Mail.app message://<ABCDEF-GHADB-123455-FOO-BAR@example.com> link')
|
assert_select("div#notes_todo_#{todo.id}", 'A Mail.app message://<ABCDEF-GHADB-123455-FOO-BAR@example.com> link')
|
||||||
assert_select("div#notes_todo_#{todo.id} a", 'message://<ABCDEF-GHADB-123455-FOO-BAR@example.com>')
|
assert_select("div#notes_todo_#{todo.id} a", 'message://<ABCDEF-GHADB-123455-FOO-BAR@example.com>')
|
||||||
assert_select("div#notes_todo_#{todo.id} a[href=message://<ABCDEF-GHADB-123455-FOO-BAR@example.com>]", 'message://<ABCDEF-GHADB-123455-FOO-BAR@example.com>')
|
assert_select("div#notes_todo_#{todo.id} a[href='message://<ABCDEF-GHADB-123455-FOO-BAR@example.com>']", "message://<ABCDEF-GHADB-123455-FOO-BAR@example.com>")
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_format_note_link_onenote
|
def test_format_note_link_onenote
|
||||||
|
|
@ -908,7 +906,7 @@ class TodosControllerTest < ActionController::TestCase
|
||||||
get :index
|
get :index
|
||||||
assert_select("div#notes_todo_#{todo.id}", 'link me to onenote')
|
assert_select("div#notes_todo_#{todo.id}", 'link me to onenote')
|
||||||
assert_select("div#notes_todo_#{todo.id} a", 'link me to onenote')
|
assert_select("div#notes_todo_#{todo.id} a", 'link me to onenote')
|
||||||
assert_select("div#notes_todo_#{todo.id} a[href=onenote:///E:%5COneNote%5Cdir%5Cnotes.one#PAGE&section-id=%7BFD597D3A-3793-495F-8345-23D34A00DD3B%7D&page-id=%7B1C95A1C7-6408-4804-B3B5-96C28426022B%7D&end]", 'link me to onenote')
|
assert_select("div#notes_todo_#{todo.id} a[href='onenote:///E:%5COneNote%5Cdir%5Cnotes.one#PAGE§ion-id=%7BFD597D3A-3793-495F-8345-23D34A00DD3B%7D&page-id=%7B1C95A1C7-6408-4804-B3B5-96C28426022B%7D&end']", 'link me to onenote')
|
||||||
end
|
end
|
||||||
|
|
||||||
##############
|
##############
|
||||||
|
|
|
||||||
|
|
@ -6,11 +6,12 @@ class ProjectXmlApiTest < ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
def test_retrieve_project
|
def test_retrieve_project
|
||||||
authenticated_get_xml "/projects/1.xml", users(:admin_user).login, 'abracadabra', {}
|
authenticated_get_xml "/projects/1.xml", users(:admin_user).login, 'abracadabra', {}
|
||||||
assert_tag :tag => "project"
|
assert_select 'project' do
|
||||||
assert_tag :tag => "project", :child => {:tag => "not_done" }
|
assert_select 'not_done'
|
||||||
assert_tag :tag => "project", :child => {:tag => "deferred" }
|
assert_select 'deferred'
|
||||||
assert_tag :tag => "project", :child => {:tag => "pending" }
|
assert_select 'pending'
|
||||||
assert_tag :tag => "project", :child => {:tag => "done" }
|
assert_select 'done'
|
||||||
|
end
|
||||||
assert_response 200
|
assert_response 200
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,14 @@ class TodoXmlApiTest < ActionDispatch::IntegrationTest
|
||||||
def test_get_tickler_returns_all_deferred_and_pending_todos
|
def test_get_tickler_returns_all_deferred_and_pending_todos
|
||||||
number = @user.todos.deferred.count + @user.todos.pending.count
|
number = @user.todos.deferred.count + @user.todos.pending.count
|
||||||
authenticated_get_xml "/tickler.xml", @user.login, @password, {}
|
authenticated_get_xml "/tickler.xml", @user.login, @password, {}
|
||||||
assert_tag :tag => "todos", :children => { :count => number }
|
assert_select 'todos' do
|
||||||
|
assert_select 'todo', count: number
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_tickler_omits_user_id
|
def test_get_tickler_omits_user_id
|
||||||
authenticated_get_xml "/tickler.xml", @user.login, @password, {}
|
authenticated_get_xml "/tickler.xml", @user.login, @password, {}
|
||||||
assert_no_tag :tag => "user_id"
|
assert_select 'user_id', false
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_index_with_only_active_todos
|
def test_get_index_with_only_active_todos
|
||||||
|
|
@ -245,7 +247,7 @@ class TodoXmlApiTest < ActionDispatch::IntegrationTest
|
||||||
<project_id type='integer'>-11</project_id>
|
<project_id type='integer'>-11</project_id>
|
||||||
</todo>"
|
</todo>"
|
||||||
assert_response 409
|
assert_response 409
|
||||||
assert_xml_select 'errors' do
|
assert_select 'errors' do
|
||||||
assert_select 'error', 2
|
assert_select 'error', 2
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -261,4 +263,4 @@ class TodoXmlApiTest < ActionDispatch::IntegrationTest
|
||||||
authenticated_post_xml "/todos.xml", user, password, postdata
|
authenticated_post_xml "/todos.xml", user, password, postdata
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -69,16 +69,17 @@ class UsersXmlApiTest < ActionDispatch::IntegrationTest
|
||||||
def test_get_users_as_xml
|
def test_get_users_as_xml
|
||||||
get '/users.xml', {}, basic_auth_headers()
|
get '/users.xml', {}, basic_auth_headers()
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_tag :tag => "users",
|
assert_select 'users' do
|
||||||
:children => { :count => 4, :only => { :tag => "user" } }
|
assert_select 'user', count: 4
|
||||||
assert_no_tag :tag => "password"
|
end
|
||||||
|
assert_select 'password', false
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_get_user_as_xml
|
def test_get_user_as_xml
|
||||||
get "/users/#{users(:other_user).id}.xml", {}, basic_auth_headers()
|
get "/users/#{users(:other_user).id}.xml", {}, basic_auth_headers()
|
||||||
assert_response :success
|
assert_response :success
|
||||||
assert_tag :tag => "user"
|
assert_select 'user'
|
||||||
assert_no_tag :tag => "password"
|
assert_select 'password', false
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
11
test/support/html_entity_helper.rb
Normal file
11
test/support/html_entity_helper.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
require 'htmlentities'
|
||||||
|
|
||||||
|
module HTMLEntityHelper
|
||||||
|
def entity(name)
|
||||||
|
HTMLEntities.new.decode("&#{name};")
|
||||||
|
end
|
||||||
|
|
||||||
|
def nbsp
|
||||||
|
entity('nbsp')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -56,15 +56,6 @@ class ActiveSupport::TestCase
|
||||||
def assert_equal_dmy(date1, date2)
|
def assert_equal_dmy(date1, date2)
|
||||||
assert_equal date1.strftime("%d-%m-%y"), date2.strftime("%d-%m-%y")
|
assert_equal date1.strftime("%d-%m-%y"), date2.strftime("%d-%m-%y")
|
||||||
end
|
end
|
||||||
|
|
||||||
def xml_document
|
|
||||||
@xml_document ||= HTML::Document.new(@response.body, false, true)
|
|
||||||
end
|
|
||||||
|
|
||||||
def assert_xml_select(*args, &block)
|
|
||||||
@html_document = xml_document
|
|
||||||
assert_select(*args, &block)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class ActionController::TestCase
|
class ActionController::TestCase
|
||||||
|
|
@ -90,11 +81,6 @@ class ActionController::TestCase
|
||||||
xhr :post, :create, get_model_class.downcase => {:name => name}
|
xhr :post, :create, get_model_class.downcase => {:name => name}
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_xml_select(*args, &block)
|
|
||||||
@html_document = xml_document
|
|
||||||
assert_select(*args, &block)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def get_model_class
|
def get_model_class
|
||||||
|
|
@ -145,7 +131,7 @@ class ActionDispatch::IntegrationTest
|
||||||
|
|
||||||
def assert_responses_with_error(error_msg)
|
def assert_responses_with_error(error_msg)
|
||||||
assert_response 409
|
assert_response 409
|
||||||
assert_xml_select 'errors' do
|
assert_select 'errors' do
|
||||||
assert_select 'error', 1, error_msg
|
assert_select 'error', 1, error_msg
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue