test/helper.rb in nanoc-3.6.5 vs test/helper.rb in nanoc-3.6.6
- old
+ new
@@ -179,11 +179,11 @@
# Test
b = binding
lines.each_slice(2) do |pair|
actual_out = eval(pair.first, b)
expected_out = eval(pair.last.match(/# ?=>(.*)/)[1], b)
-
+
assert_equal expected_out, actual_out,
"Incorrect example:\n#{pair.first}"
end
end
end
@@ -201,9 +201,17 @@
end
def assert_raises_frozen_error
error = assert_raises(RuntimeError, TypeError) { yield }
assert_match(/(^can't modify frozen |^unable to modify frozen object$)/, error.message)
+ end
+
+ def with_env_vars(hash, &block)
+ orig_env_hash = ENV.to_hash
+ hash.each_pair { |k,v| ENV[k] = v }
+ yield
+ ensure
+ orig_env_hash.each_pair { |k,v| ENV[k] = v }
end
end
class Nanoc::TestCase < MiniTest::Unit::TestCase