File: shared_examples_for_providers.rb

package info (click to toggle)
ruby-oembed 0.12.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 3,468 kB
  • sloc: ruby: 2,351; makefile: 3
file content (39 lines) | stat: -rw-r--r-- 1,096 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
RSpec.shared_examples "an OEmbed::Proviers 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