Rubocop: Using single-quotes properly
This commit is contained in:
@@ -3,7 +3,7 @@ require 'squib'
|
||||
|
||||
describe Squib::Deck, '#text' do
|
||||
|
||||
context "fonts" do
|
||||
context 'fonts' do
|
||||
it "should use the default font when #text and #set_font don't specify" do
|
||||
card = instance_double(Squib::Card)
|
||||
expect(card).to receive(:text).with('a', 'Arial 36',
|
||||
@@ -27,7 +27,7 @@ describe Squib::Deck, '#text' do
|
||||
end
|
||||
end
|
||||
|
||||
it "should use the specified font no matter what" do
|
||||
it 'should use the specified font no matter what' do
|
||||
card = instance_double(Squib::Card)
|
||||
expect(card).to receive(:text).with('a', 'Arial 18',
|
||||
anything, anything, anything, anything,anything,anything,anything, anything, anything,anything, anything, anything, anything, anything, anything
|
||||
|
||||
@@ -3,7 +3,7 @@ require 'squib'
|
||||
|
||||
describe Squib::Commands::New do
|
||||
|
||||
describe "#process" do
|
||||
describe '#process' do
|
||||
before(:all) do
|
||||
@old_stderr = $stderr
|
||||
$stderr = StringIO.new
|
||||
@@ -16,27 +16,27 @@ describe Squib::Commands::New do
|
||||
@cmd = Squib::Commands::New.new
|
||||
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.')
|
||||
end
|
||||
|
||||
it "creates a new template on an fresh directory" do
|
||||
it 'creates a new template on an fresh directory' do
|
||||
@cmd.process(['foo'])
|
||||
expect(File.exists?('foo/deck.rb')).to be true
|
||||
end
|
||||
|
||||
it "creates a new template on an empty directory" do
|
||||
it 'creates a new template on an empty directory' do
|
||||
Dir.mkdir('foo')
|
||||
@cmd.process(['foo'])
|
||||
expect(File.exists?('foo/deck.rb')).to be true
|
||||
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')
|
||||
File.new('foo/somefile.txt', 'w+')
|
||||
@cmd.process(['foo'])
|
||||
$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
|
||||
|
||||
after(:all) do
|
||||
|
||||
+20
-20
@@ -3,15 +3,15 @@ require 'squib/deck'
|
||||
|
||||
describe Squib::Deck do
|
||||
|
||||
it "initializes with default parameters" do
|
||||
it 'initializes with default parameters' do
|
||||
d = Squib::Deck.new
|
||||
expect(d.width).to eq(825)
|
||||
expect(d.height).to eq(1125)
|
||||
expect(d.cards.size).to eq(1)
|
||||
end
|
||||
|
||||
context "in dealing with ranges" do
|
||||
it "calls text on all cards by default" do
|
||||
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).once
|
||||
@@ -22,7 +22,7 @@ describe Squib::Deck do
|
||||
end
|
||||
end
|
||||
|
||||
it "calls text on some cards with an integer" do
|
||||
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).once
|
||||
@@ -32,7 +32,7 @@ describe Squib::Deck do
|
||||
end
|
||||
end
|
||||
|
||||
it "calls text with ranges" do
|
||||
it 'calls text with ranges' do
|
||||
card1 = instance_double(Squib::Card)
|
||||
card2 = instance_double(Squib::Card)
|
||||
card3 = instance_double(Squib::Card)
|
||||
@@ -45,22 +45,22 @@ describe Squib::Deck do
|
||||
end
|
||||
end
|
||||
|
||||
context "#load_layout" do
|
||||
context '#load_layout' do
|
||||
|
||||
it "loads a normal layout with no extends" do
|
||||
it 'loads a normal layout with no extends' do
|
||||
d = Squib::Deck.new(layout: test_file('no-extends.yml'))
|
||||
expect(d.layout).to \
|
||||
eq({'frame' => {
|
||||
'x' => 38,
|
||||
'valign' => :middle,
|
||||
'str' => "blah",
|
||||
'font' => "Mr. Font",
|
||||
'str' => 'blah',
|
||||
'font' => 'Mr. Font',
|
||||
}
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
it "loads with a single extends" do
|
||||
it 'loads with a single extends' do
|
||||
d = Squib::Deck.new(layout: test_file('single-extends.yml'))
|
||||
expect(d.layout).to \
|
||||
eq({'frame' => {
|
||||
@@ -77,7 +77,7 @@ describe Squib::Deck do
|
||||
)
|
||||
end
|
||||
|
||||
it "applies the extends regardless of order" do
|
||||
it 'applies the extends regardless of order' do
|
||||
d = Squib::Deck.new(layout: test_file('pre-extends.yml'))
|
||||
expect(d.layout).to \
|
||||
eq({'frame' => {
|
||||
@@ -94,7 +94,7 @@ describe Squib::Deck do
|
||||
)
|
||||
end
|
||||
|
||||
it "applies the single-level extends multiple times" do
|
||||
it 'applies the single-level extends multiple times' do
|
||||
d = Squib::Deck.new(layout: test_file('single-level-multi-extends.yml'))
|
||||
expect(d.layout).to \
|
||||
eq({'frame' => {
|
||||
@@ -117,7 +117,7 @@ describe Squib::Deck do
|
||||
)
|
||||
end
|
||||
|
||||
it "applies multiple extends in a single rule" do
|
||||
it 'applies multiple extends in a single rule' do
|
||||
d = Squib::Deck.new(layout: test_file('multi-extends-single-entry.yml'))
|
||||
expect(d.layout).to \
|
||||
eq({'aunt' => {
|
||||
@@ -142,7 +142,7 @@ describe Squib::Deck do
|
||||
)
|
||||
end
|
||||
|
||||
it "applies multi-level extends" do
|
||||
it 'applies multi-level extends' do
|
||||
d = Squib::Deck.new(layout: test_file('multi-level-extends.yml'))
|
||||
expect(d.layout).to \
|
||||
eq({'frame' => {
|
||||
@@ -165,22 +165,22 @@ describe Squib::Deck do
|
||||
)
|
||||
end
|
||||
|
||||
it "fails on a self-circular extends" do
|
||||
it 'fails on a self-circular extends' do
|
||||
file = test_file('self-circular-extends.yml')
|
||||
expect { Squib::Deck.new(layout: file) }.to \
|
||||
raise_error(RuntimeError, "Invalid layout: circular extends with 'a'")
|
||||
raise_error(RuntimeError, 'Invalid layout: circular extends with \'a\'')
|
||||
end
|
||||
|
||||
it "fails on a easy-circular extends" do
|
||||
it 'fails on a easy-circular extends' do
|
||||
file = test_file('easy-circular-extends.yml')
|
||||
expect { Squib::Deck.new(layout: file) }.to \
|
||||
raise_error(RuntimeError, "Invalid layout: circular extends with 'a'")
|
||||
raise_error(RuntimeError, 'Invalid layout: circular extends with \'a\'')
|
||||
end
|
||||
|
||||
it "hard on a easy-circular extends" do
|
||||
it 'hard on a easy-circular extends' do
|
||||
file = test_file('hard-circular-extends.yml')
|
||||
expect { Squib::Deck.new(layout: file) }.to \
|
||||
raise_error(RuntimeError, "Invalid layout: circular extends with 'a'")
|
||||
raise_error(RuntimeError, 'Invalid layout: circular extends with \'a\'')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
+20
-20
@@ -28,7 +28,7 @@ describe Squib::InputHelpers do
|
||||
end
|
||||
|
||||
context '#layoutify' do
|
||||
it "warns on the logger when the layout doesn't exist" do
|
||||
it 'warns on the logger when the layout does not exist' do
|
||||
@old_logger = Squib.logger
|
||||
Squib.logger = instance_double(Logger)
|
||||
expect(Squib.logger).to receive(:warn).with("Layout entry 'foo' does not exist.").twice
|
||||
@@ -37,23 +37,23 @@ describe Squib::InputHelpers do
|
||||
Squib.logger = @old_logger
|
||||
end
|
||||
|
||||
it "applies the layout in a normal situation" do
|
||||
it 'applies the layout in a normal situation' do
|
||||
expect(@deck.send(:layoutify, {layout: :blah})).to \
|
||||
eq({layout: [:blah, :blah], x: [25, 25]})
|
||||
end
|
||||
|
||||
it "applies two different layouts for two different situations" do
|
||||
it 'applies two different layouts for two different situations' do
|
||||
expect(@deck.send(:layoutify, {layout: ['blah', 'apples']})).to \
|
||||
eq({layout: ['blah','apples'], x: [25, 35]})
|
||||
end
|
||||
|
||||
it "still has nils when not applied two different layouts differ in structure" do
|
||||
it 'still has nils when not applied two different layouts differ in structure' do
|
||||
expect(@deck.send(:layoutify, {layout: ['apples', 'oranges']})).to \
|
||||
eq({layout: ['apples','oranges'], x: [35], y: [nil, 45]})
|
||||
#...this might behavior that is hard to debug for users. Trying to come up with a warning or something...
|
||||
end
|
||||
|
||||
it "also looks up based on strings" do
|
||||
it 'also looks up based on strings' do
|
||||
expect(@deck.send(:layoutify, {layout: 'blah'})).to \
|
||||
eq({layout: ['blah','blah'], x: [25, 25]})
|
||||
end
|
||||
@@ -61,54 +61,54 @@ describe Squib::InputHelpers do
|
||||
end
|
||||
|
||||
context '#rangeify' do
|
||||
it "must be within the card size range" do
|
||||
it 'must be within the card size range' do
|
||||
expect{@deck.send(:rangeify, {range: 2..3})}.to \
|
||||
raise_error(ArgumentError, '2..3 is outside of deck range of 0..1')
|
||||
end
|
||||
|
||||
it "cannot be nil" do
|
||||
it 'cannot be nil' do
|
||||
expect{@deck.send(:rangeify, {range: nil})}.to \
|
||||
raise_error(RuntimeError, 'Range cannot be nil')
|
||||
end
|
||||
|
||||
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})
|
||||
end
|
||||
end
|
||||
|
||||
context "#fileify" do
|
||||
it "should throw an error if the file doesn't exist" do
|
||||
context '#fileify' do
|
||||
it 'should throw an error if the file does not exist' do
|
||||
expect{@deck.send(:fileify, {file: 'nonexist.txt'}, true)}.to \
|
||||
raise_error(RuntimeError,"File #{File.expand_path('nonexist.txt')} does not exist!")
|
||||
end
|
||||
end
|
||||
|
||||
context "#dir" do
|
||||
it "should raise an error if the directory does not exist" do
|
||||
context '#dir' do
|
||||
it 'should raise an error if the directory does not exist' do
|
||||
expect{@deck.send(:dirify, {dir: 'nonexist'}, :dir, false)}.to \
|
||||
raise_error(RuntimeError,"'nonexist' does not exist!")
|
||||
end
|
||||
end
|
||||
|
||||
context "#colorify" do
|
||||
it "should parse if nillable" do
|
||||
context '#colorify' do
|
||||
it 'should parse if nillable' do
|
||||
color = @deck.send(:colorify, {color: ['#fff']}, true)[:color]
|
||||
expect(color.to_a[0].to_a).to eq([1.0, 1.0, 1.0, 1.0])
|
||||
end
|
||||
|
||||
it "raises and error if the color doesn't exist" do
|
||||
it 'raises and error if the color does not exist' do
|
||||
expect{ @deck.send(:colorify, {color: [:nonexist]}, false) }.to \
|
||||
raise_error(ArgumentError, "unknown color name: nonexist")
|
||||
raise_error(ArgumentError, 'unknown color name: nonexist')
|
||||
end
|
||||
|
||||
it "pulls from config's custom colors" do
|
||||
@deck.custom_colors['foo'] = "#abc"
|
||||
it 'pulls from custom colors in the config' do
|
||||
@deck.custom_colors['foo'] = '#abc'
|
||||
expect(@deck.send(:colorify, {color: [:foo]}, false)[:color][0].to_s).to \
|
||||
eq('#AABBCCFF')
|
||||
end
|
||||
|
||||
it "pulls from config's custom colors even when a string" do
|
||||
@deck.custom_colors['foo'] = "#abc"
|
||||
it 'pulls custom colors even when a string' do
|
||||
@deck.custom_colors['foo'] = '#abc'
|
||||
expect(@deck.send(:colorify, {color: ['foo']}, false)[:color][0].to_s).to \
|
||||
eq('#AABBCCFF')
|
||||
end
|
||||
|
||||
@@ -4,9 +4,9 @@ require 'pp'
|
||||
|
||||
describe Squib do
|
||||
|
||||
context "all samples run without error" do
|
||||
it "should execute with no errors" do
|
||||
p = double("ProgressBar")
|
||||
context 'all samples run without error' do
|
||||
it 'should execute with no errors' do
|
||||
p = double('ProgressBar')
|
||||
allow(ProgressBar).to receive(:create).and_return(Squib::DoNothing.new)
|
||||
samples = File.expand_path('../samples', File.dirname(__FILE__))
|
||||
Dir["#{samples}/**/*.rb"].each do |sample|
|
||||
|
||||
Reference in New Issue
Block a user