mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Added page to DSL for more expressive tests
e.g. page.should have_content('foo') or assert page.has_content?('foo')
This commit is contained in:
parent
f10e5b4f06
commit
2c86723ea2
2 changed files with 14 additions and 1 deletions
|
@ -30,6 +30,9 @@ module Webcat
|
|||
|
||||
extend(self)
|
||||
|
||||
def page
|
||||
Webcat.current_session
|
||||
end
|
||||
|
||||
SESSION_METHODS = [
|
||||
:visit, :body, :click_link, :click_button, :fill_in, :choose,
|
||||
|
@ -38,7 +41,7 @@ module Webcat
|
|||
SESSION_METHODS.each do |method|
|
||||
class_eval <<-RUBY, __FILE__, __LINE__+1
|
||||
def #{method}(*args, &block)
|
||||
Webcat.current_session.#{method}(*args, &block)
|
||||
page.#{method}(*args, &block)
|
||||
end
|
||||
RUBY
|
||||
end
|
||||
|
|
|
@ -104,6 +104,16 @@ describe Webcat do
|
|||
foo.click_link('ullamco')
|
||||
foo.body.should include('Another World')
|
||||
end
|
||||
|
||||
it "should provide a 'page' shortcut for more expressive tests" do
|
||||
klass = Class.new do
|
||||
include Webcat
|
||||
end
|
||||
foo = klass.new
|
||||
foo.page.visit('/with_html')
|
||||
foo.page.click_link('ullamco')
|
||||
foo.page.body.should include('Another World')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue