assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
- assert_tag 'th',
- :attributes => {:class => /filename/},
- :content => /issues_controller.rb\t\(révision 1484\)/
- assert_tag 'td',
- :attributes => {:class => /line-code/},
- :content => /Demande créée avec succès/
+ assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/
+ assert_select 'td.line-code', :text => /Demande créée avec succès/
end
set_tmp_attachments_directory
end
assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
- assert_tag 'th',
- :attributes => {:class => "filename"},
- :content => /issues_controller.rb\t\(r\?vision 1484\)/
- assert_tag 'td',
- :attributes => {:class => /line-code/},
- :content => /Demande cr\?\?e avec succ\?s/
+ assert_select 'th.filename', :text => /issues_controller.rb\t\(r\?vision 1484\)/
+ assert_select 'td.line-code', :text => /Demande cr\?\?e avec succ\?s/
end
end
set_tmp_attachments_directory
assert_response :success
assert_template 'diff'
assert_equal 'text/html', @response.content_type
- assert_tag 'th',
- :attributes => {:class => "filename"},
- :content => /issues_controller.rb\t\(révision 1484\)/
- assert_tag 'td',
- :attributes => {:class => /line-code/},
- :content => /Demande créée avec succès/
+ assert_select 'th.filename', :text => /issues_controller.rb\t\(révision 1484\)/
+ assert_select 'td.line-code', :text => /Demande créée avec succès/
end
end
set_tmp_attachments_directory
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
- assert_tag :tag => 'th',
- :content => '1',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /#{str_japanese}/ }
+ assert_select 'tr#L1' do
+ assert_select 'th.line-num', :text => '1'
+ assert_select 'td', :text => /#{str_japanese}/
+ end
end
def test_show_text_file_replace_cannot_convert_content
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
- assert_tag :tag => 'th',
- :content => '7',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /Demande cr\?\?e avec succ\?s/ }
+ assert_select 'tr#L7' do
+ assert_select 'th.line-num', :text => '7'
+ assert_select 'td', :text => /Demande cr\?\?e avec succ\?s/
+ end
end
end
assert_response :success
assert_template 'file'
assert_equal 'text/html', @response.content_type
- assert_tag :tag => 'th',
- :content => '7',
- :attributes => { :class => 'line-num' },
- :sibling => { :tag => 'td', :content => /Demande créée avec succès/ }
+ assert_select 'tr#L7' do
+ assert_select 'th.line-num', :text => '7'
+ assert_select 'td', :text => /Demande créée avec succès/
end
+ end
end
def test_show_text_file_should_send_if_too_big
@request.session[:user_id] = 2
get :show, :id => 15
assert_response :success
- assert_tag 'h2', :content => /private.diff/
+ assert_select 'h2', :text => /private.diff/
set_tmp_attachments_directory
end
get :issues, :ids => [1]
assert_response :success
assert_template 'context_menus/issues'
- assert_tag :tag => 'a', :content => 'Delete',
- :attributes => { :href => '#',
- :class => 'icon-del disabled' }
+ assert_select 'a.icon-del.disabled[href="#"]', :text => 'Delete'
end
end
get :edit, :id => 1
assert_response :success
assert_template 'edit'
- assert_tag 'input', :attributes => {:name => 'custom_field[name]', :value => 'Database'}
+ assert_select 'input[name=?][value=?]', 'custom_field[name]', 'Database'
end
def test_edit_invalid_custom_field_should_render_404
assert_not_nil assigns(:grouped)
# Default category selected in the new document form
- assert_tag :select, :attributes => {:name => 'document[category_id]'},
- :child => {:tag => 'option', :attributes => {:selected => 'selected'},
- :content => 'Technical documentation'}
+ assert_select 'select[name=?]', 'document[category_id]' do
+ assert_select 'option[selected=selected]', :text => 'Technical documentation'
- assert ! DocumentCategory.find(16).active?
- assert_no_tag :option, :attributes => {:value => '16'},
- :parent => {:tag => 'select', :attributes => {:id => 'document_category_id'} }
+ assert ! DocumentCategory.find(16).active?
+ assert_select 'option[value="16"]', 0
+ end
end
def test_index_grouped_by_date
get :index, :project_id => 'ecookbook', :sort_by => 'date'
assert_response :success
- assert_tag 'h3', :content => '2007-02-12'
+ assert_select 'h3', :text => '2007-02-12'
end
def test_index_grouped_by_title
get :index, :project_id => 'ecookbook', :sort_by => 'title'
assert_response :success
- assert_tag 'h3', :content => 'T'
+ assert_select 'h3', :text => 'T'
end
def test_index_grouped_by_author
get :index, :project_id => 'ecookbook', :sort_by => 'author'
assert_response :success
- assert_tag 'h3', :content => 'John Smith'
+ assert_select 'h3', :text => 'John Smith'
end
def test_index_with_long_description
assert_response :success
assert_template 'new'
assert_kind_of IssuePriority, assigns(:enumeration)
- assert_tag 'input', :attributes => {:name => 'enumeration[type]', :value => 'IssuePriority'}
- assert_tag 'input', :attributes => {:name => 'enumeration[name]'}
+ assert_select 'input[name=?][value=?]', 'enumeration[type]', 'IssuePriority'
+ assert_select 'input[name=?]', 'enumeration[name]'
end
def test_new_with_invalid_type_should_respond_with_404
get :edit, :id => 6
assert_response :success
assert_template 'edit'
- assert_tag 'input', :attributes => {:name => 'enumeration[name]', :value => 'High'}
+ assert_select 'input[name=?][value=?]', 'enumeration[name]', 'High'
end
def test_edit_invalid_should_respond_with_404
assert_not_nil assigns(:containers)
# file attached to the project
- assert_tag :a, :content => 'project_file.zip',
- :attributes => { :href => '/attachments/download/8/project_file.zip' }
+ assert_select 'a[href=?]', '/attachments/download/8/project_file.zip', :text => 'project_file.zip'
# file attached to a project's version
- assert_tag :a, :content => 'version_file.zip',
- :attributes => { :href => '/attachments/download/9/version_file.zip' }
+ assert_select 'a[href=?]', '/attachments/download/9/version_file.zip', :text => 'version_file.zip'
end
def test_new
assert_response :success
assert_template 'new'
- assert_tag 'select', :attributes => {:name => 'version_id'}
+ assert_select 'select[name=?]', 'version_id'
end
def test_new_without_versions
assert_response :success
assert_template 'new'
- assert_no_tag 'select', :attributes => {:name => 'version_id'}
+ assert_select 'select[name=?]', 'version_id', 0
end
def test_create_file
get :show
assert_response :success
assert_template 'gantts/show'
- assert_tag 'a', :content => /eCookbook/
+ assert_select 'a', :text => /eCookbook/
# Root private project
- assert_no_tag 'a', {:content => /OnlineStore/}
+ assert_select 'a', :text => /OnlineStore/, :count => 0
# Private children of a public project
- assert_no_tag 'a', :content => /Private child of eCookbook/
+ assert_select 'a', :text => /Private child of eCookbook/, :count => 0
end
def test_gantt_should_display_relations
assert_response :success
assert_template 'diff'
- assert_tag 'span',
- :attributes => {:class => 'diff_out'},
- :content => /removed/
- assert_tag 'span',
- :attributes => {:class => 'diff_in'},
- :content => /added/
+ assert_select 'span.diff_out', :text => /removed/
+ assert_select 'span.diff_in', :text => /added/
end
def test_reply_to_issue