Change file closing strategy when persisting a label

Cássio Marques committed Jan 10, 2014
commit 650bb14e6f91abc4c68086f4db90bb24f648a3d2
Showing 3 changed files with 2 additions and 12 deletions
zebra/epl/label.rb b/lib/zebra/epl/label.rb +1 -1
@@ @@ -62,7 +62,7 @@ module Zebra
def persist
tempfile = Tempfile.new "zebra_label"
dump_contents tempfile
- tempfile.rewind
+ tempfile.close
@tempfile = tempfile
tempfile
end
zebra/print_job.rb b/lib/zebra/print_job.rb +1 -6
@@ @@ -16,12 +16,7 @@ module Zebra
def print(label)
tempfile = label.persist
-
- begin
- send_to_printer tempfile.path
- ensure
- tempfile.close
- end
+ send_to_printer tempfile.path
end
private
spec/zebra/epl/label_spec.rb +0 -5
@@ @@ -107,11 +107,6 @@ describe Zebra::Epl::Label do
label.persist.should == tempfile
end
- it "dumps its contents to the tempfile" do
- tempfile.should_receive(:rewind)
- label.persist
- end
-
it "sets the `tempfile` attribute" do
label.persist
label.tempfile.should == tempfile