Sha256: de5296335c83907f0fe4c5777a4d0ebf7200523899ca0b2d6299913e1ba14152

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'test_helper'

class HelperTest < ActionView::TestCase
  include Tuning::Extensions::ActionView::Base

  test 'active trail' do
    set_path '/some-path/other-path'
    assert active_trail?('/')
    assert active_trail?('/some-path')

    set_path '/'
    assert active_trail?('/')
    set_path '/some-path'
    assert active_trail?('/some-path')

    set_path '/'
    assert_not active_trail?('/some-path')
    set_path '/some-path'
    assert_not active_trail?('/other-path')
  end

  test 'content tag if' do
    assert_equal(
      'content',
      content_tag_if(false, :a) { 'content' }
    )
    assert_equal(
      '<a>content</a>',
      content_tag_if(true, :a) { 'content' }
    )
    assert_equal(
      '<a href="#">content</a>',
      content_tag_if(true, :a, href: '#') { 'content' }
    )
  end

  test 'extending' do
    assert_equal(
      '<!DOCTYPE html><p>content</p>',
      render(template: 'layouts/market').gsub(/\n\s+/, '')
    )
  end

  private

  def set_path(path)
    self.request = ActionDispatch::TestRequest.new
    self.request.path = path
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
tuning-4.0.1.2 test/helper_test.rb
tuning-4.0.1.1 test/helper_test.rb
tuning-4.0.1.0 test/helper_test.rb
tuning-4.0.0.1 test/helper_test.rb
tuning-4.0.0.0 test/helper_test.rb