Sha256: 4a36ccbf13fa94db1f9b836ffaca870eb03d80cdf5c674074a837a3adf9f8931

Contents?: true

Size: 1.88 KB

Versions: 2

Compression:

Stored size: 1.88 KB

Contents

require 'test_helper'

class GretelTrailsTest < ActionDispatch::IntegrationTest
  test "regular breadcrumbs" do
    visit "/categories/one"

    within "#products" do
      click_link "Product One"
    end
    assert_equal "/products/one", current_fullpath
    assert_equal ["/", "/categories/one"], all(".breadcrumbs a").map { |a| a[:href] }

    click_link "See reviews"
    assert_equal "/products/one/reviews", current_fullpath
    assert_equal ["/", "/categories/one", "/products/one"], all(".breadcrumbs a").map { |a| a[:href] }

    all(".breadcrumbs a").last.click
    assert_equal "/products/one", current_fullpath
    assert_equal ["/", "/categories/one"], all(".breadcrumbs a").map { |a| a[:href] }

    all(".breadcrumbs a").last.click
    assert_equal "/categories/one", current_fullpath
  end

  test "invisibly applying trail" do
    visit "/products/recent"

    within "#products" do
      click_link "Product One"
    end
    assert_equal "/products/one", current_fullpath
    assert_equal ["/", "/products/recent"], all(".breadcrumbs a").map { |a| a[:href] }

    click_link "See reviews"
    assert_equal "/products/one/reviews", current_fullpath
    assert_equal ["/", "/products/recent", "/products/one"], all(".breadcrumbs a").map { |a| a[:href] }

    all(".breadcrumbs a").last.click
    assert_equal "/products/one", current_fullpath
    assert_equal ["/", "/products/recent"], all(".breadcrumbs a").map { |a| a[:href] }

    all(".breadcrumbs a").last.click
    assert_equal "/products/recent", current_fullpath
  end

  test "breadcrumb_link_to" do
    visit "/products/recent"

    within "#products" do
      click_link "Product One"
    end

    click_link "See reviews"

    within "#back" do
      click_link "Back"
    end

    assert_equal "/products/one", current_fullpath

    within "#back" do
      click_link "Back"
    end

    assert_equal "/products/recent", current_fullpath
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gretel-trails-0.0.2 test/gretel_trails_test.rb
gretel-trails-0.0.1 test/gretel_trails_test.rb