spec/repeater_spec.rb in prawn-2.0.2 vs spec/repeater_spec.rb in prawn-2.1.0

- old
+ new

@@ -5,32 +5,32 @@ describe "Repeaters" do it "creates a stamp and increments Prawn::Repeater.count on initialize" do orig_count = Prawn::Repeater.count doc = sample_document - doc.expects(:create_stamp).with("prawn_repeater(#{orig_count})") + expect(doc).to receive(:create_stamp).with("prawn_repeater(#{orig_count})") r = repeater(doc, :all) { :do_nothing } expect(Prawn::Repeater.count).to eq(orig_count + 1) end it "must provide an :all filter" do doc = sample_document r = repeater(doc, :all) { :do_nothing } - expect((1..doc.page_count).all? { |i| r.match?(i) }).to be_true + expect((1..doc.page_count).all? { |i| r.match?(i) }).to eq true end it "must provide an :odd filter" do doc = sample_document r = repeater(doc, :odd) { :do_nothing } odd, even = (1..doc.page_count).partition(&:odd?) - expect(odd.all? { |i| r.match?(i) }).to be_true - expect(even.any? { |i| r.match?(i) }).to be_false + expect(odd.all? { |i| r.match?(i) }).to eq true + expect(even.any? { |i| r.match?(i) }).to eq false end it "must be able to filter by an array of page numbers" do doc = sample_document r = repeater(doc, [1, 2, 7]) { :do_nothing } @@ -52,39 +52,39 @@ expect((1..10).select { |i| r.match?(i) }).to eq([1, 3, 6, 9]) end it "must try to run a stamp if the page number matches" do doc = sample_document - doc.expects(:stamp) + expect(doc).to receive(:stamp) repeater(doc, :odd).run(3) end it "must not try to run a stamp unless the page number matches" do doc = sample_document - doc.expects(:stamp).never + expect(doc).to_not receive(:stamp) repeater(doc, :odd).run(2) end it "must not try to run a stamp if dynamic is selected" do doc = sample_document - doc.expects(:stamp).never + expect(doc).to_not receive(:stamp) (1..10).each { |p| repeater(doc, :all, true){ :do_nothing }.run(p) } end it "must try to run a block if the page number matches" do doc = sample_document - doc.expects(:draw_text).twice + expect(doc).to receive(:draw_text).twice (1..10).each { |p| repeater(doc, [1, 2], true){ doc.draw_text "foo" }.run(p) } end it "must not try to run a block unless the page number matches" do doc = sample_document - doc.expects(:draw_text).never + expect(doc).to_not receive(:draw_text) repeater(doc, :odd, true){ doc.draw_text "foo" }.run(2) end it "must treat any block as a closure" do doc = sample_document