Writing up some basic rspecs

dev
Andy Meneely 2014-07-16 11:48:58 -04:00
parent c5bc1fc103
commit 4748f1a32c
5 changed files with 48 additions and 7 deletions

View File

@ -1,6 +1,7 @@
module Squib module Squib
class Deck class Deck
def csv(file: 'deck.csv', header: true) def csv(file: 'deck.csv', header: true)
raise 'Not implemented!'
end end
end end
end end

View File

@ -2,6 +2,7 @@ module Squib
class Deck class Deck
def png(range=:all, file: nil, x: 0, y: 0) def png(range=:all, file: nil, x: 0, y: 0)
raise 'Not implemented!'
end end
end end

View File

@ -1,13 +1,16 @@
module Squib module Squib
class Deck class Deck
def fontify (font) def fontify (font)
font = 'Arial 36' if font==:use_set
font font
end end
def font(type: 'Arial', size: 12, **options) def font(type: 'Arial', size: 12, **options)
raise 'Not implemented!'
end end
def set_font(type: 'Arial', size: 12, **options) def set_font(type: 'Arial', size: 12, **options)
raise 'Not implemented!'
end end
def text(range: :all, str: '', font: :use_set, x: 0, y: 0, **options) def text(range: :all, str: '', font: :use_set, x: 0, y: 0, **options)

View File

@ -1,12 +1,48 @@
require 'squib/deck' require 'squib/deck'
include Squib
describe Deck.new do describe Squib::Deck do
it "initializes with default parameters" do it "initializes with default parameters" do
d = Deck.new d = Squib::Deck.new
expect(d.width).to eq(825) expect(d.width).to eq(825)
expect(d.height).to eq(1125) expect(d.height).to eq(1125)
expect(d.cards).to eq(1) expect(d.cards.size).to eq(1)
end end
end
context "in dealing with ranges" do
it "calls text on all cards by default" do
card1 = instance_double(Squib::Card)
card2 = instance_double(Squib::Card)
expect(card1).to receive(:text).with('blah','Arial 36',0,0,{}).once
expect(card2).to receive(:text).with('blah','Arial 36',0,0,{}).once
Squib::Deck.new do
@cards = [card1, card2]
text str: 'blah'
end
end
it "calls text on some cards with an integer" do
card1 = instance_double(Squib::Card)
card2 = instance_double(Squib::Card)
expect(card2).to receive(:text).with('blah','Arial 36',0,0,{}).once
Squib::Deck.new do
@cards = [card1, card2]
text range: 1, str: 'blah'
end
end
it "calls text with ranges" do
card1 = instance_double(Squib::Card)
card2 = instance_double(Squib::Card)
card3 = instance_double(Squib::Card)
expect(card1).to receive(:text).with('blah','Arial 36',0,0,{}).once
expect(card2).to receive(:text).with('blah','Arial 36',0,0,{}).once
Squib::Deck.new do
@cards = [card1, card2, card3]
text range: 0..1, str: 'blah'
end
end
end
end#describe

View File

@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "bundler", "~> 1.6"
spec.add_development_dependency "rake" spec.add_development_dependency "rake"
spec.add_development_dependency "rspec" spec.add_development_dependency "rspec", "~> 3.0"
end end