Skip to content

Commit

Permalink
Add some specs for handling runtime attribute generation
Browse files Browse the repository at this point in the history
  • Loading branch information
adambeynon committed Jan 9, 2014
1 parent b36d83a commit ff91c89
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions spec/output_buffer_spec.rb
@@ -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

0 comments on commit ff91c89

Please sign in to comment.