mirror of
https://github.com/Shopify/liquid.git
synced 2026-09-26 13:45:13 -07:00
Adding tests, spy dependency
This commit is contained in:
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
|
|||||||
|
|
||||||
gemspec
|
gemspec
|
||||||
gem 'stackprof', platforms: :mri_21
|
gem 'stackprof', platforms: :mri_21
|
||||||
|
|
||||||
|
group :test do
|
||||||
|
gem 'spy', '0.4.1'
|
||||||
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
## 3.0.0 / not yet released / branch "master"
|
## 3.0.0 / not yet released / branch "master"
|
||||||
|
|
||||||
* ...
|
* ...
|
||||||
|
* Optimize checking for block interrupts to reduce object allocation #380 [Jason Hiltz-Laforge, jasonhl]
|
||||||
* Properly set context rethrow_errors on render! #349 [Thierry Joyal, tjoyal]
|
* Properly set context rethrow_errors on render! #349 [Thierry Joyal, tjoyal]
|
||||||
* Fix broken rendering of variables which are equal to false, see #345 [Florian Weingarten, fw42]
|
* Fix broken rendering of variables which are equal to false, see #345 [Florian Weingarten, fw42]
|
||||||
* Remove ActionView template handler [Dylan Thacker-Smith, dylanahsmith]
|
* Remove ActionView template handler [Dylan Thacker-Smith, dylanahsmith]
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ module Liquid
|
|||||||
|
|
||||||
# are there any not handled interrupts?
|
# are there any not handled interrupts?
|
||||||
def has_interrupt?
|
def has_interrupt?
|
||||||
!@interrupts.empty?
|
!@interrupts.empty?
|
||||||
end
|
end
|
||||||
|
|
||||||
# push an interrupt to the stack. this interrupt is considered not handled.
|
# push an interrupt to the stack. this interrupt is considered not handled.
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
require 'test/unit'
|
require 'test/unit'
|
||||||
require 'test/unit/assertions'
|
require 'test/unit/assertions'
|
||||||
|
require 'spy/integration'
|
||||||
|
|
||||||
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
|
||||||
require 'liquid.rb'
|
require 'liquid.rb'
|
||||||
|
|||||||
@@ -70,6 +70,10 @@ class ContextUnitTest < Test::Unit::TestCase
|
|||||||
@context = Liquid::Context.new
|
@context = Liquid::Context.new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def teardown
|
||||||
|
Spy.teardown
|
||||||
|
end
|
||||||
|
|
||||||
def test_variables
|
def test_variables
|
||||||
@context['string'] = 'string'
|
@context['string'] = 'string'
|
||||||
assert_equal 'string', @context['string']
|
assert_equal 'string', @context['string']
|
||||||
@@ -457,4 +461,16 @@ class ContextUnitTest < Test::Unit::TestCase
|
|||||||
assert_kind_of CategoryDrop, @context['category']
|
assert_kind_of CategoryDrop, @context['category']
|
||||||
assert_equal @context, @context['category'].context
|
assert_equal @context, @context['category'].context
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_use_empty_instead_of_any_in_interrupt_handling_to_avoid_lots_of_unnecessary_object_allocations
|
||||||
|
mock_any = Spy.on_instance_method(Array, :any?)
|
||||||
|
mock_empty = Spy.on_instance_method(Array, :empty?)
|
||||||
|
mock_has_interrupt = Spy.on(@context, :has_interrupt?).and_call_through
|
||||||
|
|
||||||
|
@context.has_interrupt?
|
||||||
|
|
||||||
|
refute mock_any.has_been_called?
|
||||||
|
assert mock_empty.has_been_called?
|
||||||
|
end
|
||||||
|
|
||||||
end # ContextTest
|
end # ContextTest
|
||||||
|
|||||||
Reference in New Issue
Block a user