Sha256: cd9b28defcb51240a1c2ae7a5ee27c9f5aee30a593f0b82d107cf32ac02be3e5

Contents?: true

Size: 1.05 KB

Versions: 7

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require "spec_helpers"

describe Wayfarer::Routing::Matchers::Suffix do
  subject(:matcher) { Wayfarer::Routing::Matchers::Suffix.new(".png") }

  describe "#match" do
    context "with matching URL" do
      it "returns true" do
        urls = %w[
          http://example.com/foo.png
          https://example.com/a/b.png/c.png
          http://example.com/foobar.html.png
          https://example.com/foo.png/bar.png
        ].map { |u| Addressable::URI.parse(u) }

        urls.each do |url|
          expect(matcher).to match(url)
        end
      end
    end

    context "with mismatching URL" do
      it "returns false" do
        urls = %w[
          http://example.png
          http://example.com.png
          https://example.com/a/b.png/c
          http://example.com.html
          http://example.com/foobar.html
          https://example.com/foo.png/bar.png.html
        ].map { |u| Addressable::URI.parse(u) }

        urls.each do |url|
          expect(matcher).not_to match(url)
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
wayfarer-0.4.7 spec/routing/matchers/suffix_spec.rb
wayfarer-0.4.6 spec/routing/matchers/suffix_spec.rb
wayfarer-0.4.5 spec/routing/matchers/suffix_spec.rb
wayfarer-0.4.4 spec/routing/matchers/suffix_spec.rb
wayfarer-0.4.3 spec/routing/matchers/suffix_spec.rb
wayfarer-0.4.2 spec/routing/matchers/suffix_spec.rb
wayfarer-0.4.1 spec/routing/matchers/suffix_spec.rb