-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Require liquid-spec to be run on commit automatically and related fixes #2034
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Implement ActiveSupport-compatible behaviors internally so Liquid works
correctly without ActiveSupport being loaded:
1. String first/last via property access (name.first, name.last)
- VariableLookup now handles string[0] and string[-1] for first/last
2. String first/last via filters (name | first, name | last)
- StandardFilters#first and #last now handle strings
3. blank?/empty? comparisons for types without these methods
- Condition now implements liquid_blank? and liquid_empty? internally
- blank? matches ActiveSupport: nil, false, empty/whitespace strings,
empty arrays/hashes are all blank
- empty? checks length == 0 only (whitespace is NOT empty)
This fixes spec failures for templates like:
- {{ name.first }} / {{ name | first }} on strings
- {% if x == blank %} for whitespace strings, empty hashes/arrays
- {% case ' ' %}{% when blank %} matching whitespace
- Add liquid-spec gem from GitHub to :spec group - Create spec/ruby-liquid.rb adapter for the reference implementation - Add spec job to CI workflow to run liquid-spec tests
- nil is NOT empty (but IS blank) - matches Shopify production - String first/last returns '' for empty strings, not nil - matches ActiveSupport - Add test for nil not being empty
Both adapters now pass with 0 failures: - ruby_liquid.rb: 4194 passed (skips activesupport and shopify_error_handling specs) - ruby_liquid_with_active_support.rb: 4203 passed (skips shopify_error_handling specs)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds liquid-spec conformance testing to CI and fixes Liquid to work correctly without ActiveSupport.
Changes
CI Integration
liquid-specgem dependency for conformance testingspecjob to GitHub Actions that runs all adapters inspec/*.rbruby_liquid.rb(without ActiveSupport) andruby_liquid_with_active_support.rbActiveSupport Independence
Liquid historically evolved with ActiveSupport always loaded. This PR makes Liquid work correctly without it by implementing equivalent behaviors internally:
String
first/last-{{ name.first }}and{{ name | first }}now work on strings, returning the first/last character (empty string for empty input, matching ActiveSupport)blank?comparisons -{% if x == blank %}now works for:" ")[],{})nilandfalseempty?comparisons -{% if x == empty %}correctly returnsfalsefornil(nil is blank but not empty)Other Fixes
Test Results
Both adapters pass with 0 failures:
Related PRs
required_featuressupport to liquid-spec