Job persists label before printing

Cássio Marques committed Nov 20, 2013
commit 0020973bc5d5041bceaefdacac8b653790e73a40
Showing 2 changed files with 11 additions and 1 deletions
zebra/print_job.rb b/lib/zebra/print_job.rb +1 -0
@@ @@ -15,6 +15,7 @@ module Zebra
end
def print(label)
+ label.persist! unless label.persisted?
Cups::PrintJob.new(label.path, @printer).print
end
spec/zebra/print_job_spec.rb +10 -1
@@ @@ -16,7 +16,7 @@ describe Zebra::PrintJob do
end
describe "#print" do
- let(:label) { stub :path => "/foo/bar" }
+ let(:label) { stub :path => "/foo/bar", :persisted? => true }
let(:cups_job) { stub :print => true }
subject(:print_job) { described_class.new "Zebra" }
@@ @@ -32,5 +32,14 @@ describe Zebra::PrintJob do
cups_job.should_receive(:print)
print_job.print label
end
+
+ context "when the label is not persisted" do
+ before { label.stub :persisted? => false }
+
+ it "persists the label" do
+ label.should_receive(:persist!)
+ print_job.print label
+ end
+ end
end
end