spec/components_spec.rb in inky-rb-0.0.2 vs spec/components_spec.rb in inky-rb-0.0.3
- old
+ new
@@ -67,10 +67,29 @@
</tr>
</table>
HTML
compare(input, expected);
end
+
+ it 'creates a button with target="_blank" attribute' do
+ input = '<button href="http://zurb.com" target="_blank">Button</button>'
+ expected = <<-HTML
+ <table class="button">
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <td><a href="http://zurb.com" target="_blank">Button</a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ HTML
+ compare(input, expected)
+ end
+
it 'creates a button with classes' do
input = '<button class="small alert" href="http://zurb.com">Button</button>'
expected = <<-HTML
<table class="button small alert">
<tr>
@@ -133,10 +152,33 @@
HTML
compare(input, expected)
end
+ it 'creates a menu with items tags inside, containing target="_blank" attribute' do
+ input = <<-INKY
+ <menu>
+ <item href="http://zurb.com" target="_blank">Item</item>
+ </menu>
+ INKY
+ expected = <<-HTML
+ <table class="menu">
+ <tr>
+ <td>
+ <table>
+ <tr>
+ <th class="menu-item"><a href="http://zurb.com" target="_blank">Item</a></th>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ </table>
+ HTML
+
+ compare(input, expected)
+ end
+
it 'creates a menu with classes' do
input = <<-INKY
<menu class="vertical">
</menu>
INKY
@@ -223,11 +265,65 @@
</table>
HTML
compare(input, expected);
end
-
+
+ it 'creates a spacer element for small screens with correct size' do
+ input = '<spacer size-sm="10"></spacer>'
+ expected = <<-HTML
+ <table class="spacer hide-for-large">
+ <tbody>
+ <tr>
+ <td height="10px" style="font-size:10px;line-height:10px;"> </td>
+ </tr>
+ </tbody>
+ </table>
+ HTML
+
+ compare(input, expected)
+ end
+
+ it 'creates a spacer element for large screens with correct size' do
+ input = '<spacer size-lg="20"></spacer>'
+ expected = <<-HTML
+ <table class="spacer show-for-large">
+ <tbody>
+ <tr>
+ <td height="20px" style="font-size:20px;line-height:20px;"> </td>
+ </tr>
+ </tbody>
+ </table>
+ HTML
+
+ compare(input, expected)
+ end
+
+ it 'creates a spacer element for small and large screens with correct sizes' do
+ input = '<spacer size-sm="10" size-lg="20"></spacer>'
+ expected = <<-HTML
+ <span>
+ <table class="spacer hide-for-large">
+ <tbody>
+ <tr>
+ <td height="10px" style="font-size:10px;line-height:10px;"> </td>
+ </tr>
+ </tbody>
+ </table>
+ <table class="spacer show-for-large">
+ <tbody>
+ <tr>
+ <td height="20px" style="font-size:20px;line-height:20px;"> </td>
+ </tr>
+ </tbody>
+ </table>
+ </span>
+ HTML
+
+ compare(input, expected)
+ end
+
it 'copies classes to the final spacer HTML' do
input = '<spacer size="10" class="bgcolor"></spacer>'
expected = <<-HTML
<table class="spacer bgcolor">
<tbody>
@@ -252,7 +348,19 @@
</tr>
</table>
HTML
compare(input, expected);
+ end
+end
+
+RSpec.describe "raw" do
+ it 'creates a wrapper that ignores anything inside' do
+ input = "<raw><<LCG Program\TG LCG Coupon Code Default='246996'>></raw>"
+ expected = "<<LCG Program\TG LCG Coupon Code Default='246996'>>"
+
+ # Can't do vanilla compare because the second will fail to parse
+ inky = Inky::Core.new
+ output = inky.release_the_kraken(input)
+ expect(output).to eql(expected)
end
end