Sha256: 8173251116a17a5b50e08bac585c321e4c6cc64bcd05b7de0d993a6529b0d240

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

RSpec.shared_examples "an OEmbed::Providers instance" do |expected_valid_urls, expected_invalid_urls|
  expected_valid_urls.each do |valid_url|
    context "given the valid URL #{valid_url}" do
      describe ".include?" do
        it "should be true" do
          expect(provider_class.include?(valid_url)).to be_truthy
        end
      end

      describe ".get" do
        it "should return a response" do
          response = nil
          expect {
            response = provider_class.get(valid_url)
          }.to_not raise_error
          expect(response).to be_a(OEmbed::Response)
        end
      end
    end
  end

  expected_invalid_urls.each do |invalid_url|
    context "given the invalid URL #{invalid_url}" do
      describe ".include?" do
        it "should be false" do
          expect(provider_class.include?(invalid_url)).to be_falsey
        end
      end

      describe ".get" do
        it "should not find a response" do
          expect {
            provider_class.get(invalid_url)
          }.to raise_error(OEmbed::NotFound)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ruby-oembed-0.14.1 spec/support/shared_examples_for_providers.rb