Browse Source

spec: add a test for making a new sprue

dev
Andy Meneely 9 years ago
parent
commit
c969f8ecf4
  1. 8
      lib/squib/commands/make_sprue.rb
  2. 38
      spec/commands/make_sprue_spec.rb

8
lib/squib/commands/make_sprue.rb

@ -15,9 +15,9 @@ module Squib
class MakeSprue class MakeSprue
# :nodoc: # :nodoc:
# @api private # @api private
def process(args) def process(args, input = $stdin, output = $stdout)
# Get definitions from the user # Get definitions from the user
@option = prompt @option = prompt(input, output)
@printable_edge_right = ( @printable_edge_right = (
@option.sheet_width - @option.sheet_margin.right) @option.sheet_width - @option.sheet_margin.right)
@ -38,9 +38,9 @@ module Squib
private private
# Accept user input that defines the template. # Accept user input that defines the template.
def prompt def prompt(input, output)
option = TemplateOption.new option = TemplateOption.new
cli = HighLine.new cli = HighLine.new(input, output)
option.unit = cli.choose do |menu| option.unit = cli.choose do |menu|
menu.prompt = 'What measure unit should we use? ' menu.prompt = 'What measure unit should we use? '

38
spec/commands/make_sprue_spec.rb

@ -0,0 +1,38 @@
require 'highline'
require 'spec_helper'
require 'squib'
describe Squib::Commands::MakeSprue do
describe '#process' do
before(:each) do
@in = StringIO.new
@out = StringIO.new
@oldpwd = Dir.pwd
Dir.chdir(output_dir)
end
after(:each) do
Dir.chdir @oldpwd
end
it 'creates a custom sheet based on inputs' do
@in <<
"1\n" << # Units inches
"4\n" << # Paper size A4 landscape
"0.135\n" << # Sheet margins
"3\n" << # Center align cards
"2.2\n" << # Card width
"3.5\n" << # Card height
"0\n" << # Gap
"1\n" << # Layout cards by row
"1\n" << # Generate crop lines
"foo.yml\n" # Output to foo.yml
@in.rewind
subject.process({}, @in, @out)
expect(@out.string).to match(/What measure/)
end
end
end
Loading…
Cancel
Save