Adding tests, spy dependency

This commit is contained in:
Jason Hiltz-Laforge
2014-07-16 15:05:45 +00:00
parent 4cfc05e32a
commit fd8c30070a
5 changed files with 23 additions and 1 deletions
+4
View File
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
gemspec
gem 'stackprof', platforms: :mri_21
group :test do
gem 'spy', '0.4.1'
end
+1
View File
@@ -3,6 +3,7 @@
## 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]
* Fix broken rendering of variables which are equal to false, see #345 [Florian Weingarten, fw42]
* Remove ActionView template handler [Dylan Thacker-Smith, dylanahsmith]
+1
View File
@@ -2,6 +2,7 @@
require 'test/unit'
require 'test/unit/assertions'
require 'spy/integration'
$:.unshift(File.join(File.expand_path(File.dirname(__FILE__)), '..', 'lib'))
require 'liquid.rb'
+16
View File
@@ -70,6 +70,10 @@ class ContextUnitTest < Test::Unit::TestCase
@context = Liquid::Context.new
end
def teardown
Spy.teardown
end
def test_variables
@context['string'] = 'string'
assert_equal 'string', @context['string']
@@ -457,4 +461,16 @@ class ContextUnitTest < Test::Unit::TestCase
assert_kind_of CategoryDrop, @context['category']
assert_equal @context, @context['category'].context
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