-
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #322 from getmango/rc/0.27.0
v0.27.0
- Loading branch information
Showing
28 changed files
with
679 additions
and
223 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ Layout/LineLength: | |
MaxLength: 80 | ||
Excluded: | ||
- src/routes/api.cr | ||
- spec/plugin_spec.cr |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name: mango | ||
version: 0.26.2 | ||
version: 0.27.0 | ||
|
||
authors: | ||
- Alex Ling <hkalexling@gmail.com> | ||
|
Empty file.
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,6 @@ | ||
{ | ||
"id": "test", | ||
"title": "Test Plugin", | ||
"placeholder": "placeholder", | ||
"wait_seconds": 1 | ||
} |
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 |
---|---|---|
@@ -1,14 +1,31 @@ | ||
require "./spec_helper" | ||
|
||
describe Config do | ||
it "creates config if it does not exist" do | ||
with_default_config do |_, path| | ||
it "creates default config if it does not exist" do | ||
with_default_config do |config, path| | ||
File.exists?(path).should be_true | ||
config.port.should eq 9000 | ||
end | ||
end | ||
|
||
it "correctly loads config" do | ||
config = Config.load "spec/asset/test-config.yml" | ||
config.port.should eq 3000 | ||
config.base_url.should eq "/" | ||
end | ||
|
||
it "correctly reads config defaults from ENV" do | ||
ENV["LOG_LEVEL"] = "debug" | ||
config = Config.load "spec/asset/test-config.yml" | ||
config.log_level.should eq "debug" | ||
config.base_url.should eq "/" | ||
end | ||
|
||
it "correctly handles ENV truthiness" do | ||
ENV["CACHE_ENABLED"] = "false" | ||
config = Config.load "spec/asset/test-config.yml" | ||
config.cache_enabled.should be_false | ||
config.cache_log_enabled.should be_true | ||
config.disable_login.should be_false | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
require "./spec_helper" | ||
|
||
describe Plugin do | ||
describe "helper functions" do | ||
it "mango.text" do | ||
with_plugin do |plugin| | ||
res = plugin.eval <<-JS | ||
mango.text('<a href="https://github.com">Click Me<a>'); | ||
JS | ||
res.should eq "Click Me" | ||
end | ||
end | ||
|
||
it "mango.text returns empty string when no text" do | ||
with_plugin do |plugin| | ||
res = plugin.eval <<-JS | ||
mango.text('<img src="https://github.com" />'); | ||
JS | ||
res.should eq "" | ||
end | ||
end | ||
|
||
it "mango.css" do | ||
with_plugin do |plugin| | ||
res = plugin.eval <<-JS | ||
mango.css('<ul><li class="test">A</li><li class="test">B</li><li>C</li></ul>', 'li.test'); | ||
JS | ||
res.should eq ["<li class=\"test\">A</li>", "<li class=\"test\">B</li>"] | ||
end | ||
end | ||
|
||
it "mango.css returns empty array when no match" do | ||
with_plugin do |plugin| | ||
res = plugin.eval <<-JS | ||
mango.css('<ul><li class="test">A</li><li class="test">B</li><li>C</li></ul>', 'li.noclass'); | ||
JS | ||
res.should eq [] of String | ||
end | ||
end | ||
|
||
it "mango.attribute" do | ||
with_plugin do |plugin| | ||
res = plugin.eval <<-JS | ||
mango.attribute('<a href="https://github.com">Click Me<a>', 'href'); | ||
JS | ||
res.should eq "https://github.com" | ||
end | ||
end | ||
|
||
it "mango.attribute returns undefined when no match" do | ||
with_plugin do |plugin| | ||
res = plugin.eval <<-JS | ||
mango.attribute('<div />', 'href') === undefined; | ||
JS | ||
res.should be_true | ||
end | ||
end | ||
|
||
# https://github.com/hkalexling/Mango/issues/320 | ||
it "mango.attribute handles tags in attribute values" do | ||
with_plugin do |plugin| | ||
res = plugin.eval <<-JS | ||
mango.attribute('<div data-a="<img />" data-b="test" />', 'data-b'); | ||
JS | ||
res.should eq "test" | ||
end | ||
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
Oops, something went wrong.