Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some specs for handling runtime attribute generation
- Loading branch information
1 parent
b36d83a
commit ff91c89
Showing
1 changed file
with
29 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
require 'template' | ||
|
||
describe Template::OutputBuffer do | ||
describe "#attributes" do | ||
it "compiles an empty attribute set as ''" do | ||
attributes({}).should == "" | ||
end | ||
|
||
it "can compile simple attributes" do | ||
result = attributes(name: 'foo', height: '100') | ||
expect(result).to include("name='foo'", "height='100'") | ||
end | ||
|
||
it "skips the attribute for false values" do | ||
result = attributes(name: false) | ||
expect(result).to_not include('name') | ||
end | ||
|
||
it "generates a simple named attribute for true values" do | ||
result = attributes(closable: true) | ||
expect(result).to include('closable') | ||
expect(result).to_not include('closable=') | ||
end | ||
|
||
def attributes(attrs) | ||
subject.attributes({}, nil, attrs) | ||
end | ||
end | ||
end |