diff --git a/test/source/_includes/params.html b/test/source/_includes/params.html new file mode 100644 index 00000000..65a00018 --- /dev/null +++ b/test/source/_includes/params.html @@ -0,0 +1,7 @@ +{{include.param}} + + \ No newline at end of file diff --git a/test/test_tags.rb b/test/test_tags.rb index fd2df409..d0992873 100644 --- a/test/test_tags.rb +++ b/test/test_tags.rb @@ -347,4 +347,94 @@ CONTENT end end end + + context "include tag with parameters" do + context "with one parameter" do + setup do + content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) + end + + should "correctly output include variable" do + assert_match "value", @result.strip + end + + should "ignore parameters if unused" do + assert_match "
\n

Tom Preston-Werner github.com/mojombo

\n", @result + end + end + + context "with invalid parameter syntax" do + should "throw a SyntaxError" do + content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) + end + + content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) + end + end + end + + context "with several parameters" do + setup do + content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) + end + + should "list all parameters" do + assert_match '
  • param1 = new_value
  • ', @result + assert_match '
  • param2 = another
  • ', @result + end + + should "not include previously used parameters" do + assert_match "", @result + end + end + + context "without parameters" do + setup do + content = < 'pretty', 'source' => source_dir, 'destination' => dest_dir, 'read_posts' => true}) + end + + should "include file with empty parameters" do + assert_match "", @result + end + end + end end