Sha256: c682a1ba73ffc28a99f0a0f1410577929f89ff6f20e6c299ab7a1c56fc690610

Contents?: true

Size: 1.4 KB

Versions: 48

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).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

48 entries across 48 versions & 1 rubygems

Version Path
onebox-1.5.45 spec/lib/onebox/matcher_spec.rb
onebox-1.5.44 spec/lib/onebox/matcher_spec.rb
onebox-1.5.43 spec/lib/onebox/matcher_spec.rb
onebox-1.5.42 spec/lib/onebox/matcher_spec.rb
onebox-1.5.41 spec/lib/onebox/matcher_spec.rb
onebox-1.5.40 spec/lib/onebox/matcher_spec.rb
onebox-1.5.39 spec/lib/onebox/matcher_spec.rb
onebox-1.5.38 spec/lib/onebox/matcher_spec.rb
onebox-1.5.37 spec/lib/onebox/matcher_spec.rb
onebox-1.5.36 spec/lib/onebox/matcher_spec.rb
onebox-1.5.35 spec/lib/onebox/matcher_spec.rb
onebox-1.5.34 spec/lib/onebox/matcher_spec.rb
onebox-1.5.33 spec/lib/onebox/matcher_spec.rb
onebox-1.5.32 spec/lib/onebox/matcher_spec.rb
onebox-1.5.31 spec/lib/onebox/matcher_spec.rb
onebox-1.5.30 spec/lib/onebox/matcher_spec.rb
onebox-1.5.29 spec/lib/onebox/matcher_spec.rb
onebox-1.5.28 spec/lib/onebox/matcher_spec.rb
onebox-1.5.27 spec/lib/onebox/matcher_spec.rb
onebox-1.5.26 spec/lib/onebox/matcher_spec.rb