Refactor add_property
Change implementation of the add_property method which allows for dynamically adding attributes from outside the gem. We made it simpler to construct the args needed for this method and refactored the logic and tests.
This commit is contained in:
parent
5deb796829
commit
e8be12b66e
3 changed files with 33 additions and 11 deletions
|
@ -75,11 +75,17 @@ describe Microformats2::Collection do
|
|||
end
|
||||
|
||||
describe "Format.add_property" do
|
||||
let(:value) { "bar" }
|
||||
before do
|
||||
@collection.first.add_property("p-foo", value)
|
||||
end
|
||||
|
||||
it "creates the attr" do
|
||||
fake_element = OpenStruct.new(inner_text: "dork")
|
||||
fake_text_object = Microformats2::Property::Text.new(fake_element, "p-foo")
|
||||
@collection.first.add_property(fake_text_object)
|
||||
@collection.first.foo.to_s.should == "dork"
|
||||
@collection.first.foo.to_s.should == value
|
||||
end
|
||||
|
||||
it "allows json output of the attribute" do
|
||||
@collection.first.to_json.should include(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue