repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/hooks/forgetable.rb | lib/devise/hooks/forgetable.rb | # frozen_string_literal: true
# Before logout hook to forget the user in the given scope, if it responds
# to forget_me! Also clear remember token to ensure the user won't be
# remembered again. Notice that we forget the user unless the record is not persisted.
# This avoids forgetting deleted users.
Warden::Manager.b... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/hooks/trackable.rb | lib/devise/hooks/trackable.rb | # frozen_string_literal: true
# After each sign in, update sign in time, sign in count and sign in IP.
# This is only triggered when the user is explicitly set (with set_user)
# and on authentication. Retrieving the user from session (:fetch) does
# not trigger it.
Warden::Manager.after_set_user except: :fetch do |rec... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/test/controller_helpers.rb | lib/devise/test/controller_helpers.rb | # frozen_string_literal: true
module Devise
module Test
# `Devise::Test::ControllerHelpers` provides a facility to test controllers
# in isolation when using `ActionController::TestCase` allowing you to
# quickly sign_in or sign_out a user. Do not use
# `Devise::Test::ControllerHelpers` in integratio... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/test/integration_helpers.rb | lib/devise/test/integration_helpers.rb | # frozen_string_literal: true
module Devise
# Devise::Test::IntegrationHelpers is a helper module for facilitating
# authentication on Rails integration tests to bypass the required steps for
# signin in or signin out a record.
#
# Examples
#
# class PostsTest < ActionDispatch::IntegrationTest
# in... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/lockable.rb | lib/devise/models/lockable.rb | # frozen_string_literal: true
require "devise/hooks/lockable"
module Devise
module Models
# Handles blocking a user access after a certain number of attempts.
# Lockable accepts two different strategies to unlock a user after it's
# blocked: email and time. The former will send an email to the user when... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/validatable.rb | lib/devise/models/validatable.rb | # frozen_string_literal: true
module Devise
module Models
# Validatable creates all needed validations for a user email and password.
# It's optional, given you may want to create the validations by yourself.
# Automatically validate if the email is present, unique and its format is
# valid. Also tes... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/rememberable.rb | lib/devise/models/rememberable.rb | # frozen_string_literal: true
require 'devise/strategies/rememberable'
require 'devise/hooks/rememberable'
require 'devise/hooks/forgetable'
module Devise
module Models
# Rememberable manages generating and clearing token for remembering the user
# from a saved cookie. Rememberable also has utility methods ... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/timeoutable.rb | lib/devise/models/timeoutable.rb | # frozen_string_literal: true
require 'devise/hooks/timeoutable'
module Devise
module Models
# Timeoutable takes care of verifying whether a user session has already
# expired or not. When a session expires after the configured time, the user
# will be asked for credentials again, it means, they will be... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/authenticatable.rb | lib/devise/models/authenticatable.rb | # frozen_string_literal: true
require 'devise/hooks/activatable'
require 'devise/hooks/csrf_cleaner'
module Devise
module Models
# Authenticatable module. Holds common settings for authentication.
#
# == Options
#
# Authenticatable adds the following options to +devise+:
#
# * +authent... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/recoverable.rb | lib/devise/models/recoverable.rb | # frozen_string_literal: true
module Devise
module Models
# Recoverable takes care of resetting the user password and send reset instructions.
#
# ==Options
#
# Recoverable adds the following options to +devise+:
#
# * +reset_password_keys+: the keys you want to use when recovering the... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/confirmable.rb | lib/devise/models/confirmable.rb | # frozen_string_literal: true
module Devise
module Models
# Confirmable is responsible to verify if an account is already confirmed to
# sign in, and to send emails with confirmation instructions.
# Confirmation instructions are sent to the user email after creating a
# record and when manually reque... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/registerable.rb | lib/devise/models/registerable.rb | # frozen_string_literal: true
module Devise
module Models
# Registerable is responsible for everything related to registering a new
# resource (ie user sign up).
module Registerable
extend ActiveSupport::Concern
def self.required_fields(klass)
[]
end
module ClassMethods
... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/database_authenticatable.rb | lib/devise/models/database_authenticatable.rb | # frozen_string_literal: true
require 'devise/strategies/database_authenticatable'
module Devise
module Models
# Authenticatable Module, responsible for hashing the password and
# validating the authenticity of a user while signing in.
#
# This module defines a `password=` method. This method will h... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/omniauthable.rb | lib/devise/models/omniauthable.rb | # frozen_string_literal: true
require 'devise/omniauth'
module Devise
module Models
# Adds OmniAuth support to your model.
#
# == Options
#
# Oauthable adds the following options to +devise+:
#
# * +omniauth_providers+: Which providers are available to this model. It expects an array:
... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/models/trackable.rb | lib/devise/models/trackable.rb | # frozen_string_literal: true
require 'devise/hooks/trackable'
module Devise
module Models
# Track information about your user sign in. It tracks the following columns:
#
# * sign_in_count - Increased every time a sign in is made (by form, openid, oauth)
# * current_sign_in_at - A timestamp upd... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/omniauth/config.rb | lib/devise/omniauth/config.rb | # frozen_string_literal: true
module Devise
module OmniAuth
class StrategyNotFound < NameError
def initialize(strategy)
@strategy = strategy
super("Could not find a strategy with name `#{strategy}'. " \
"Please ensure it is required or explicitly set it using the :strategy_class o... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/omniauth/url_helpers.rb | lib/devise/omniauth/url_helpers.rb | # frozen_string_literal: true
module Devise
module OmniAuth
module UrlHelpers
def omniauth_authorize_path(resource_or_scope, provider, *args)
scope = Devise::Mapping.find_scope!(resource_or_scope)
_devise_route_context.send("#{scope}_#{provider}_omniauth_authorize_path", *args)
end
... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/orm/active_record.rb | lib/devise/orm/active_record.rb | # frozen_string_literal: true
require 'orm_adapter/adapters/active_record'
ActiveSupport.on_load(:active_record) do
extend Devise::Models
end
| ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/orm/mongoid.rb | lib/devise/orm/mongoid.rb | # frozen_string_literal: true
ActiveSupport.on_load(:mongoid) do
require 'orm_adapter/adapters/mongoid'
Mongoid::Document::ClassMethods.send :include, Devise::Models
end
| ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/strategies/rememberable.rb | lib/devise/strategies/rememberable.rb | # frozen_string_literal: true
require 'devise/strategies/authenticatable'
module Devise
module Strategies
# Remember the user through the remember token. This strategy is responsible
# to verify whether there is a cookie with the remember token, and to
# recreate the user from this cookie if it exists. ... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/strategies/base.rb | lib/devise/strategies/base.rb | # frozen_string_literal: true
module Devise
module Strategies
# Base strategy for Devise. Responsible for verifying correct scope and mapping.
class Base < ::Warden::Strategies::Base
# Whenever CSRF cannot be verified, we turn off any kind of storage
def store?
!env["devise.skip_storage"]... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/strategies/authenticatable.rb | lib/devise/strategies/authenticatable.rb | # frozen_string_literal: true
require 'devise/strategies/base'
module Devise
module Strategies
# This strategy should be used as basis for authentication strategies. It retrieves
# parameters both from params or from http authorization headers. See database_authenticatable
# for an example.
class Au... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/strategies/database_authenticatable.rb | lib/devise/strategies/database_authenticatable.rb | # frozen_string_literal: true
require 'devise/strategies/authenticatable'
module Devise
module Strategies
# Default strategy for signing in a user, based on their email and password in the database.
class DatabaseAuthenticatable < Authenticatable
def authenticate!
resource = password.present?... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/lib/devise/mailers/helpers.rb | lib/devise/mailers/helpers.rb | # frozen_string_literal: true
module Devise
module Mailers
module Helpers
extend ActiveSupport::Concern
included do
include Devise::Controllers::ScopedViews
end
protected
attr_reader :scope_name, :resource
# Configure default email options
def devise_mail(rec... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
heartcombo/devise | https://github.com/heartcombo/devise/blob/00a97782cb91104a72ea68d8f62ca8aa0e6eb101/guides/bug_report_templates/integration_test.rb | guides/bug_report_templates/integration_test.rb | # frozen_string_literal: true
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
# Activate the gem you are reporting the issue against.
gem 'rails', '~> 4.2.0'... | ruby | MIT | 00a97782cb91104a72ea68d8f62ca8aa0e6eb101 | 2026-01-04T15:37:27.393664Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/test_helper.rb | test/test_helper.rb | #!/usr/bin/env ruby
# frozen_string_literal: true
ENV["MT_NO_EXPECTATIONS"] = "1"
require 'minitest/autorun'
$LOAD_PATH.unshift(File.join(File.expand_path(__dir__), '..', 'lib'))
require 'liquid.rb'
require 'liquid/profiler'
mode = :strict
if (env_mode = ENV['LIQUID_PARSER_MODE'])
puts "-- #{env_mode.upcase} ERROR... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/trim_mode_test.rb | test/integration/trim_mode_test.rb | # frozen_string_literal: true
require 'test_helper'
class TrimModeTest < Minitest::Test
include Liquid
# Make sure the trim isn't applied to standard output
def test_standard_output
text = <<-END_TEMPLATE
<div>
<p>
{{ 'John' }}
</p>
</div>
END_TEMPLATE
expected... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tag_test.rb | test/integration/tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class TagTest < Minitest::Test
include Liquid
def test_custom_tags_have_a_default_render_to_output_buffer_method_for_backwards_compatibility
klass1 = Class.new(Tag) do
def render(*)
'hello'
end
end
with_custom_tag('blabla', klas... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/parsing_quirks_test.rb | test/integration/parsing_quirks_test.rb | # frozen_string_literal: true
require 'test_helper'
class ParsingQuirksTest < Minitest::Test
include Liquid
def test_parsing_css
text = " div { font-weight: bold; } "
assert_equal(text, Template.parse(text).render!)
end
def test_raise_on_single_close_bracet
assert_raises(SyntaxError) do
Te... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/template_test.rb | test/integration/template_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'timeout'
class TemplateContextDrop < Liquid::Drop
def liquid_method_missing(method)
method
end
def foo
'fizzbuzz'
end
def baz
@context.registers['lulz']
end
end
class SomethingWithLength < Liquid::Drop
def length
nil
end
e... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/variable_test.rb | test/integration/variable_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'timeout'
class VariableTest < Minitest::Test
include Liquid
def test_simple_variable
assert_template_result('worked', "{{test}}", { 'test' => 'worked' })
assert_template_result('worked wonderfully', "{{test}}", { 'test' => 'worked wonderfully' ... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/blank_test.rb | test/integration/blank_test.rb | # frozen_string_literal: true
require 'test_helper'
class FoobarTag < Liquid::Tag
def render_to_output_buffer(_context, output)
output << ' '
output
end
end
class BlankTest < Minitest::Test
include Liquid
N = 10
def wrap_in_for(body)
"{% for i in (1..#{N}) %}#{body}{% endfor %}"
end
def w... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/expression_test.rb | test/integration/expression_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'lru_redux'
class ExpressionTest < Minitest::Test
def test_keyword_literals
assert_template_result("true", "{{ true }}")
assert_expression_result(true, "true")
end
def test_string
assert_template_result("single quoted", "{{'single quoted'}... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/document_test.rb | test/integration/document_test.rb | # frozen_string_literal: true
require 'test_helper'
class DocumentTest < Minitest::Test
include Liquid
def test_unexpected_outer_tag
source = "{% else %}"
assert_match_syntax_error("Liquid syntax error (line 1): Unexpected outer 'else' tag", source)
end
def test_unknown_tag
source = "{% foo %}"
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/filter_kwarg_test.rb | test/integration/filter_kwarg_test.rb | # frozen_string_literal: true
require 'test_helper'
class FilterKwargTest < Minitest::Test
module KwargFilter
def html_tag(_tag, attributes)
attributes
.map { |key, value| "#{key}='#{value}'" }
.join(' ')
end
end
include Liquid
def test_can_parse_data_kwargs
with_global_fil... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/hash_ordering_test.rb | test/integration/hash_ordering_test.rb | # frozen_string_literal: true
require 'test_helper'
class HashOrderingTest < Minitest::Test
module MoneyFilter
def money(input)
format(' %d$ ', input)
end
end
module CanadianMoneyFilter
def money(input)
format(' %d$ CAD ', input)
end
end
include Liquid
def test_global_regist... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/capture_test.rb | test/integration/capture_test.rb | # frozen_string_literal: true
require 'test_helper'
class CaptureTest < Minitest::Test
include Liquid
def test_captures_block_content_in_variable
assert_template_result("test string", "{% capture 'var' %}test string{% endcapture %}{{var}}", {})
end
def test_capture_with_hyphen_in_variable_name
templ... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/filter_test.rb | test/integration/filter_test.rb | # frozen_string_literal: true
require 'test_helper'
module MoneyFilter
def money(input)
format(' %d$ ', input)
end
def money_with_underscore(input)
format(' %d$ ', input)
end
end
module CanadianMoneyFilter
def money(input)
format(' %d$ CAD ', input)
end
end
module SubstituteFilter
def sub... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/context_test.rb | test/integration/context_test.rb | # frozen_string_literal: true
require 'test_helper'
class HundredCentes
def to_liquid
100
end
end
class CentsDrop < Liquid::Drop
def amount
HundredCentes.new
end
def non_zero?
true
end
end
class ContextSensitiveDrop < Liquid::Drop
def test
@context['test']
end
end
class Category
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/hash_rendering_test.rb | test/integration/hash_rendering_test.rb | # frozen_string_literal: true
require 'test_helper'
class HashRenderingTest < Minitest::Test
def test_render_empty_hash
assert_template_result("{}", "{{ my_hash }}", { "my_hash" => {} })
end
def test_render_hash_with_string_keys_and_values
assert_template_result("{\"key1\"=>\"value1\", \"key2\"=>\"valu... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/security_test.rb | test/integration/security_test.rb | # frozen_string_literal: true
require 'test_helper'
module SecurityFilter
def add_one(input)
"#{input} + 1"
end
end
class SecurityTest < Minitest::Test
include Liquid
def setup
@assigns = {}
end
def test_no_instance_eval
text = %( {{ '1+1' | instance_eval }} )
expected = %( 1+1 )
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/output_test.rb | test/integration/output_test.rb | # frozen_string_literal: true
require 'test_helper'
module FunnyFilter
def make_funny(_input)
'LOL'
end
def cite_funny(input)
"LOL: #{input}"
end
def add_smiley(input, smiley = ":-)")
"#{input} #{smiley}"
end
def add_tag(input, tag = "p", id = "foo")
%(<#{tag} id="#{id}">#{input}</#{t... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/assign_test.rb | test/integration/assign_test.rb | # frozen_string_literal: true
require 'test_helper'
class AssignTest < Minitest::Test
include Liquid
def test_assign_with_hyphen_in_variable_name
template_source = <<~END_TEMPLATE
{% assign this-thing = 'Print this-thing' -%}
{{ this-thing -}}
END_TEMPLATE
assert_template_result("Print th... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/block_test.rb | test/integration/block_test.rb | # frozen_string_literal: true
require 'test_helper'
class BlockTest < Minitest::Test
include Liquid
def test_unexpected_end_tag
source = '{% if true %}{% endunless %}'
assert_match_syntax_error("Liquid syntax error (line 1): 'endunless' is not a valid delimiter for if tags. use endif", source)
end
d... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/error_handling_test.rb | test/integration/error_handling_test.rb | # frozen_string_literal: true
require 'test_helper'
class ErrorHandlingTest < Minitest::Test
include Liquid
def test_templates_parsed_with_line_numbers_renders_them_in_errors
template = <<-LIQUID
Hello,
{{ errors.standard_error }} will raise a standard error.
Bla bla test.
{{ error... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/profiler_test.rb | test/integration/profiler_test.rb | # frozen_string_literal: true
require 'test_helper'
class ProfilerTest < Minitest::Test
class TestDrop < Liquid::Drop
def initialize(value)
super()
@value = value
end
def to_s
artificial_execution_time
@value
end
private
# Monotonic clock precision fluctuate based... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/standard_filter_test.rb | test/integration/standard_filter_test.rb | # encoding: utf-8
# frozen_string_literal: true
require 'test_helper'
class TestThing
attr_reader :foo
def initialize
@foo = 0
end
def to_s
"woot: #{@foo}"
end
def [](_whatever)
to_s
end
def to_liquid
@foo += 1
self
end
end
class TestDrop < Liquid::Drop
def initialize(valu... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | true |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/drop_test.rb | test/integration/drop_test.rb | # frozen_string_literal: true
require 'test_helper'
class ContextDrop < Liquid::Drop
def scopes
@context.scopes.size
end
def scopes_as_array
(1..@context.scopes.size).to_a
end
def loop_pos
@context['forloop.index']
end
def liquid_method_missing(method)
@context[method]
end
end
clas... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/include_tag_test.rb | test/integration/tags/include_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class TestFileSystem
PARTIALS = {
"nested_template" => "{% include 'header' %} {% include 'body' %} {% include 'footer' %}",
"body" => "body {% include 'body_detail' %}",
}
def read_template_file(template_path)
PARTIALS[template_path] || template_... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/unless_else_tag_test.rb | test/integration/tags/unless_else_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class UnlessElseTagTest < Minitest::Test
include Liquid
def test_unless
assert_template_result(' ', ' {% unless true %} this text should not go into the output {% endunless %} ')
assert_template_result(
' this text should go into the output ',
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/render_tag_test.rb | test/integration/tags/render_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class RenderTagTest < Minitest::Test
include Liquid
def test_render_with_no_arguments
assert_template_result(
'rendered content',
'{% render "source" %}',
partials: { 'source' => 'rendered content' },
)
end
def test_render_tag_loo... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/break_tag_test.rb | test/integration/tags/break_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class BreakTagTest < Minitest::Test
include Liquid
# tests that no weird errors are raised if break is called outside of a
# block
def test_break_with_no_block
assigns = { 'i' => 1 }
markup = 'before{% break %}after'
expected = 'before'
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/if_else_tag_test.rb | test/integration/tags/if_else_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class IfElseTagTest < Minitest::Test
include Liquid
def test_if
assert_template_result(' ', ' {% if false %} this text should not go into the output {% endif %} ')
assert_template_result(
' this text should go into the output ',
' {% if t... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/statements_test.rb | test/integration/tags/statements_test.rb | # frozen_string_literal: true
require 'test_helper'
class StatementsTest < Minitest::Test
include Liquid
def test_true_eql_true
text = ' {% if true == true %} true {% else %} false {% endif %} '
assert_template_result(' true ', text)
end
def test_true_not_eql_true
text = ' {% if true != true %... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/echo_test.rb | test/integration/tags/echo_test.rb | # frozen_string_literal: true
require 'test_helper'
class EchoTest < Minitest::Test
include Liquid
def test_echo_outputs_its_input
assert_template_result('BAR', <<~LIQUID, { 'variable-name' => 'bar' })
{%- echo variable-name | upcase -%}
LIQUID
end
end
| ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/liquid_tag_test.rb | test/integration/tags/liquid_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class LiquidTagTest < Minitest::Test
include Liquid
def test_liquid_tag
assert_template_result('1 2 3', <<~LIQUID, { 'array' => [1, 2, 3] })
{%- liquid
echo array | join: " "
-%}
LIQUID
assert_template_result('1 2 3', <<~LIQUID,... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/raw_tag_test.rb | test/integration/tags/raw_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class RawTagTest < Minitest::Test
include Liquid
def test_tag_in_raw
assert_template_result(
'{% comment %} test {% endcomment %}',
'{% raw %}{% comment %} test {% endcomment %}{% endraw %}',
)
end
def test_output_in_raw
assert_temp... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/table_row_test.rb | test/integration/tags/table_row_test.rb | # frozen_string_literal: true
require 'test_helper'
class TableRowTest < Minitest::Test
include Liquid
class ArrayDrop < Liquid::Drop
include Enumerable
def initialize(array)
@array = array
end
def each(&block)
@array.each(&block)
end
end
def test_table_row
assert_templ... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/for_tag_test.rb | test/integration/tags/for_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class ThingWithValue < Liquid::Drop
def value
3
end
end
class ForTagTest < Minitest::Test
include Liquid
def test_for
assert_template_result(' yo yo yo yo ', '{%for item in array%} yo {%endfor%}', { 'array' => [1, 2, 3, 4] })
assert_template... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/increment_tag_test.rb | test/integration/tags/increment_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class IncrementTagTest < Minitest::Test
include Liquid
def test_inc
assert_template_result('0 1', '{%increment port %} {{ port }}')
assert_template_result(' 0 1 2', '{{port}} {%increment port %} {%increment port%} {{port}}')
assert_template_result(
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/standard_tag_test.rb | test/integration/tags/standard_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class StandardTagTest < Minitest::Test
include Liquid
def test_no_transform
assert_template_result(
'this text should come out of the template without change...',
'this text should come out of the template without change...',
)
assert_t... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/continue_tag_test.rb | test/integration/tags/continue_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class ContinueTagTest < Minitest::Test
include Liquid
# tests that no weird errors are raised if continue is called outside of a
# block
def test_continue_with_no_block
assigns = {}
markup = '{% continue %}'
expected = ''
assert_template... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/cycle_tag_test.rb | test/integration/tags/cycle_tag_test.rb | # frozen_string_literal: true
require 'test_helper'
class CycleTagTest < Minitest::Test
def test_simple_cycle_inside_for_loop
template = <<~LIQUID
{%- for i in (1..3) -%}
{%- cycle '1', '2', '3' -%}
{%- endfor -%}
LIQUID
assert_template_result("123", template)
end
def test_cycl... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tags/inline_comment_test.rb | test/integration/tags/inline_comment_test.rb | # frozen_string_literal: true
require 'test_helper'
class InlineCommentTest < Minitest::Test
include Liquid
def test_inline_comment_returns_nothing
assert_template_result('', '{%- # this is an inline comment -%}')
assert_template_result('', '{%-# this is an inline comment -%}')
assert_template_result... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/integration/tag/disableable_test.rb | test/integration/tag/disableable_test.rb | # frozen_string_literal: true
require 'test_helper'
class TagDisableableTest < Minitest::Test
include Liquid
module RenderTagName
def render(_context)
tag_name
end
end
class Custom < Tag
prepend Liquid::Tag::Disableable
include RenderTagName
end
class Custom2 < Tag
prepend Liq... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/block_unit_test.rb | test/unit/block_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class BlockUnitTest < Minitest::Test
include Liquid
def test_blankspace
template = Liquid::Template.parse(" ")
assert_equal([" "], template.root.nodelist)
end
def test_variable_beginning
template = Liquid::Template.parse("{{funk}} ")
ass... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/tokenizer_unit_test.rb | test/unit/tokenizer_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class TokenizerTest < Minitest::Test
def test_tokenize_strings
assert_equal([' '], tokenize(' '))
assert_equal(['hello world'], tokenize('hello world'))
assert_equal(['{}'], tokenize('{}'))
end
def test_tokenize_variables
assert_equal(['{{funk... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/strainer_template_unit_test.rb | test/unit/strainer_template_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class StrainerTemplateUnitTest < Minitest::Test
include Liquid
def test_add_filter_when_wrong_filter_class
c = Context.new
s = c.strainer
wrong_filter = lambda(&:reverse)
exception = assert_raises(TypeError) do
s.class.add_filter(wrong_fi... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/i18n_unit_test.rb | test/unit/i18n_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class I18nUnitTest < Minitest::Test
include Liquid
def setup
@i18n = I18n.new(fixture("en_locale.yml"))
end
def test_simple_translate_string
assert_equal("less is more", @i18n.translate("simple"))
end
def test_nested_translate_string
asser... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/lexer_unit_test.rb | test/unit/lexer_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class LexerUnitTest < Minitest::Test
include Liquid
def test_strings
assert_equal(
[[:string, %('this is a test""')], [:string, %("wat 'lol'")], [:end_of_string]],
tokenize(%( 'this is a test""' "wat 'lol'")),
)
end
def test_integer
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/condition_unit_test.rb | test/unit/condition_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class ConditionUnitTest < Minitest::Test
include Liquid
def setup
@context = Liquid::Context.new
end
def test_basic_condition
assert_equal(false, Condition.new(1, '==', 2).evaluate(Context.new))
assert_equal(true, Condition.new(1, '==', 1).eva... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/parse_context_unit_test.rb | test/unit/parse_context_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class ParseContextUnitTest < Minitest::Test
include Liquid
def test_safe_parse_expression_with_variable_lookup
parser_strict = strict_parse_context.new_parser('product.title')
result_strict = strict_parse_context.safe_parse_expression(parser_strict)
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/parser_unit_test.rb | test/unit/parser_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class ParserUnitTest < Minitest::Test
include Liquid
def test_consume
p = new_parser("wat: 7")
assert_equal('wat', p.consume(:id))
assert_equal(':', p.consume(:colon))
assert_equal('7', p.consume(:number))
end
def test_jump
p = new_pars... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/variable_unit_test.rb | test/unit/variable_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class VariableUnitTest < Minitest::Test
include Liquid
def test_variable
var = create_variable('hello')
assert_equal(VariableLookup.new('hello'), var.name)
end
def test_filters
var = create_variable('hello | textileze')
assert_equal(Variabl... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/regexp_unit_test.rb | test/unit/regexp_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
require 'timeout'
class RegexpUnitTest < Minitest::Test
include Liquid
def test_empty
assert_equal([], ''.scan(QuotedFragment))
end
def test_quote
assert_equal(['"arg 1"'], '"arg 1"'.scan(QuotedFragment))
end
def test_words
assert_equal(['... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/environment_test.rb | test/unit/environment_test.rb | # frozen_string_literal: true
require 'test_helper'
class EnvironmentTest < Minitest::Test
include Liquid
class UnsubscribeFooter < Liquid::Tag
def render(_context)
'Unsubscribe Footer'
end
end
def test_custom_tag
email_environment = Liquid::Environment.build do |environment|
environ... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/template_unit_test.rb | test/unit/template_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class TemplateUnitTest < Minitest::Test
include Liquid
def test_sets_default_localization_in_document
t = Template.new
t.parse('{%comment%}{%endcomment%}')
assert_instance_of(I18n, t.root.nodelist[0].options[:locale])
end
def test_sets_default_... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/template_factory_unit_test.rb | test/unit/template_factory_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class TemplateFactoryUnitTest < Minitest::Test
include Liquid
def test_for_returns_liquid_template_instance
template = TemplateFactory.new.for("anything")
assert_instance_of(Liquid::Template, template)
end
end
| ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/registers_unit_test.rb | test/unit/registers_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class RegistersUnitTest < Minitest::Test
include Liquid
def test_set
static_register = Registers.new(a: 1, b: 2)
static_register[:b] = 22
static_register[:c] = 33
assert_equal(1, static_register[:a])
assert_equal(22, static_register[:b])
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/partial_cache_unit_test.rb | test/unit/partial_cache_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class PartialCacheUnitTest < Minitest::Test
def test_uses_the_file_system_register_if_present
context = Liquid::Context.build(
registers: {
file_system: StubFileSystem.new('my_partial' => 'my partial body'),
},
)
partial = Liquid::... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/environment_filter_test.rb | test/unit/environment_filter_test.rb | # frozen_string_literal: true
require 'test_helper'
class EnvironmentFilterTest < Minitest::Test
include Liquid
module AccessScopeFilters
def public_filter
"public"
end
def private_filter
"private"
end
private :private_filter
end
module LateAddedFilter
def late_added_fil... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/tag_unit_test.rb | test/unit/tag_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class TagUnitTest < Minitest::Test
include Liquid
def test_tag
tag = Tag.parse('tag', "", new_tokenizer, ParseContext.new)
assert_equal('liquid::tag', tag.name)
assert_equal('', tag.render(Context.new))
end
def test_return_raw_text_of_tag
t... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/parse_tree_visitor_test.rb | test/unit/parse_tree_visitor_test.rb | # frozen_string_literal: true
require 'test_helper'
class ParseTreeVisitorTest < Minitest::Test
include Liquid
def test_variable
assert_equal(
["test"],
visit(%({{ test }})),
)
end
def test_varible_with_filter
assert_equal(
["test", "infilter"],
visit(%({{ test | split: i... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/file_system_unit_test.rb | test/unit/file_system_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class FileSystemUnitTest < Minitest::Test
include Liquid
def test_default
assert_raises(FileSystemError) do
BlankFileSystem.new.read_template_file("dummy")
end
end
def test_local
file_system = Liquid::LocalFileSystem.new("/some/path")
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/tags/if_tag_unit_test.rb | test/unit/tags/if_tag_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class IfTagUnitTest < Minitest::Test
def test_if_nodelist
template = Liquid::Template.parse('{% if true %}IF{% else %}ELSE{% endif %}')
assert_equal(['IF', 'ELSE'], template.root.nodelist[0].nodelist.map(&:nodelist).flatten)
end
end
| ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/tags/doc_tag_unit_test.rb | test/unit/tags/doc_tag_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class DocTagUnitTest < Minitest::Test
def test_doc_tag
template = <<~LIQUID.chomp
{% doc %}
Renders loading-spinner.
@param {string} foo - some foo
@param {string} [bar] - optional bar
@example
{% render 'loading... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/tags/case_tag_unit_test.rb | test/unit/tags/case_tag_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class CaseTagUnitTest < Minitest::Test
include Liquid
def test_case_nodelist
template = Liquid::Template.parse('{% case var %}{% when true %}WHEN{% else %}ELSE{% endcase %}')
assert_equal(['WHEN', 'ELSE'], template.root.nodelist[0].nodelist.map(&:nodeli... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/tags/for_tag_unit_test.rb | test/unit/tags/for_tag_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class ForTagUnitTest < Minitest::Test
def test_for_nodelist
template = Liquid::Template.parse('{% for item in items %}FOR{% endfor %}')
assert_equal(['FOR'], template.root.nodelist[0].nodelist.map(&:nodelist).flatten)
end
def test_for_else_nodelist
... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/test/unit/tags/comment_tag_unit_test.rb | test/unit/tags/comment_tag_unit_test.rb | # frozen_string_literal: true
require 'test_helper'
class CommentTagUnitTest < Minitest::Test
def test_comment_inside_liquid_tag
assert_template_result("", <<~LIQUID.chomp)
{% liquid
if 1 != 1
comment
else
echo 123
endcomment
endif
%}
LIQUID
en... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/benchmark.rb | performance/benchmark.rb | # frozen_string_literal: true
require 'benchmark/ips'
require_relative 'theme_runner'
RubyVM::YJIT.enable if defined?(RubyVM::YJIT)
Liquid::Environment.default.error_mode = ARGV.first.to_sym if ARGV.first
profiler = ThemeRunner.new
Benchmark.ips do |x|
x.time = 20
x.warmup = 10
puts
puts "Running benchma... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/memory_profile.rb | performance/memory_profile.rb | # frozen_string_literal: true
require 'benchmark/ips'
require 'memory_profiler'
require 'terminal-table'
require_relative 'theme_runner'
class Profiler
LOG_LABEL = "Profiling: ".rjust(14).freeze
REPORTS_DIR = File.expand_path('.memprof', __dir__).freeze
def self.run
puts
yield new
end
def initia... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/profile.rb | performance/profile.rb | # frozen_string_literal: true
require 'stackprof'
require_relative 'theme_runner'
Liquid::Template.error_mode = ARGV.first.to_sym if ARGV.first
profiler = ThemeRunner.new
profiler.run
[:cpu, :object].each do |profile_type|
puts "Profiling in #{profile_type} mode..."
results = StackProf.run(mode: profile_type) do... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/theme_runner.rb | performance/theme_runner.rb | # frozen_string_literal: true
# This profiler run simulates Shopify.
# We are looking in the tests directory for liquid files and render them within the designated layout file.
# We will also export a substantial database to liquid which the templates can render values of.
# All this is to make the benchmark as non sy... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/shopify/paginate.rb | performance/shopify/paginate.rb | # frozen_string_literal: true
class Paginate < Liquid::Block
Syntax = /(#{Liquid::QuotedFragment})\s*(by\s*(\d+))?/
def initialize(tag_name, markup, options)
super
if markup =~ Syntax
@collection_name = Regexp.last_match(1)
@page_size = if Regexp.last_match(2)
Regexp.last_match(... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/shopify/shop_filter.rb | performance/shopify/shop_filter.rb | # frozen_string_literal: true
module ShopFilter
def asset_url(input)
"/files/1/[shop_id]/[shop_id]/assets/#{input}"
end
def global_asset_url(input)
"/global/#{input}"
end
def shopify_asset_url(input)
"/shopify/#{input}"
end
def script_tag(url)
%(<script src="#{url}" type="text/javascri... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/shopify/json_filter.rb | performance/shopify/json_filter.rb | # frozen_string_literal: true
require 'json'
module JsonFilter
def json(object)
JSON.dump(object.reject { |k, _v| k == "collections" })
end
end
| ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/shopify/tag_filter.rb | performance/shopify/tag_filter.rb | # frozen_string_literal: true
module TagFilter
def link_to_tag(label, tag)
"<a title=\"Show tag #{tag}\" href=\"/collections/#{@context['handle']}/#{tag}\">#{label}</a>"
end
def highlight_active_tag(tag, css_class = 'active')
if @context['current_tags'].include?(tag)
"<span class=\"#{css_class}\">... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/shopify/money_filter.rb | performance/shopify/money_filter.rb | # frozen_string_literal: true
module MoneyFilter
def money_with_currency(money)
return '' if money.nil?
format("$ %.2f USD", money / 100.0)
end
def money(money)
return '' if money.nil?
format("$ %.2f", money / 100.0)
end
private
def currency
ShopDrop.new.currency
end
end
| ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/shopify/weight_filter.rb | performance/shopify/weight_filter.rb | # frozen_string_literal: true
module WeightFilter
def weight(grams)
format("%.2f", grams / 1000)
end
def weight_with_unit(grams)
"#{weight(grams)} kg"
end
end
| ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Shopify/liquid | https://github.com/Shopify/liquid/blob/a4a29f3e0836cfd04c1b55b52e92d36914424e7d/performance/shopify/liquid.rb | performance/shopify/liquid.rb | # frozen_string_literal: true
$LOAD_PATH.unshift(__dir__ + '/../../lib')
require_relative '../../lib/liquid'
require_relative 'comment_form'
require_relative 'paginate'
require_relative 'json_filter'
require_relative 'money_filter'
require_relative 'shop_filter'
require_relative 'tag_filter'
require_relative 'weight_... | ruby | MIT | a4a29f3e0836cfd04c1b55b52e92d36914424e7d | 2026-01-04T15:37:46.392600Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.