-
-
Save donfanning/6dd170b1a9272a14eb011cbb197d50ca to your computer and use it in GitHub Desktop.
CrawledUrlSpec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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