Skip to content
This repository has been archived by the owner on Aug 29, 2019. It is now read-only.

Commit

Permalink
refactoring view helpers test to use assert_select
Browse files Browse the repository at this point in the history
Signed-off-by: James Adam <james@lazyatom.com>
  • Loading branch information
trptcolin authored and lazyatom committed Jan 22, 2009
1 parent 2aee150 commit a8c6d6d
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions test/functional/view_helpers_test.rb
Expand Up @@ -7,30 +7,31 @@ def setup
get :index
end

# TODO: refactor this to use assert_select
def test_plugin_javascript_helpers
attrs = { :type => "text/javascript" }
assert_tag :script, :attributes => attrs.update(:src => "/plugin_assets/test_assets/javascripts/file.1.js")
assert_tag :script, :attributes => attrs.update(:src => "/plugin_assets/test_assets/javascripts/file2.js")
base_selector = "script[type='text/javascript']"
js_dir = "/plugin_assets/test_assets/javascripts"
assert_select "#{base_selector}[src='#{js_dir}/file.1.js']"
assert_select "#{base_selector}[src='#{js_dir}/file2.js']"
end

def test_plugin_stylesheet_helpers
attrs = { :media => "screen", :rel => "stylesheet", :type => "text/css" }
assert_tag :link, :attributes => attrs.update(:href => "/plugin_assets/test_assets/stylesheets/file.1.css")
assert_tag :link, :attributes => attrs.update(:href => "/plugin_assets/test_assets/stylesheets/file2.css")
base_selector = "link[media='screen'][rel='stylesheet'][type='text/css']"
css_dir = "/plugin_assets/test_assets/stylesheets"
assert_select "#{base_selector}[href='#{css_dir}/file.1.css']"
assert_select "#{base_selector}[href='#{css_dir}/file2.css']"
end

def test_plugin_image_helpers
assert_tag :img, :attributes => { :src => "/plugin_assets/test_assets/images/image.png", :alt => "Image" }
assert_select "img[src='/plugin_assets/test_assets/images/image.png'][alt='Image']"
end

def test_plugin_layouts
get :index
assert_tag :div, :attributes => { :id => "assets_layout" }
assert_select "div[id='assets_layout']"
end

def test_plugin_image_submit_helpers
assert_tag :input, :attributes => { :src => "/plugin_assets/test_assets/images/image.png", :type => "image"}
end
def test_plugin_image_submit_helpers
assert_select "input[src='/plugin_assets/test_assets/images/image.png'][type='image']"
end

end

0 comments on commit a8c6d6d

Please sign in to comment.