Sha256: 3b37320479c79d357ae20065a3627edded14b519c0883fbd3a54fc00a7e826b2

Contents?: true

Size: 976 Bytes

Versions: 2

Compression:

Stored size: 976 Bytes

Contents

require 'bundler/setup'
require 'minitest/autorun'
require 'uri'
require 'action_view'
require 'simple_active_link_to'

class MiniTest::Test

  # need this to simulate requests that drive active_link_helper
  module FakeRequest
    class Request
      attr_accessor :original_fullpath
    end
    def request
      @request ||= Request.new
    end
    def params
      @params ||= {}
    end
  end

  SimpleActiveLinkTo.send :include, FakeRequest

  include ActionView::Helpers::UrlHelper
  include ActionView::Helpers::TagHelper
  include SimpleActiveLinkTo

  def set_path(path, purge_cache = true)
    request.original_fullpath = path
    if purge_cache && defined?(@is_active_link)
      remove_instance_variable(:@is_active_link)
    end
  end

  def assert_html(html, selector, value = nil)
    doc = Nokogiri::HTML(html)
    element = doc.at_css(selector)
    assert element, "No element found at: `#{selector}`"
    assert_equal value, element.text if value
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
simple_active_link_to-1.0.2 test/test_helper.rb
simple_active_link_to-1.0.1 test/test_helper.rb