Skip to content

Instantly share code, notes, and snippets.

@NealJMD
NealJMD / liquid_i18n_spec.rb
Created January 22, 2016 06:37
Rspec tests for LiquidI18n module which allows use of Rails I18n API in liquid templates. LiquidI18n module can be found [here](https://gist.github.com/NealJMD/c340dbe54f46f84fe480).
require 'rails_helper'
describe LiquidI18n do
# to define a liquid filter, you make a module with instance methods that
# gets included by liquid. You can't make them module_functions, so here
# we extend a generic class to call the filter
subject { Class.new.extend(LiquidI18n) }
before :all do
@NealJMD
NealJMD / liquid_i18n.rb
Last active September 20, 2022 14:41
Rails I18n in Liquid templating, including interpolated values. Spec can be found at https://gist.github.com/NealJMD/16cf509164bb71215a87
# The <tt>LiquidI18nRails</tt> module allows us to use the +translate+
# method of Rails' I18n library within liquid templates. To use it,
# simply pass the name of the text entry to the +t+ filter:
#
# {{ 'fundraiser.thank_you' | t }}
#
# The above tag is equivalent to calling:
#
# I18n.t('fundraiser.thank_you')
#
ShareProgress::Button
instance methods
should respond to #page_url
should respond to #page_url=
should respond to #button_template
should respond to #button_template=
should respond to #page_title
should respond to #page_title=
should respond to #share_button_html
should respond to #share_button_html=