Sha256: 1fe49e880c2a7bcfbecb28b4f600525af23e1dac16d2cb2e28b43433515129b9
Contents?: true
Size: 1.4 KB
Versions: 6
Compression:
Stored size: 1.4 KB
Contents
require 'spec_helper' describe Arbre::HTML::Tag, "Attributes" do let(:tag){ Arbre::HTML::Tag.new } describe "attributes" do before { tag.build :id => "my_id" } it "should have an attributes hash" do tag.attributes.should == {:id => "my_id"} end it "should render the attributes to html" do tag.to_s.should == <<-HTML <tag id="my_id"></tag> HTML end it "should get an attribute value" do tag.attr(:id).should == "my_id" end describe "#has_attribute?" do context "when the attribute exists" do it "should return true" do tag.has_attribute?(:id).should == true end end context "when the attribute does not exist" do it "should return false" do tag.has_attribute?(:class).should == false end end end it "should remove an attribute" do tag.attributes.should == {:id => "my_id"} tag.remove_attribute(:id).should == "my_id" tag.attributes.should == {} end end describe "rendering attributes" do it "should html safe the attribute values" do tag.set_attribute(:class, "\">bad things!") tag.to_s.should == <<-HTML <tag class="">bad things!"></tag> HTML end it "should should escape the attribute names" do tag.set_attribute(">bad", "things") tag.to_s.should == <<-HTML <tag >bad="things"></tag> HTML end end end
Version data entries
6 entries across 6 versions & 1 rubygems