lib/capybara-extensions.rb in capybara-extensions-0.2.0 vs lib/capybara-extensions.rb in capybara-extensions-0.3.0
- old
+ new
@@ -1,12 +1,30 @@
-require 'rubygems'
require 'capybara'
+require 'capybara_minitest_spec'
-module Capybara
- module Node
- module Finders
- def parent
- find(:xpath, '..')
- end
+module CapybaraExtensions
+ ExtensionMethods = []
+end
+
+require 'capybara-extensions/finders'
+require 'capybara-extensions/matchers'
+
+module Capybara::DSL
+ CapybaraExtensions::ExtensionMethods.each do |method|
+ define_method method do |*args, &block|
+ page.send method, *args, &block
end
end
end
+
+class Capybara::Session
+ CapybaraExtensions::ExtensionMethods.each do |method|
+ define_method method do |*args, &block|
+ current_scope.send method, *args, &block
+ end
+ end
+end
+
+Capybara::Node::Base.send(:include, CapybaraExtensions::Finders)
+Capybara::Node::Base.send(:include, CapybaraExtensions::Matchers)
+Capybara::Node::Simple.send(:include, CapybaraExtensions::Matchers)
+Capybara::Node::Simple.send(:include, CapybaraExtensions::Finders)