Skip to content
Open
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
4 changes: 2 additions & 2 deletions lib/retriever/fetchsitemap.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ def initialize(url, options)
@result.uniq!
end

private

# produces valid XML sitemap based on page collection fetched.
# Writes to current directory.
def gen_xml
Expand All @@ -33,6 +31,8 @@ def gen_xml
print_file_info(filename)
end

private

def print_file_info(filename)
puts HR
puts "File Created: sitemap-#{filename}.xml"
Expand Down
21 changes: 21 additions & 0 deletions spec/retriever_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,25 @@
expect(success_resp).to eq(true)
end
end

describe Retriever::FetchSitemap do
let(:options) do
{ limit: 1, progress: false }
end

let(:url) { 'http://www.yahoo.com' }

let(:removed_sitemap) { FileUtils.rm(Dir.pwd + '/sitemap-yahoo.xml').first }

subject { described_class.new(url, options) }

before do
subject.gen_xml
end

it 'generates xml' do
sitemap_file = removed_sitemap
expect(sitemap_file).to match 'sitemap-yahoo.xml'
end
end
end