require File.dirname(__FILE__) + "/helper" class ClicksLinkTest < Test::Unit::TestCase def setup @session = ActionController::Integration::Session.new @session.stubs(:assert_response) @session.stubs(:get_via_redirect) @session.stubs(:response).returns(@response=mock) end def test_should_use_get_by_default @response.stubs(:body).returns(<<-EOS) Link text EOS @session.expects(:get_via_redirect).with("/page", {}) @session.clicks_link "Link text" end def test_should_click_get_links @response.stubs(:body).returns(<<-EOS) Link text EOS @session.expects(:get_via_redirect).with("/page", {}) @session.clicks_get_link "Link text" end def test_should_click_delete_links @response.stubs(:body).returns(<<-EOS) Link text EOS @session.expects(:delete_via_redirect).with("/page", {}) @session.clicks_delete_link "Link text" end def test_should_click_post_links @response.stubs(:body).returns(<<-EOS) Link text EOS @session.expects(:post_via_redirect).with("/page", {}) @session.clicks_post_link "Link text" end def test_should_click_put_links @response.stubs(:body).returns(<<-EOS) Link text EOS @session.expects(:put_via_redirect).with("/page", {}) @session.clicks_put_link "Link text" end def test_should_click_rails_javascript_links_with_authenticity_tokens @response.stubs(:body).returns(<<-EOS) Posts EOS @session.expects(:post_via_redirect).with("/posts", "authenticity_token" => "aa79cb354597a60a3786e7e291ed4f74d77d3a62") @session.clicks_link "Posts" end def test_should_click_rails_javascript_delete_links @response.stubs(:body).returns(<<-EOS) Delete EOS @session.expects(:delete_via_redirect).with("/posts/1", {}) @session.clicks_link "Delete" end def test_should_click_rails_javascript_post_links @response.stubs(:body).returns(<<-EOS) Posts EOS @session.expects(:post_via_redirect).with("/posts", {}) @session.clicks_link "Posts" end def test_should_click_rails_javascript_put_links @response.stubs(:body).returns(<<-EOS) Put EOS @session.expects(:put_via_redirect).with("/posts", {}) @session.clicks_link "Put" end def test_should_assert_valid_response @response.stubs(:body).returns(<<-EOS) Link text EOS @session.expects(:assert_response).with(:success) @session.clicks_link "Link text" end def test_should_not_be_case_sensitive @response.stubs(:body).returns(<<-EOS) Link text EOS @session.expects(:get_via_redirect).with("/page", {}) @session.clicks_link "LINK TEXT" end def test_should_match_link_substrings @response.stubs(:body).returns(<<-EOS) This is some cool link text, isn't it? EOS @session.expects(:get_via_redirect).with("/page", {}) @session.clicks_link "Link text" end def test_should_work_with_elements_in_the_link @response.stubs(:body).returns(<<-EOS) Link text EOS @session.expects(:get_via_redirect).with("/page", {}) @session.clicks_link "Link text" end def test_should_match_the_first_matching_link @response.stubs(:body).returns(<<-EOS) Link text Link text EOS @session.expects(:get_via_redirect).with("/page1", {}) @session.clicks_link "Link text" end def test_should_choose_the_shortest_link_text_match @response.stubs(:body).returns(<<-EOS) Linkerama Link EOS @session.expects(:get_via_redirect).with("/page2", {}) @session.clicks_link "Link" end def test_should_click_link_within_a_selector @response.stubs(:body).returns(<<-EOS) Link
Link
EOS @session.expects(:get_via_redirect).with("/page2", {}) @session.clicks_link_within "#container", "Link" end end