Sha256: 6e6b34089bb0dd1af7ae392f1bece15a3b95a611ea3cd05aa8710cce0e2c7d70

Contents?: true

Size: 1.38 KB

Versions: 12

Compression:

Stored size: 1.38 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])
        matcher.oneboxed.should_not 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])
        matcher.oneboxed.should 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])
        matcher.oneboxed.should_not 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])
        matcher.oneboxed.should_not be_nil
      end
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
onebox-1.5.17 spec/lib/onebox/matcher_spec.rb
onebox-1.5.16 spec/lib/onebox/matcher_spec.rb
onebox-1.5.14 spec/lib/onebox/matcher_spec.rb
onebox-1.5.13 spec/lib/onebox/matcher_spec.rb
onebox-1.5.12 spec/lib/onebox/matcher_spec.rb
onebox-1.5.11 spec/lib/onebox/matcher_spec.rb
onebox-1.5.10 spec/lib/onebox/matcher_spec.rb
onebox-1.5.9 spec/lib/onebox/matcher_spec.rb
onebox-1.5.8 spec/lib/onebox/matcher_spec.rb
onebox-1.5.7 spec/lib/onebox/matcher_spec.rb
onebox-1.5.6 spec/lib/onebox/matcher_spec.rb
onebox-1.5.5 spec/lib/onebox/matcher_spec.rb