Sha256: 0b168281a944f2138ecda24def166963c13a0793a8f0951afb49750d32e4ddbf

Contents?: true

Size: 1.4 KB

Versions: 8

Compression:

Stored size: 1.4 KB

Contents

require "spec_helper"

class TestEngine
  def self.===(uri)
    true
  end
end

describe Onebox::Matcher do

  describe "oneboxed" do

    describe "with a path" do
      let(:url) { "http://party.time.made.up-url.com/beep/boop" }
      let(:matcher) { Onebox::Matcher.new(url) }

      it "finds an engine" do
        matcher.stubs(:ordered_engines).returns([TestEngine])
        expect(matcher.oneboxed).not_to be_nil
      end
    end

    describe "without a path" do
      let(:url) { "http://party.time.made.up-url.com/" }
      let(:matcher) { Onebox::Matcher.new(url) }

      it "doesn't find an engine" do
        matcher.stubs(:ordered_engines).returns([TestEngine])
        expect(matcher.oneboxed).not_to be_nil
      end
    end

    describe "without a path but has a query string" do
      let(:url) { "http://party.time.made.up-url.com/?article_id=1234" }
      let(:matcher) { Onebox::Matcher.new(url) }

      it "it finds an engine" do
        matcher.stubs(:ordered_engines).returns([TestEngine])
        expect(matcher.oneboxed).not_to be_nil
      end
    end

    describe "without a path but has a fragment string" do
      let(:url) { "http://party.time.made.up-url.com/#article_id=1234" }
      let(:matcher) { Onebox::Matcher.new(url) }

      it "it finds an engine" do
        matcher.stubs(:ordered_engines).returns([TestEngine])
        expect(matcher.oneboxed).not_to be_nil
      end
    end

  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
onebox-1.7.7 spec/lib/onebox/matcher_spec.rb
onebox-1.7.6 spec/lib/onebox/matcher_spec.rb
onebox-1.7.5 spec/lib/onebox/matcher_spec.rb
onebox-1.7.4 spec/lib/onebox/matcher_spec.rb
onebox-1.7.3 spec/lib/onebox/matcher_spec.rb
onebox-1.7.2 spec/lib/onebox/matcher_spec.rb
onebox-1.7.1 spec/lib/onebox/matcher_spec.rb
onebox-1.7.0 spec/lib/onebox/matcher_spec.rb