test/integration/navigation_test.rb in seiten-0.0.8 vs test/integration/navigation_test.rb in seiten-1.0.0

- old
+ new

@@ -1,69 +1,69 @@ require 'test_helper' class NavigationTest < ActionDispatch::IntegrationTest - - def test_returns_2_level_deep_navigation - visit "/" - assert has_content?("Home") - assert has_content?("Products") - assert has_content?("Logo Design") - assert has_content?("Web Development") - assert has_content?("Hire us") - assert has_content?("About") - assert has_content?("Our Team") - assert has_content?("Works") - assert has_content?("Partners") - assert has_content?("Contact") + def test_should_ignore_active_storage_routes + assert_raise ActionController::RoutingError do + get '/rails/active_storage/test' + end end - def test_does_not_return_3_level_deep_pages - visit "/" - assert !has_content?("Daniel Puglisi") - assert !has_content?("Codegestalt") - assert !has_content?("Kreatify") + def test_should_raise_seiten_routing_error + assert_raise Seiten::Errors::RoutingError do + get '/non-existing-route' + end end - def test_returns_home_url - visit "/contact" - assert_equal "/contact", current_path - click_link "Home" - assert_equal "/", current_path + def test_returns_2_level_deep_navigation + get '/' + assert_select 'a', 'Home' + assert_select 'a', 'Products' + assert_select 'a', 'Logo Design' + assert_select 'a', 'Web Development' + assert_select 'a', 'Hire us' + assert_select 'a', 'About' + assert_select 'a', 'Our Team' + assert_select 'a', 'Works' + assert_select 'a', 'Partners' + assert_select 'a', 'Contact' + assert_select 'a', { count: 0, text: 'Daniel Puglisi' } + assert_select 'a', { count: 0, text: 'Codegestalt' } + assert_select 'a', { count: 0, text: 'Kreatify' } + assert_select '.navigation__item--active', count: 1 + assert_select 'title', 'My awesome Web Agency' end def test_returns_sub_navigation - visit "/about/partners" - assert has_content?("Daniel Puglisi") - assert has_content?("Codegestalt") - assert has_content?("Kreatify") + get '/about/partners' + assert_select 'a', 'Daniel Puglisi' + assert_select 'a', 'Codegestalt' + assert_select 'a', 'Kreatify' + assert_select '.navigation__item--active', count: 2 + assert_select 'title', 'Partners' end def test_returns_breadcrumb_navigation - visit "/about/our-team/switzerland" - assert has_content?("> About") - assert has_content?("> Our Team") - assert has_content?("> Switzerland") + get '/about/our-team/switzerland' + assert_select '.breadcrumb a', 'About' + assert_select '.breadcrumb a', 'Our Team' + assert_select '.breadcrumb a', 'Switzerland' + assert_select '.navigation__item--active', count: 2 + assert_select '.breadcrumb__item--current', count: 1 + assert_select 'title', 'Switzerland' end - def test_returns_clicked_breadcrumb_page - visit "/about/our-team/switzerland" - find(".breadcrumb a", text: "Our Team").click - assert_equal "/about/our-team", current_path + def test_returns_page_with_navigation_which_is_not_defined_in_navigation_config + get '/secret' + assert_response :success + assert_select 'p', 'pages#secret' + assert_select '.navigation__item--active', count: 0 + assert_select 'title', nil end - def test_returns_clicked_navigation_page - visit "/" - click_link "Web Development" - assert_equal "/products/web-development", current_path - end - - def test_returns_external_links - visit "/about/partners" - assert has_xpath?("//a[@href='http://danielpuglisi.com']") - end - - def test_returns_page_with_navigation_which_is_not_defined_in_navigation_config - visit "/secret" - assert_equal 200, status_code - has_content?("This is a secret page") + def test_returns_current_page_of_custom_controller + get '/blog' + assert_select 'title', 'Blog' + assert_select 'p', 'posts#index' + assert_select '.navigation__item--active', count: 1 + assert_select '.navigation__item--active a', text: 'Blog' end end