spec/input_helpers_spec.rb in squib-0.3.0 vs spec/input_helpers_spec.rb in squib-0.4.0
- old
+ new
@@ -23,15 +23,13 @@
@deck.dpi = 300
end
context '#layoutify' do
it 'warns on the logger when the layout does not exist' do
- mock_squib_logger(@old_logger) do
- expect(Squib.logger).to receive(:warn).with("Layout entry 'foo' does not exist.").twice
- expect(Squib.logger).to receive(:debug)
- expect(@deck.send(:layoutify, {layout: :foo})).to eq({layout: [:foo,:foo]})
- end
+ expect(Squib.logger).to receive(:warn).with("Layout entry 'foo' does not exist.").twice
+ expect(Squib.logger).to receive(:debug)
+ expect(@deck.send(:layoutify, {layout: :foo})).to eq({layout: [:foo,:foo]})
end
it 'applies the layout in a normal situation' do
expect(@deck.send(:layoutify, {layout: :blah})).to \
eq({layout: [:blah, :blah], x: [25, 25]})
@@ -86,15 +84,13 @@
it 'should warn and make a directory creation is allowed' do
opts = {dir: 'tocreate'}
Dir.chdir(output_dir) do
FileUtils.rm_rf('tocreate', secure: true)
- mock_squib_logger(@old_logger) do
- expect(Squib.logger).to receive(:warn).with("Dir 'tocreate' does not exist, creating it.").once
- expect(@deck.send(:dirify, opts, :dir, true)).to eq(opts)
- expect(Dir.exists? 'tocreate').to be true
- end
+ expect(Squib.logger).to receive(:warn).with("Dir 'tocreate' does not exist, creating it.").once
+ expect(@deck.send(:dirify, opts, :dir, true)).to eq(opts)
+ expect(Dir.exists? 'tocreate').to be true
end
end
end
@@ -214,8 +210,29 @@
it 'is false on anything else' do
opts = @deck.send(:faceify, {face: 'flugelhorn'})
expect(opts).to eq({ face: false })
end
+ end
+
+ context '#formatify' do
+ it 'sets format to nil when format is not set' do
+ opts = @deck.send(:formatify, {foo: true})
+ expect(opts).to eq({
+ foo: true,
+ format: [nil]
+ })
+ end
+
+ it 'updates the format to array' do
+ opts = @deck.send(:formatify, {format: :png})
+ expect(opts).to eq({format: [:png]})
+ end
+
+ it 'updates the format to flattened array' do
+ opts = @deck.send(:formatify, {format: [[:png]]})
+ expect(opts).to eq({format: [:png]})
+ end
+
end
end