mirror of
https://github.com/jekyll/jekyll.git
synced 2026-01-09 15:08:08 -05:00
Add test for Jekyll.env
This commit is contained in:
5
test/source/environment.html
Normal file
5
test/source/environment.html
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
title: I'm a Jekyll environment exchequer
|
||||
---
|
||||
|
||||
{{ jekyll.environment }}
|
||||
@@ -137,7 +137,7 @@ class TestFilters < Test::Unit::TestCase
|
||||
assert_equal 2, g["items"].size
|
||||
when ""
|
||||
assert g["items"].is_a?(Array), "The list of grouped items for '' is not an Array."
|
||||
assert_equal 10, g["items"].size
|
||||
assert_equal 11, g["items"].size
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -166,6 +166,7 @@ class TestSite < Test::Unit::TestCase
|
||||
coffeescript.coffee
|
||||
contacts.html
|
||||
deal.with.dots.html
|
||||
environment.html
|
||||
exploit.md
|
||||
foo.md
|
||||
index.html
|
||||
@@ -407,5 +408,35 @@ class TestSite < Test::Unit::TestCase
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
context "manipulating the Jekyll environment" do
|
||||
setup do
|
||||
@site = Site.new(site_configuration)
|
||||
@site.process
|
||||
@page = @site.pages.find { |p| p.name == "environment.html" }
|
||||
end
|
||||
|
||||
should "default to 'development'" do
|
||||
assert_equal "development", @page.content.strip
|
||||
end
|
||||
|
||||
context "in production" do
|
||||
setup do
|
||||
ENV["JEKYLL_ENV"] = "production"
|
||||
@site = Site.new(site_configuration)
|
||||
@site.process
|
||||
@page = @site.pages.find { |p| p.name == "environment.html" }
|
||||
end
|
||||
|
||||
teardown do
|
||||
ENV.delete("JEKYLL_ENV")
|
||||
end
|
||||
|
||||
should "be overridden by JEKYLL_ENV" do
|
||||
assert_equal "production", @page.content.strip
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user