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)
|
extend(self)
|
||||||
|
|
||||||
|
def page
|
||||||
|
Webcat.current_session
|
||||||
|
end
|
||||||
|
|
||||||
SESSION_METHODS = [
|
SESSION_METHODS = [
|
||||||
:visit, :body, :click_link, :click_button, :fill_in, :choose,
|
:visit, :body, :click_link, :click_button, :fill_in, :choose,
|
||||||
|
@ -38,7 +41,7 @@ module Webcat
|
||||||
SESSION_METHODS.each do |method|
|
SESSION_METHODS.each do |method|
|
||||||
class_eval <<-RUBY, __FILE__, __LINE__+1
|
class_eval <<-RUBY, __FILE__, __LINE__+1
|
||||||
def #{method}(*args, &block)
|
def #{method}(*args, &block)
|
||||||
Webcat.current_session.#{method}(*args, &block)
|
page.#{method}(*args, &block)
|
||||||
end
|
end
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
|
@ -104,6 +104,16 @@ describe Webcat do
|
||||||
foo.click_link('ullamco')
|
foo.click_link('ullamco')
|
||||||
foo.body.should include('Another World')
|
foo.body.should include('Another World')
|
||||||
end
|
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
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue