Skip to content
Browse files

Delegate index and values_at from Capybara::Result

  • Loading branch information...
1 parent e5108a9 commit 4df077e375da49a814dc1d59c4cb3ab9bf422919 @abotalov abotalov committed Oct 29, 2013
Showing with 12 additions and 1 deletion.
  1. +2 −1 lib/capybara/result.rb
  2. +10 −0 spec/result_spec.rb
View
3 lib/capybara/result.rb
@@ -29,7 +29,8 @@ def initialize(elements, query)
@query = query
end
- def_delegators :@result, :each, :[], :at, :size, :count, :length, :first, :last, :empty?, :inspect, :sample
+ def_delegators :@result, :each, :[], :at, :size, :count, :length,
+ :first, :last, :values_at, :empty?, :inspect, :sample, :index
def matches_count?
Capybara::Helpers.matches_count?(@result.size, @query.options)
View
10 spec/result_spec.rb
@@ -28,6 +28,10 @@
result.last.text == 'Delta'
end
+ it 'can supports values_at method' do
+ result.values_at(0, 2).map(&:text).should == %w(Alpha Gamma)
+ end
+
it "can return an element by its index" do
result.at(1).text.should == 'Beta'
result[2].text.should == 'Gamma'
@@ -52,4 +56,10 @@
it 'can be sampled' do
result.should include(result.sample)
end
+
+ it 'can be indexed' do
+ result.index do |el|
+ el.text == 'Gamma'
+ end.should == 2
+ end
end

0 comments on commit 4df077e

Please sign in to comment.
Something went wrong with that request. Please try again.