Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ gem 'bundler', '>= 2.2.33'
gem 'guard-rspec'
gem 'rake'
gem 'rspec'
gem 'vcr'
gem 'webmock'
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,8 @@ Once development dependencies are installed, all unit tests are run with just:
# or..
$ rake spec

Unit tests exclude a set of integration tests that actually hit the network (therefore not 'nice' to run all the time,
and also subject to failures due to network availability or changes in the services accessed). To run integration tests:

rake spec:integration

To run all tests (unit and integration):

rake spec:all
VCR is used to record integration tests. To re-record sessions, delete the corresponding cassette in
[spec/fixtures/cassettes](./spec/fixtures/cassettes/).

### How do I automatically run tests when I modify files?

Expand Down
23 changes: 3 additions & 20 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,26 +1,9 @@
#!/usr/bin/env rake
require "bundler/gem_tasks"
# frozen_string_literal: true

require 'rspec'
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'

desc "Run only unit test examples"
RSpec::Core::RakeTask.new do |t|
t.rspec_opts = ["-c", "-f progress"]
t.pattern = 'spec/unit/**/*_spec.rb'
end

desc "Run only integration test examples"
RSpec::Core::RakeTask.new(:'spec:integration') do |t|
t.rspec_opts = ["-c", "-f progress"]
t.pattern = 'spec/integration/**/*_spec.rb'
end

desc "Run all test examples including integration tests"
RSpec::Core::RakeTask.new(:'spec:all') do |t|
t.rspec_opts = ["-c", "-f progress"]
t.pattern = 'spec/**/*_spec.rb'
end
RSpec::Core::RakeTask.new(:spec)

task default: :spec

Expand Down
2,298 changes: 2,298 additions & 0 deletions spec/fixtures/cassettes/feed/is_atom_feed.yml

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions spec/fixtures/cassettes/feed/is_rss_feed.yml

Large diffs are not rendered by default.

69 changes: 69 additions & 0 deletions spec/fixtures/cassettes/feed/no_feed.yml

Large diffs are not rendered by default.

154 changes: 154 additions & 0 deletions spec/fixtures/cassettes/feed/no_oembed.yml

Large diffs are not rendered by default.

1,471 changes: 1,471 additions & 0 deletions spec/fixtures/cassettes/feed/with_atom_and_rss_feed.yml

Large diffs are not rendered by default.

47 changes: 47 additions & 0 deletions spec/fixtures/cassettes/feed/with_rss_feed.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 26 additions & 25 deletions spec/integration/feed_spec.rb
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
require 'spec_helper'

# These tests hit real network endpoints - not included in the default test runs. Run with:
# rake spec:integration
# or
# rake spec:all
#
describe Earl do
subject(:instance) { Earl[url] }

context "when page has no feeds associated" do
let(:url) { 'https://google.com/' }
vcr_base = 'feed'

context 'when page has no feeds associated', vcr: { cassette_name: "#{vcr_base}/no_feed" } do
let(:url) { 'https://www.google.com/' }
it { expect(subject.has_feed?).to be false }
it { expect(subject.rss_feed).to be_nil }
it { expect(subject.feed).to be_nil }
end

context "when page has rss feed associated" do
context "when page has rss feed associated", vcr: { cassette_name: "#{vcr_base}/with_rss_feed" } do
let(:url) { 'https://rubyweekly.com/' }
it { expect(subject.has_feed?).to be true }
it { expect(subject.rss_feed).to eql('/rss/') }
it { expect(subject.feed).to eql('/rss/') }
end

# context "when page has atom feed associated" do
# let(:url) { 'http:// still looking for a page that just has atom' }
# its(:has_feed?) { should be_true }
# its(:atom_feed) { should eql('http://www.readwriteweb.com/atom.xml') }
# its(:feed) { should eql('http://www.readwriteweb.com/atom.xml') }
# end
# # context "when page has atom feed associated" do
# # let(:url) { 'http:// still looking for a page that just has atom' }
# # { expect(subject.has_feed?).to be true }
# # { expect(subject.atom_feed).to eql('http://www.readwriteweb.com/atom.xml') }
# # { expect(subject.feed).to eql('http://www.readwriteweb.com/atom.xml') }
# # end

context "when page has rss and atom feed associated" do
context "when page has rss and atom feed associated", vcr: { cassette_name: "#{vcr_base}/with_atom_and_rss_feed" } do
let(:url) { 'https://0xfe.blogspot.com/' }
let(:expected_rss_feed) { 'https://0xfe.blogspot.com/feeds/posts/default?alt=rss' }
let(:expected_atom_feed) { 'https://0xfe.blogspot.com/feeds/posts/default' }
Expand All @@ -53,17 +50,21 @@
end
end

# context "when page IS an rss feed" do
# let(:url) { 'https://cprss.s3.amazonaws.com/rubyweekly.com.xml' }
# it { expect(subject.url).to eql(url) }
# it { expect(subject.base_url).to eql(url) }
# it { expect(subject.content_type).to eql('application/xml') }
# it { expect(subject.has_feed?).to be true }
# it { expect(subject.rss_feed).to eql(url) }
# it { expect(subject.feed).to eql(url) }
# end
context "when page IS an rss feed", vcr: { cassette_name: "#{vcr_base}/is_rss_feed" } do
let(:url) { 'https://cprss.s3.amazonaws.com/rubyweekly.com.xml' }
it { expect(subject.url).to eql(url) }
it { expect(subject.base_url).to eql(url) }
it { expect(subject.content_type).to eql('application/xml') }
# TODO: fix rss feed detection
# it { expect(subject.has_feed?).to be true }
# it { expect(subject.rss_feed).to eql(url) }
# it { expect(subject.feed).to eql(url) }
it { expect(subject.has_feed?).to be false }
it { expect(subject.rss_feed).to be_nil }
it { expect(subject.feed).to be_nil }
end

context "when page IS an atom feed" do
context "when page IS an atom feed", vcr: { cassette_name: "#{vcr_base}/is_atom_feed" } do
let(:url) { 'https://0xfe.blogspot.com/feeds/posts/default' }
it { expect(subject.url).to eql(url) }
it { expect(subject.base_url).to eql(url) }
Expand Down
12 changes: 5 additions & 7 deletions spec/integration/oembed_spec.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
require 'spec_helper'

# These tests hit real network endpoints - not included in the default test runs. Run with:
# rake spec:integration
# or
# rake spec:all
#
describe Earl do
subject(:instance) { Earl[url] }

context "when page does not support oembed" do
vcr_base = 'feed'

context "when page does not support oembed", vcr: { cassette_name: "#{vcr_base}/no_oembed" } do
let(:url) { 'https://github.com/evendis/earl' }
it { expect(subject.oembed).to eql({error: 'no matching providers found', url: 'https://github.com/evendis/earl'}) }
it { expect(subject.oembed_html).to be_nil }
Expand All @@ -20,7 +17,8 @@
end
end

# context "when page supports oembed" do
# TODO: oembed support needs fixing
# context "when youtube oembed", vcr: { cassette_name: "#{vcr_base}/youtube_oembed" } do
# let(:url) { 'https://www.youtube.com/watch?v=g3DCEcSlfhw' }
# let(:expected_oembed_html) { %(<iframe width="420" height="315" src="http://www.youtube.com/embed/g3DCEcSlfhw?fs=1&feature=oembed" frameborder="0" allowfullscreen></iframe>) }

Expand Down
7 changes: 7 additions & 0 deletions spec/support/vcr.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'vcr'

VCR.configure do |config|
config.cassette_library_dir = 'spec/fixtures/cassettes'
config.hook_into :webmock
config.configure_rspec_metadata!
end