| 329 | | |
|---|
| 330 | | specify '<r:find>' do |
|---|
| 331 | | page.should render(%{<r:find url="/parent/child/"><r:title /></r:find>}).as('Child') |
|---|
| 332 | | end |
|---|
| 333 | | specify '<r:find> without url' do |
|---|
| 334 | | page.should render(%{<r:find />}).with_error("`find' tag must contain `url' attribute") |
|---|
| 335 | | end |
|---|
| 336 | | specify '<r:find> with nonexistant url' do |
|---|
| 337 | | page.should render(%{<r:find url="/asdfsdf/"><r:title /></r:find>}).as('') |
|---|
| 338 | | end |
|---|
| 339 | | specify '<r:find> with nonexistant url and file not found' do |
|---|
| 340 | | page.should render(%{<r:find url="/gallery/asdfsdf/"><r:title /></r:find>}).as('') |
|---|
| 341 | | end |
|---|
| 342 | | specify '<r:find> with children' do |
|---|
| 343 | | page.should render(%{<r:find url="/parent/"><r:children:each><r:slug /> </r:children:each></r:find>}).as('child child-2 child-3 ') |
|---|
| 344 | | end |
|---|
| 345 | | specify '<r:find> with relative url' do |
|---|
| 346 | | page(:great_grandchild).should render(%{<r:find url="../../../child-2"><r:title/></r:find>}).as("Child 2") |
|---|
| 347 | | end |
|---|
| 348 | | |
|---|
| 349 | | specify '<r:escape_html>' do |
|---|
| | 329 | describe "<r:find>" do |
|---|
| | 330 | it "should change the local page to the page specified in the 'url' attribute" do |
|---|
| | 331 | page.should render(%{<r:find url="/parent/child/"><r:title /></r:find>}).as('Child') |
|---|
| | 332 | end |
|---|
| | 333 | |
|---|
| | 334 | it "should render an error without the 'url' attribute" do |
|---|
| | 335 | page.should render(%{<r:find />}).with_error("`find' tag must contain `url' attribute") |
|---|
| | 336 | end |
|---|
| | 337 | |
|---|
| | 338 | it "should render nothing when the 'url' attribute does not point to a page" do |
|---|
| | 339 | page.should render(%{<r:find url="/asdfsdf/"><r:title /></r:find>}).as('') |
|---|
| | 340 | end |
|---|
| | 341 | |
|---|
| | 342 | it "should render nothing when the 'url' attribute does not point to a page and a custom 404 page exists" do |
|---|
| | 343 | page.should render(%{<r:find url="/gallery/asdfsdf/"><r:title /></r:find>}).as('') |
|---|
| | 344 | end |
|---|
| | 345 | |
|---|
| | 346 | it "should scope contained tags to the found page" do |
|---|
| | 347 | page.should render(%{<r:find url="/parent/"><r:children:each><r:slug /> </r:children:each></r:find>}).as('child child-2 child-3 ') |
|---|
| | 348 | end |
|---|
| | 349 | |
|---|
| | 350 | it "should accept a path relative to the current page" do |
|---|
| | 351 | page(:great_grandchild).should render(%{<r:find url="../../../child-2"><r:title/></r:find>}).as("Child 2") |
|---|
| | 352 | end |
|---|
| | 353 | end |
|---|
| | 354 | |
|---|
| | 355 | it '<r:escape_html> should escape HTML-related characters into entities' do |
|---|
| 357 | | specify '<r:breadcrumbs>' do |
|---|
| 358 | | expected = %{<a href="/">Home</a> > <a href="/parent/">Parent</a> > <a href="/parent/child/">Child</a> > <a href="/parent/child/grandchild/">Grandchild</a> > Great Grandchild} |
|---|
| 359 | | page(:great_grandchild).should render('<r:breadcrumbs />').as(expected) |
|---|
| 360 | | end |
|---|
| 361 | | specify '<r:breadcrumbs> with separator attribute' do |
|---|
| 362 | | expected = %{<a href="/">Home</a> :: Parent} |
|---|
| 363 | | page(:parent).should render('<r:breadcrumbs separator=" :: " />').as(expected) |
|---|
| 364 | | end |
|---|
| 365 | | specify '<r:breadcrumbs> with nolinks attribute' do |
|---|
| 366 | | expected = %{Home > Parent} |
|---|
| 367 | | page(:parent).should render('<r:breadcrumbs nolinks="true" />').as(expected) |
|---|
| 368 | | end |
|---|
| 369 | | specify '<r:breadcrumbs> with a relative URL root should scope to the relative root' do |
|---|
| 370 | | expected = '<a href="/foo/">Home</a> > Assorted' |
|---|
| 371 | | page(:assorted).should render('<r:breadcrumbs />').with_relative_root('/foo').as(expected) |
|---|
| 372 | | end |
|---|
| 373 | | |
|---|
| 374 | | specify '<r:if_url> with "matches" attribute' do |
|---|
| 375 | | page.should render('<r:if_url matches="a.sorted/$">true</r:if_url>').as('true') |
|---|
| 376 | | end |
|---|
| 377 | | specify '<r:if_url> with "matches" attribute that does not match' do |
|---|
| 378 | | page.should render('<r:if_url matches="fancypants">true</r:if_url>').as('') |
|---|
| 379 | | end |
|---|
| 380 | | specify '<r:if_url> with "matches" attribute set to a malformatted regexp' do |
|---|
| 381 | | page.should render('<r:if_url matches="as(sorted/$">true</r:if_url>').with_error("Malformed regular expression in `matches' argument of `if_url' tag: unmatched (: /as(sorted\\/$/") |
|---|
| 382 | | end |
|---|
| 383 | | specify '<r:if_url> without "ignore_case" attribute' do |
|---|
| 384 | | page.should render('<r:if_url matches="asSorted/$">true</r:if_url>').as('true') |
|---|
| 385 | | end |
|---|
| 386 | | specify '<r:if_url> with "ignore_case" attribute set to "true"' do |
|---|
| 387 | | page.should render('<r:if_url matches="asSorted/$" ignore_case="true">true</r:if_url>').as('true') |
|---|
| 388 | | end |
|---|
| 389 | | specify '<r:if_url> with "ignore_case" attribute set to "false"' do |
|---|
| 390 | | page.should render('<r:if_url matches="asSorted/$" ignore_case="false">true</r:if_url>').as('') |
|---|
| 391 | | end |
|---|
| 392 | | specify '<r:if_url> with no attributes' do |
|---|
| 393 | | page.should render('<r:if_url>test</r:if_url>').with_error("`if_url' tag must contain a `matches' attribute.") |
|---|
| | 363 | describe "<r:breadcrumbs>" do |
|---|
| | 364 | it "should render a series of breadcrumb links separated by >" do |
|---|
| | 365 | expected = %{<a href="/">Home</a> > <a href="/parent/">Parent</a> > <a href="/parent/child/">Child</a> > <a href="/parent/child/grandchild/">Grandchild</a> > Great Grandchild} |
|---|
| | 366 | page(:great_grandchild).should render('<r:breadcrumbs />').as(expected) |
|---|
| | 367 | end |
|---|
| | 368 | |
|---|
| | 369 | it "with a 'separator' attribute should use the separator instead of >" do |
|---|
| | 370 | expected = %{<a href="/">Home</a> :: Parent} |
|---|
| | 371 | page(:parent).should render('<r:breadcrumbs separator=" :: " />').as(expected) |
|---|
| | 372 | end |
|---|
| | 373 | |
|---|
| | 374 | it "with a 'nolinks' attribute set to 'true' should not render links" do |
|---|
| | 375 | expected = %{Home > Parent} |
|---|
| | 376 | page(:parent).should render('<r:breadcrumbs nolinks="true" />').as(expected) |
|---|
| | 377 | end |
|---|
| | 378 | |
|---|
| | 379 | it "with a relative URL root should scope links to the relative root" do |
|---|
| | 380 | expected = '<a href="/foo/">Home</a> > Assorted' |
|---|
| | 381 | page(:assorted).should render('<r:breadcrumbs />').with_relative_root('/foo').as(expected) |
|---|
| | 382 | end |
|---|
| | 383 | end |
|---|
| | 384 | |
|---|
| | 385 | describe "<r:if_url>" do |
|---|
| | 386 | describe "with 'matches' attribute" do |
|---|
| | 387 | it "should render the contained block if the page URL matches" do |
|---|
| | 388 | page.should render('<r:if_url matches="a.sorted/$">true</r:if_url>').as('true') |
|---|
| | 389 | end |
|---|
| | 390 | |
|---|
| | 391 | it "should not render the contained block if the page URL does not match" do |
|---|
| | 392 | page.should render('<r:if_url matches="fancypants">true</r:if_url>').as('') |
|---|
| | 393 | end |
|---|
| | 394 | |
|---|
| | 395 | it "set to a malformatted regexp should render an error" do |
|---|
| | 396 | page.should render('<r:if_url matches="as(sorted/$">true</r:if_url>').with_error("Malformed regular expression in `matches' argument of `if_url' tag: unmatched (: /as(sorted\\/$/") |
|---|
| | 397 | end |
|---|
| | 398 | |
|---|
| | 399 | it "without 'ignore_case' attribute should ignore case by default" do |
|---|
| | 400 | page.should render('<r:if_url matches="asSorted/$">true</r:if_url>').as('true') |
|---|
| | 401 | end |
|---|
| | 402 | |
|---|
| | 403 | describe "with 'ignore_case' attribute" do |
|---|
| | 404 | it "set to 'true' should use a case-insensitive match" do |
|---|
| | 405 | page.should render('<r:if_url matches="asSorted/$" ignore_case="true">true</r:if_url>').as('true') |
|---|
| | 406 | end |
|---|
| | 407 | |
|---|
| | 408 | it "set to 'false' should use a case-sensitive match" do |
|---|
| | 409 | page.should render('<r:if_url matches="asSorted/$" ignore_case="false">true</r:if_url>').as('') |
|---|
| | 410 | end |
|---|
| | 411 | end |
|---|
| | 412 | end |
|---|
| | 413 | |
|---|
| | 414 | it "with no attributes should render an error" do |
|---|
| | 415 | page.should render('<r:if_url>test</r:if_url>').with_error("`if_url' tag must contain a `matches' attribute.") |
|---|
| | 416 | end |
|---|
| 409 | | end |
|---|
| 410 | | end |
|---|
| 411 | | |
|---|
| 412 | | specify '<r:unless_url> without "ignore_case" attribute' do |
|---|
| 413 | | page.should render('<r:unless_url matches="asSorted/$">true</r:unless_url>').as('') |
|---|
| 414 | | end |
|---|
| 415 | | specify '<r:unless_url> with "ignore_case" attribute set to "true"' do |
|---|
| 416 | | page.should render('<r:unless_url matches="asSorted/$" ignore_case="true">true</r:unless_url>').as('') |
|---|
| 417 | | end |
|---|
| 418 | | specify '<r:unless_url> with "ignore_case" attribute set to "false"' do |
|---|
| 419 | | page.should render('<r:unless_url matches="asSorted/$" ignore_case="false">true</r:unless_url>').as('true') |
|---|
| 420 | | end |
|---|
| 421 | | specify '<r:unless_url> with no attributes' do |
|---|
| 422 | | page.should render('<r:unless_url>test</r:unless_url>').with_error("`unless_url' tag must contain a `matches' attribute.") |
|---|
| | 432 | |
|---|
| | 433 | it "without 'ignore_case' attribute should ignore case by default" do |
|---|
| | 434 | page.should render('<r:unless_url matches="asSorted/$">true</r:unless_url>').as('') |
|---|
| | 435 | end |
|---|
| | 436 | |
|---|
| | 437 | describe "with 'ignore_case' attribute" do |
|---|
| | 438 | it "set to 'true' should use a case-insensitive match" do |
|---|
| | 439 | page.should render('<r:unless_url matches="asSorted/$">true</r:unless_url>').as('') |
|---|
| | 440 | end |
|---|
| | 441 | |
|---|
| | 442 | it "set to 'false' should use a case-sensitive match" do |
|---|
| | 443 | page.should render('<r:unless_url matches="asSorted/$" ignore_case="false">true</r:unless_url>').as('true') |
|---|
| | 444 | end |
|---|
| | 445 | end |
|---|
| | 446 | end |
|---|
| | 447 | |
|---|
| | 448 | it "with no attributes should render an error" do |
|---|
| | 449 | page.should render('<r:unless_url>test</r:unless_url>').with_error("`unless_url' tag must contain a `matches' attribute.") |
|---|
| | 450 | end |
|---|