Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use Erubis to remove/convert Erb before parsing JSON
- Loading branch information
Noah Gibbs
committed
Oct 19, 2011
1 parent
479f5ed
commit 97d0c92
Showing
8 changed files
with
83 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require File.join(File.dirname(__FILE__), "test_helper.rb") | ||
require "multi_json" | ||
|
||
class ErubisTest < Scope::TestCase | ||
setup do | ||
Ecology.reset | ||
end | ||
|
||
context "with a .erb ecology" do | ||
setup do | ||
set_up_ecology(<<ECOLOGY_CONTENTS, "some_app.ecology.erb") | ||
{ | ||
"application": "SomeApp", | ||
"domain": { | ||
"property1" : | ||
<% if ENV["BOBO"] %> | ||
37 | ||
<% else %> | ||
42 | ||
<% end %> | ||
}, | ||
"bobo": <%= MultiJson.encode(ENV["BOBO"]) %> | ||
} | ||
ECOLOGY_CONTENTS | ||
|
||
ENV["BOBO"] = nil | ||
end | ||
|
||
should "Parse conditionally with Erubis" do | ||
ENV["BOBO"] = "true" | ||
Ecology.read | ||
assert_equal 37, Ecology.property("domain::property1") | ||
end | ||
|
||
should "Parse conditionally with Erubis when a variable is unset" do | ||
Ecology.read | ||
assert_equal 42, Ecology.property("domain::property1") | ||
end | ||
|
||
# should "Return values from Erubis" do | ||
# ENV["BOBO"] = { "a" => "b", "c" => "d" } | ||
# Ecology.read | ||
# assert_equal { "a" => "b", "c" => "d" }, Ecology.property("bobo") | ||
# end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters