Sha256: 45c71a2e7c21e180773013bce73c1910e394b2e52af2a502d17670aafa12a9ca
Contents?: true
Size: 1.86 KB
Versions: 3
Compression:
Stored size: 1.86 KB
Contents
shared_examples_for 'a container' do it 'can delete stored item' do container << (element = Weskit::WML::Element.new :foo) expect { container.delete element }.to change { container.contents.size }.by(-1) end it 'can determine if item exists' do container << (element = Weskit::WML::Element.new :foo) container.exists?(element).should be_true end it 'expose attrs and elems' do container << Weskit::WML::Attribute.new(:foo, :bar) container << Weskit::WML::Element.new(:baz) container.should have(2).contents container.should have(1).attrs container.should have(1).elems end it 'expose contents methods' do %w{each empty? first last size to_a}.each do |method| container.should respond_to(method) end end it 'has associated builder' do container.build do key :foo name {} end container[:key].should match_value_of(:foo) container[0].should have_same_identifier_as(:name) end it 'has hash like access' do container << (attribute = Weskit::WML::Attribute.new :foo, :bar) container << (element = Weskit::WML::Element.new :baz) container[:foo].should match_value_of(:bar) container[0].should have_same_representation_as(element) end end shared_examples_for 'a searchable' do specify 'append amending elements' do searchable << Weskit::WML::Element.new(:bar) searchable << sample_amendment searchable.should have(1).elems searchable.find(:bar, false)[:bat].should match_value_of(:baz) end specify 'finds nested elements' do searchable << sample_elements searchable.find(:a, false).find(:b).find(:c).size.should eq(1) end specify 'finds elements recursively' do searchable << sample_elements searchable << Weskit::WML::Element.new(:b) searchable.find_recursively do |item| item.name == :b end.size.should eq(2) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
weskit-0.2.1 | spec/wml_shared_examples.rb |
weskit-0.2.0 | spec/wml_shared_examples.rb |
weskit-0.1.0 | spec/wml_shared_examples.rb |