spec/source_spec.rb in pdfkit-0.8.4.1 vs spec/source_spec.rb in pdfkit-0.8.4.2
- old
+ new
@@ -10,10 +10,15 @@
it "returns false if passed a file" do
source = PDFKit::Source.new(File.new(__FILE__))
expect(source).not_to be_url
end
+ it "returns false if passed a tempfile" do
+ source = PDFKit::Source.new(::Tempfile.new(__FILE__))
+ expect(source).not_to be_url
+ end
+
it "returns false if passed HTML" do
source = PDFKit::Source.new('<blink>Oh Hai!</blink>')
expect(source).not_to be_url
end
@@ -27,10 +32,15 @@
it "returns true if passed a file" do
source = PDFKit::Source.new(::File.new(__FILE__))
expect(source).to be_file
end
+ it "returns true if passed a tempfile" do
+ source = PDFKit::Source.new(::Tempfile.new(__FILE__))
+ expect(source).to be_file
+ end
+
it "returns false if passed a url like string" do
source = PDFKit::Source.new('http://google.com')
expect(source).not_to be_file
end
@@ -49,10 +59,15 @@
it "returns false if passed a file" do
source = PDFKit::Source.new(::File.new(__FILE__))
expect(source).not_to be_html
end
+ it "returns false if passed a tempfile" do
+ source = PDFKit::Source.new(::Tempfile.new(__FILE__))
+ expect(source).not_to be_html
+ end
+
it "returns false if passed a url like string" do
source = PDFKit::Source.new('http://google.com')
expect(source).not_to be_html
end
end
@@ -75,10 +90,15 @@
it "returns the file path for file sources" do
source = PDFKit::Source.new(::File.new(__FILE__))
expect(source.to_input_for_command).to match 'spec/source_spec.rb'
end
+
+ it "returns the file path for tempfile sources" do
+ source = PDFKit::Source.new(file = ::Tempfile.new(__FILE__))
+ expect(source.to_input_for_command).to match file.path
+ end
end
describe "#to_s" do
it "returns the HTML if passed HTML" do
source = PDFKit::Source.new('<blink>Oh Hai!</blink>')
@@ -86,9 +106,14 @@
end
it "returns a path if passed a file" do
source = PDFKit::Source.new(::File.new(__FILE__))
expect(source.to_s).to eq(__FILE__)
+ end
+
+ it "returns a path if passed a tempfile" do
+ source = PDFKit::Source.new(file = ::Tempfile.new(__FILE__))
+ expect(source.to_s).to eq(file.path)
end
it "returns the url if passed a url like string" do
source = PDFKit::Source.new('http://google.com')
expect(source.to_s).to eq('http://google.com')