mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Merge branch 'master' of https://github.com/jeffkreeftmeijer/capybara into jeffkreeftmeijer-master
This commit is contained in:
commit
6f5c1c330e
3 changed files with 15 additions and 7 deletions
|
@ -29,7 +29,7 @@ module Capybara
|
|||
DSL_METHODS = [
|
||||
:all, :first, :attach_file, :body, :check, :choose, :click_link_or_button, :click_button, :click_link, :current_url, :drag, :evaluate_script,
|
||||
:field_labeled, :fill_in, :find, :find_button, :find_by_id, :find_field, :find_link, :has_content?, :has_css?,
|
||||
:has_no_content?, :has_no_css?, :has_no_xpath?, :has_xpath?, :locate, :save_and_open_page, :select, :source, :uncheck,
|
||||
:has_no_content?, :has_no_css?, :has_no_xpath?, :has_xpath?, :locate, :save_page, :save_and_open_page, :select, :source, :uncheck,
|
||||
:visit, :wait_until, :within, :within_fieldset, :within_table, :within_frame, :within_window, :has_link?, :has_no_link?, :has_button?,
|
||||
:has_no_button?, :has_field?, :has_no_field?, :has_checked_field?, :has_unchecked_field?, :has_no_table?, :has_table?,
|
||||
:unselect, :has_select?, :has_no_select?, :current_path, :click, :has_selector?, :has_no_selector?, :click_on
|
||||
|
@ -251,6 +251,11 @@ module Capybara
|
|||
#
|
||||
# Save a snapshot of the page and open it in a browser for inspection
|
||||
#
|
||||
def save_page
|
||||
require 'capybara/util/save_and_open_page'
|
||||
Capybara.save_page(body)
|
||||
end
|
||||
|
||||
def save_and_open_page
|
||||
require 'capybara/util/save_and_open_page'
|
||||
Capybara.save_and_open_page(body)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Capybara
|
||||
class << self
|
||||
def save_and_open_page(html)
|
||||
def save_page(html)
|
||||
name = File.join(*[Capybara.save_and_open_page_path, "capybara-#{Time.new.strftime("%Y%m%d%H%M%S")}.html"].compact)
|
||||
|
||||
unless Capybara.save_and_open_page_path.nil? || File.directory?(Capybara.save_and_open_page_path )
|
||||
|
@ -11,8 +11,11 @@ module Capybara
|
|||
tempfile = File.new(name,'w')
|
||||
tempfile.write(rewrite_css_and_image_references(html))
|
||||
tempfile.close
|
||||
tempfile.path
|
||||
end
|
||||
|
||||
open_in_browser(tempfile.path)
|
||||
def save_and_open_page(html)
|
||||
open_in_browser save_page(html)
|
||||
end
|
||||
|
||||
protected
|
||||
|
|
|
@ -3,7 +3,7 @@ require 'spec_helper'
|
|||
require 'capybara/util/save_and_open_page'
|
||||
require 'launchy'
|
||||
describe Capybara do
|
||||
describe ".save_and_open_page" do
|
||||
describe ".save_page & .save_and_open_page" do
|
||||
before do
|
||||
@time = Time.new.strftime("%Y%m%d%H%M%S")
|
||||
|
||||
|
@ -56,7 +56,7 @@ describe Capybara do
|
|||
|
||||
it "should create a new temporary file" do
|
||||
@temp_file.should_receive(:write).with @html
|
||||
Capybara.save_and_open_page @html
|
||||
Capybara.save_page @html
|
||||
end
|
||||
|
||||
it "should open the file in the browser" do
|
||||
|
@ -81,7 +81,7 @@ describe Capybara do
|
|||
File.should_receive(:new).and_return @temp_file
|
||||
|
||||
@temp_file.should_receive(:write).with @html
|
||||
Capybara.save_and_open_page @html
|
||||
Capybara.save_page @html
|
||||
end
|
||||
|
||||
it "should open the file - in the custom path - in the browser" do
|
||||
|
@ -140,7 +140,7 @@ describe Capybara do
|
|||
def test_with_directories(directories)
|
||||
@temp_file.should_receive(:write) \
|
||||
.with expected_html_for_asset_root_with(directories)
|
||||
Capybara.save_and_open_page @html
|
||||
Capybara.save_page @html
|
||||
end
|
||||
|
||||
context "asset_root contains some directories" do
|
||||
|
|
Loading…
Add table
Reference in a new issue