More unit testsgit pull
parent
e835228786
commit
4f575f9761
|
|
@ -89,7 +89,7 @@ module Squib
|
||||||
Dir.mkdir opts[:dir]
|
Dir.mkdir opts[:dir]
|
||||||
return opts
|
return opts
|
||||||
else
|
else
|
||||||
raise "#{opts[:dir]} does not exist!"
|
raise "'#{opts[:dir]}' does not exist!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
module_function :dirify
|
module_function :dirify
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,9 @@ Squib::Deck.new(width: 825, height: 1125, cards: 3) do
|
||||||
text str: "<b>Markup</b> is also <i>quite</i> <s>easy</s> awesome",
|
text str: "<b>Markup</b> is also <i>quite</i> <s>easy</s> awesome",
|
||||||
markup: true,
|
markup: true,
|
||||||
x: 50, y: 1000,
|
x: 50, y: 1000,
|
||||||
font: 'Arial 32'
|
width: 750, height: 100,
|
||||||
|
valign: :bottom,
|
||||||
|
font: 'Arial 32', hint: :cyan
|
||||||
|
|
||||||
save prefix: 'text_', format: :png
|
save prefix: 'text_', format: :png
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,48 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
require 'squib'
|
require 'squib'
|
||||||
|
|
||||||
# describe Squib::Commands::New do
|
describe Squib::Commands::New do
|
||||||
|
|
||||||
# describe "#process" do
|
describe "#process" do
|
||||||
# before(:all) do
|
before(:all) do
|
||||||
# @old_stderr = $stderr
|
@old_stderr = $stderr
|
||||||
# $stderr = StringIO.new
|
$stderr = StringIO.new
|
||||||
# @oldpwd = Dir.pwd
|
@oldpwd = Dir.pwd
|
||||||
# Dir.chdir(File.expand_path('../../samples/_output', File.dirname(__FILE__)))
|
Dir.chdir(File.expand_path('../../samples/_output', File.dirname(__FILE__)))
|
||||||
# end
|
end
|
||||||
|
|
||||||
# before(:each) do
|
before(:each) do
|
||||||
# FileUtils.rm_rf('foo', secure: true)
|
FileUtils.rm_rf('foo', secure: true)
|
||||||
# @cmd = Squib::Commands::New.new
|
@cmd = Squib::Commands::New.new
|
||||||
# end
|
end
|
||||||
|
|
||||||
# it "raises an error if no directory was specified" do
|
it "raises an error if no directory was specified" do
|
||||||
# expect{@cmd.process([])}.to raise_error(ArgumentError, 'Please specify a path.')
|
expect{@cmd.process([])}.to raise_error(ArgumentError, 'Please specify a path.')
|
||||||
# end
|
end
|
||||||
|
|
||||||
# it "creates a new template on an fresh directory" do
|
it "creates a new template on an fresh directory" do
|
||||||
# @cmd.process(['foo'])
|
@cmd.process(['foo'])
|
||||||
# expect(File.exists?('foo/deck.rb')).to be true
|
expect(File.exists?('foo/deck.rb')).to be true
|
||||||
# end
|
end
|
||||||
|
|
||||||
# it "creates a new template on an empty directory" do
|
it "creates a new template on an empty directory" do
|
||||||
# Dir.mkdir('foo')
|
Dir.mkdir('foo')
|
||||||
# @cmd.process(['foo'])
|
@cmd.process(['foo'])
|
||||||
# expect(File.exists?('foo/deck.rb')).to be true
|
expect(File.exists?('foo/deck.rb')).to be true
|
||||||
# end
|
end
|
||||||
|
|
||||||
# it "does not create a new template on an empty " do
|
it "does not create a new template on an empty " do
|
||||||
# Dir.mkdir('foo')
|
Dir.mkdir('foo')
|
||||||
# File.new('foo/somefile.txt', 'w+')
|
File.new('foo/somefile.txt', 'w+')
|
||||||
# @cmd.process(['foo'])
|
@cmd.process(['foo'])
|
||||||
# $stderr.rewind
|
$stderr.rewind
|
||||||
# expect($stderr.string.chomp).to end_with " exists and is not empty. Doing nothing and quitting."
|
expect($stderr.string.chomp).to end_with " exists and is not empty. Doing nothing and quitting."
|
||||||
# end
|
end
|
||||||
|
|
||||||
# after(:all) do
|
after(:all) do
|
||||||
# $stderr = @old_stderr
|
$stderr = @old_stderr
|
||||||
# Dir.chdir(@oldpwd)
|
Dir.chdir(@oldpwd)
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
|
|
||||||
# end
|
end
|
||||||
|
|
@ -52,7 +52,29 @@ describe Squib::InputHelpers do
|
||||||
it "defaults to a range of all cards if :all" do
|
it "defaults to a range of all cards if :all" do
|
||||||
expect(@deck.send(:rangeify, {range: :all})).to eq({range: 0..1})
|
expect(@deck.send(:rangeify, {range: :all})).to eq({range: 0..1})
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "#fileify" do
|
||||||
|
it "should throw an error if the file doesn't exist" do
|
||||||
|
expect{@deck.send(:fileify, {file: 'nonexist.txt'}, false, true)}.to raise_error(RuntimeError,"File #{File.expand_path('nonexist.txt')} does not exist!")
|
||||||
|
end
|
||||||
|
|
||||||
|
it "should expand singletons when asked" do
|
||||||
|
expect(@deck.send(:fileify, {file: 'foo.txt'}, true, false)).to eq({file: ['foo.txt', 'foo.txt']})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "#dir" do
|
||||||
|
it "should raise an error if the directory does not exist" do
|
||||||
|
expect{@deck.send(:dirify, {dir: 'nonexist'}, false)}.to raise_error(RuntimeError,"'nonexist' does not exist!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context "#colorify" do
|
||||||
|
it "should parse if nillable" do
|
||||||
|
color = @deck.send(:colorify, {color: '#fff'}, true)[:color]
|
||||||
|
expect(color.to_a).to eq([1.0, 1.0, 1.0, 1.0])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
Loading…
Reference in New Issue