Skip to content

Instantly share code, notes, and snippets.

@smcabrera
Created January 7, 2016 01:05
Show Gist options
  • Select an option

  • Save smcabrera/039d0d11b772401fd801 to your computer and use it in GitHub Desktop.

Select an option

Save smcabrera/039d0d11b772401fd801 to your computer and use it in GitHub Desktop.
require 'spec_helper'
describe 'QuoteExporter' do
describe '#export' do
before do
#test_data = Rails.root.join('spec', 'data', "quote-12345.html")
#allow_any_instance_of(QuoteExporter).to receive(:export)
#.and_return(test_data)
#allow_any_instance_of(SendQuoteUrlToWlAppJob).to receive(:create_quote_url)
#.and_return 'filepicker.io/fakeurl'
@lead = create(:lead)
@exporter = QuoteExporter.new(@lead)
end
it 'should export the latest quote for a lead as a static html file
and return the path to the file' do
html = '<h1>Hello world!</h1>'
sent_email = create(:sent_email, lead_id: @lead.id, html: html)
expected_pathname = Rails.root.join('tmp', 'static-html', "quote-#{@lead.id}.html")
allow(@exporter).to receive(:create_static_html_file).
and_return(pathname)
real_pathname = @exporter.export
file_contents = File.open(pathname).read
expect(file_contents).to include html
cmd = %[ rm #{ pathname} ]
end
it 'should return a message if there is no quote for the lead was found' do
pathname = @exporter.export
file_contents = File.open(pathname).read
expect(file_contents).to include '<span>No Quote Found</span>'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment