Sha256: a278b7c077719301d00f660f7e0335db4219ee85240516f754af778b5e40f1b1

Contents?: true

Size: 764 Bytes

Versions: 1

Compression:

Stored size: 764 Bytes

Contents

require "wherelink-matchers/version"
require "capybara"
require "capybara/rspec/matchers"

module Wherelink
  module Matchers
    
    def have_link_to(href)
      LinkToMatcher.new(href)
    end

    class LinkToMatcher
      def initialize(href)
        @href = href
      end

      def matches?(actual)
        Capybara::RSpecMatchers::HaveSelector.new(:link, '', {href: @href}).matches?(actual)
      rescue Capybara::ExpectationNotMet
        return false
      end

      def description
        "have link to \"#{@href}\""
      end

      def failure_message_for_should
        "expected to find a link to \"#{@href}\""
      end

      def failure_message_for_should_not
        "expected not to find a link to \"#{@href}\""
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wherelink-matchers-0.0.1 lib/wherelink-matchers.rb