Skip to content

Commit

Permalink
Branch merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea Fazzi committed Nov 27, 2009
2 parents 516b68e + df188f9 commit ea6857b
Show file tree
Hide file tree
Showing 8 changed files with 276 additions and 176 deletions.
22 changes: 22 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,20 @@ For ultimate control, you can instantiate and use a session manually.
end
session.click_link 'Sign in'

== XPath an CSS

Capybara does not try to guess what kind of selector you are going to give it,
if you want to use CSS with your 'within' declarations for example, you'll need
to do:

within(:css, 'ul li') { ... }

Alternatively you can set the default selector to CSS, which may help if you are
moving from Webrat and used CSS a lot, or simply generally prefer CSS:

Capybara.default_selector = :css
within('ul li') { ... }

== Gotchas:

* Install JRuby and the 'celerity' gem, version 0.7.4 (0.7.5 has a bug with
Expand Down Expand Up @@ -186,6 +200,14 @@ For ultimate control, you can instantiate and use a session manually.
<tt><a href="/same/url#"></tt> instead. You can achieve this in Rails with
<tt>link_to('foo', :anchor => '')</tt>

== Contributors:

The following people have dedicated their time and effort to Capybara:

* Jonas Nicklas
* Dennis Rogenius
* Rob Holland

== License:

(The MIT License)
Expand Down
3 changes: 1 addition & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ $hoe = Hoe.spec 'capybara' do
['selenium-webdriver', '>= 0.0.3'],
['rack', '>= 1.0.0'],
['rack-test', '>= 0.5.2'],
['database_cleaner', '>= 0.2.3']
]

self.extra_dev_deps = [
['sinatra', '>= 0.9.4'],
['rspec', '>= 1.2.9']
Expand Down
6 changes: 1 addition & 5 deletions lib/capybara/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
Capybara.reset_sessions!
end

require 'database_cleaner'
require 'database_cleaner/cucumber'
DatabaseCleaner.strategy = :truncation

Before('@javascript') do
Capybara.current_driver = Capybara.javascript_driver
end
Expand All @@ -29,4 +25,4 @@

After do
Capybara.use_default_driver
end
end
12 changes: 9 additions & 3 deletions lib/capybara/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def default_driver
end

def current_driver
@current_driver || default_driver
@current_driver || default_driver
end
alias_method :mode, :current_driver

Expand All @@ -18,11 +18,17 @@ def javascript_driver
end

def use_default_driver
@current_driver = nil
@current_driver = nil
end

def current_session
session_pool["#{current_driver}#{app.object_id}"] ||= Capybara::Session.new(current_driver, app)
session_pool["#{current_driver}#{app.object_id}"] ||= begin
Capybara::Session.new(current_driver, app)
end
end

def current_session?
session_pool.has_key?("#{current_driver}#{app.object_id}")
end

def reset_sessions!
Expand Down
8 changes: 6 additions & 2 deletions lib/capybara/save_and_open_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ module SaveAndOpenPage
extend(self)

def save_and_open_page(html)
require 'tempfile'
tempfile = Tempfile.new("capybara#{rand(1000000)}")
name="capybara-#{Time.new.strftime("%Y%m%d%H%M%S")}.html"

FileUtils.touch(name) unless File.exist?(name)

tempfile = File.new(name,'w')
tempfile.write(rewrite_css_and_image_references(html))
tempfile.close

open_in_browser(tempfile.path)
end

Expand Down
Loading

0 comments on commit ea6857b

Please sign in to comment.