Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions library/rexml/element/square_brackets_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
require 'rexml/document'
require File.expand_path('../../../../spec_helper', __FILE__)

describe "REXML::Element#[]" do

before :each do
@doc = REXML::Document.new("<root foo='bar'></root>")
@child = REXML::Element.new("child")
@doc.root.add_element @child
end

ruby_version_is "2.4" do
it "return attribute value if argument is string or symbol" do
@doc.root[:foo].should == 'bar'
@doc.root['foo'].should == 'bar'
end

it "return nth element if argument is int" do
@doc.root[0].should == @child
end
end
end