Skip to content

Instantly share code, notes, and snippets.

@donfanning
Forked from devton/crawled_url_spec.rb
Created August 15, 2018 13:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donfanning/6dd170b1a9272a14eb011cbb197d50ca to your computer and use it in GitHub Desktop.
Save donfanning/6dd170b1a9272a14eb011cbb197d50ca to your computer and use it in GitHub Desktop.
CrawledUrlSpec
require 'rails_helper'
RSpec.describe CrawledUrl, :type => :model do
describe ".persist_from" do
let(:url) { 'http://www.foo.bar.com/foo-bar#lorem?ipsum=dolor' }
let(:attributes) { ::Crawler::UrlParser.parse url }
subject { CrawledUrl.persist_from url }
context "when url already persisted" do
let(:crawled_url) { create(:crawled_url, attributes) }
before { crawled_url }
it { is_expected.to eq(crawled_url) }
end
context "when url is not persisted" do
it { is_expected.to be_an_instance_of(CrawledUrl) }
end
context "when url as negative expressions" do
before do
create(:negative_expression, {
domains: ['www.foo.bar.com'],
expressions: ['/foo-*']
})
end
it { is_expected.to eq(nil) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment