Skip to content

Instantly share code, notes, and snippets.

@devton
Created February 10, 2015 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save devton/4ff2b5a547259b8d2cda to your computer and use it in GitHub Desktop.
Save devton/4ff2b5a547259b8d2cda 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