Smart quotes!

Closes #50
This commit is contained in:
Andy Meneely
2015-04-04 16:02:20 -04:00
parent 874bdba8bc
commit 674397c005
8 changed files with 93 additions and 12 deletions
+46
View File
@@ -0,0 +1,46 @@
require 'spec_helper'
require 'squib/args/smart_quotes'
describe Squib::Args::SmartQuotes do
it 'does nothing on a non-quoted string' do
expect(subject.quotify('nothing')).to eq('nothing')
end
it 'left quotes at the beginning' do
expect(subject.quotify('"foo')).to eq("\u201Cfoo")
end
it 'left quotes in the middle of the string' do
expect(subject.quotify('hello "foo')).to eq("hello \u201Cfoo")
end
it 'right quotes at the end of a string' do
expect(subject.quotify('foo"')).to eq("foo\u201D")
end
it 'handles the entire string quoted' do
expect(subject.quotify('"foo"')).to eq("\u201Cfoo\u201D")
end
it "quotes in the middle of the string" do
expect(subject.quotify('hello "foo" world')).to eq("hello \u201Cfoo\u201D world")
end
it "allows custom quotes for different character sets" do
expect(subject.quotify('hello "foo" world', %w({ }))).to eq("hello {foo} world")
end
it "processes dumb quotes" do
expect(subject.process('hello "foo" world', :dumb)).to eq("hello \"foo\" world")
end
it "processes smart quotes" do
expect(subject.process('hello "foo" world', :smart)).to eq("hello \u201Cfoo\u201D world")
end
it "processes custom quotes" do
expect(subject.process('hello "foo" world', %w({ }))).to eq("hello {foo} world")
end
end
+3 -3
View File
@@ -331,7 +331,7 @@ cairo: translate([65, 400])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["This text has fixed width, fixed height, center-aligned, middle-valigned, and has a red hint"])
pango: text=(["This text has fixed width, fixed height, center-aligned, middle-valigned, has a red hint, and \u201Csmart quotes\u201D"])
pango: width=([307200])
pango: height=([128000])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
@@ -354,7 +354,7 @@ cairo: translate([65, 400])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["This text has fixed width, fixed height, center-aligned, middle-valigned, and has a red hint"])
pango: text=(["This text has fixed width, fixed height, center-aligned, middle-valigned, has a red hint, and \u201Csmart quotes\u201D"])
pango: width=([307200])
pango: height=([128000])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])
@@ -377,7 +377,7 @@ cairo: translate([65, 400])
cairo: rotate([0])
cairo: move_to([0, 0])
pango: font_description=([MockDouble])
pango: text=(["This text has fixed width, fixed height, center-aligned, middle-valigned, and has a red hint"])
pango: text=(["This text has fixed width, fixed height, center-aligned, middle-valigned, has a red hint, and \"smart quotes\""])
pango: width=([307200])
pango: height=([128000])
pango: wrap=([#<Pango::Layout::WrapMode word-char>])