Created
February 10, 2015 22:59
-
-
Save devton/61665256894985a2be20 to your computer and use it in GitHub Desktop.
Crawler::UrlParser spec
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 Crawler::UrlParser, :type => :service do | |
describe ".parse" do | |
subject { Crawler::UrlParser.parse url } | |
context "normal url" do | |
let(:url) { 'www.my-example.url.com' } | |
let(:url_attributes) { | |
{ | |
url_scheme: 'http', | |
host: 'www.my-example.url.com', | |
path: '/', | |
fragment: nil, | |
query_strings: nil | |
} | |
} | |
it { is_expected.to eq(url_attributes) } | |
end | |
context "with fragments" do | |
let(:url) { 'www.my-example.url.com/#!/foo/bar' } | |
let(:url_attributes) { | |
{ | |
url_scheme: 'http', | |
host: 'www.my-example.url.com', | |
path: '/', | |
fragment: '#!/foo/bar', | |
query_strings: nil | |
} | |
} | |
it { is_expected.to eq(url_attributes) } | |
end | |
context "with query strings" do | |
let(:url) { 'www.my-example.url.com/?foo=bar&bar=foo' } | |
let(:url_attributes) { | |
{ | |
url_scheme: 'http', | |
host: 'www.my-example.url.com', | |
path: '/', | |
fragment: nil, | |
query_strings: 'foo=bar&bar=foo' | |
} | |
} | |
it { is_expected.to eq(url_attributes) } | |
end | |
context "complex with query and fragments" do | |
let(:url) { 'www.my-example.url.com/#!/foo/bar?foo=bar&bar=foo' } | |
let(:url_attributes) { | |
{ | |
url_scheme: 'http', | |
host: 'www.my-example.url.com', | |
path: '/', | |
fragment: '#!/foo/bar', | |
query_strings: 'foo=bar&bar=foo' | |
} | |
} | |
it { is_expected.to eq(url_attributes) } | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment