shopify_liquid_test_helper 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 84284c898f11a3cdb722b02acd0ec877884b31a05fa0898ab5e7a928e6f20cae
|
4
|
+
data.tar.gz: c998c86408b453d132537b191f94faa96b5cd7f98459e948ccb8a41871fa4a5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 125d273dc6e140eadd9cc06d0cf788948d3ec1cc66089cfc7c3b27da865b0d4d3a83c388a0db69b3634067aeab525cc0e3e21a6cbb181d16bea0c01999935769
|
7
|
+
data.tar.gz: 6716beb9dfa4bfb3c6dc44ecf7bec268642bab035adfb595478e12eea4611bbbf4c2afcbd536976907d78849b7e743175d3c70a9af785dda59285b37919c4a38
|
data/README.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
ShopifyLiquidTestHelper is a Ruby gem designed to assist in testing Shopify Liquid templates. It provides custom Liquid tags and helper methods that simulate Shopify-specific functionality, making it easier to test your Liquid templates in isolation.
|
4
4
|
|
5
|
+
## Tag Status
|
6
|
+
|
7
|
+
| Tag | Status |
|
8
|
+
| --- | ------ |
|
9
|
+
| `render` | ✅ |
|
10
|
+
| `capture` | ✅ |
|
11
|
+
|
12
|
+
|
5
13
|
## Installation
|
6
14
|
|
7
15
|
Add this line to your application's Gemfile:
|
@@ -53,7 +61,7 @@ RSpec.describe "Product template" do
|
|
53
61
|
it "renders the product title" do
|
54
62
|
template = "{% render 'product_title' %}"
|
55
63
|
assigns = { 'product' => { 'title' => 'Awesome T-Shirt' } }
|
56
|
-
result =
|
64
|
+
result = Liquid::Template.parse(template).render(assigns)
|
57
65
|
expect(result).to eq '<h1>Awesome T-Shirt</h1>'
|
58
66
|
end
|
59
67
|
end
|
@@ -70,7 +78,7 @@ RSpec.describe "Collection template" do
|
|
70
78
|
it "renders a list of product titles" do
|
71
79
|
template = "{% render 'product_list' for products %}"
|
72
80
|
assigns = { 'products' => [{ 'title' => 'Shirt' }, { 'title' => 'Pants' }] }
|
73
|
-
result =
|
81
|
+
result = Liquid::Template.parse(template).render(assigns)
|
74
82
|
expect(result).to eq 'ShirtPants'
|
75
83
|
end
|
76
84
|
end
|
@@ -83,7 +91,7 @@ RSpec.describe "Capture tag" do
|
|
83
91
|
it "captures content into a variable" do
|
84
92
|
template = "{% capture my_variable %}Hello, {{ name }}!{% endcapture %}{{ my_variable }}"
|
85
93
|
assigns = { 'name' => 'World' }
|
86
|
-
result =
|
94
|
+
result = Liquid::Template.parse(template).render(assigns)
|
87
95
|
expect(result).to eq 'Hello, World!'
|
88
96
|
end
|
89
97
|
end
|
@@ -121,7 +129,7 @@ RSpec.describe "Product listing" do
|
|
121
129
|
'price' => 1999
|
122
130
|
}
|
123
131
|
}
|
124
|
-
result =
|
132
|
+
result = Liquid::Template.parse(template).render(assigns)
|
125
133
|
expect(result).to include('Awesome T-Shirt')
|
126
134
|
expect(result).to include('Price: $19.99')
|
127
135
|
end
|
@@ -161,7 +169,7 @@ RSpec.describe "Mixed snippet sources" do
|
|
161
169
|
'price' => 2499
|
162
170
|
}
|
163
171
|
}
|
164
|
-
result =
|
172
|
+
result = Liquid::Template.parse(template).render(assigns)
|
165
173
|
expect(result).to include('This is an inline snippet')
|
166
174
|
expect(result).to include('Cool Product')
|
167
175
|
expect(result).to include('Price: $24.99')
|
@@ -10,11 +10,8 @@ module ShopifyLiquidTestHelper
|
|
10
10
|
Liquid::Template.parse(File.read(template_name))
|
11
11
|
end
|
12
12
|
|
13
|
-
def render_template(template, assigns)
|
14
|
-
template.render(assigns).strip
|
15
|
-
end
|
16
|
-
|
17
13
|
def register_custom_tags
|
14
|
+
# TODO: separate tag implementations
|
18
15
|
Liquid::Template.register_tag('render', RenderTag)
|
19
16
|
Liquid::Template.register_tag('capture', CaptureTag)
|
20
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_liquid_test_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Takagiwa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: liquid
|
@@ -65,7 +65,7 @@ files:
|
|
65
65
|
- lib/shopify_liquid_test_helper.rb
|
66
66
|
- lib/shopify_liquid_test_helper/capture_tag.rb
|
67
67
|
- lib/shopify_liquid_test_helper/render_tag.rb
|
68
|
-
- spec/
|
68
|
+
- spec/render_tag_spec.rb
|
69
69
|
- spec/spec_helper.rb
|
70
70
|
homepage: https://github.com/yourusername/shopify_liquid_test_helper
|
71
71
|
licenses:
|