Hi everyone,
It's been way too long, but I finally managed to get the master branch into a state which could be considered good enough for release. I've just pushed beta4 to Rubygems. Note that this release breaks compatibility with the 1.1.x series of Capybara in major ways, it also is not compatible with previous beta versions in some ways.
Notably, we changed the :type that Capybara assumes your specs run under in RSpec to :feature (previously it was :request). The latest release of spec/features. Alternatively you can use the Capybara Feature DSL (feature instead of describe), which should work without any additional tweaking. If you see errors like undefined method visit, then you're probably encountering this issue. If you're including modules into :request specs, you will probably need to change that to :feature.
This release also drops official support for Ruby 1.8.x. It's time to migrate, folks!
Many thanks to the many contributors for all the help with this release. Without you, this wouldn't have been possible. Let me know if there are any issues.
Full list of changes below!
/Jonas
- Dropped official support for Ruby 1.8.x. [Jonas Nicklas]
require 'capybara/rails'will automatically enable:respect_data_methodon the RackTest driver, so the behavior matches Capybara 1.1.2 [Jo Liss]- All methods which find or manipulate fields or buttons now ignore them when they are disabled. [Jonas Nicklas]
- Can no longer find elements by id via
find(:foo), usefind("#foo")orfind_by_id("foo")instead. [Jonas Nicklas] - Rename
Driver#bodytoDriver#html(relevant only for driver authors) [Jo Liss]
- Multiple files can be uploaded with
attach_file[Jarl Friis]
has_text(has_content) now accepts non-string arguments, like numbers. [Jo Liss]has_textandtextnow correctly normalize Unicode whitespace, such as . [Jo Liss]- RackTest allows protocol relative URLs [Jonas Nicklas]
- Arguments are cast to string where necessary, so that e.g.
click_link(:foo)works as expected. [Jonas Nicklas] :count => 0now works as expected [Jarl Friis]- Fixed race conditions on negative assertions when removing nodes [Jonas Nicklas]
respect_data_methoddefault tofalsefor the RackTest driver, which means that Capybara no longer picks up:method => :postet. al. from links in Rails by default. [Jonas Nicklas]findnow raises an error if more than one element was found. Sincefindis used by most actions, likeclick_linkunder the surface, this means that all actions need to unambiguous in the future. [Jonas Nicklas]Element#texton RackTest now only returns visible text and normalizes (strips) whitespace, as with Selenium [Mark Dodwell, Jo Liss]has_content?now checks the text value returned byElement#text, as opposed to querying the DOM. Which means it does not match hidden text. [Ryan Montgomery, Mark Dodwell, Jo Liss]- #394:
#bodynow returns the unmodified source (like#source), not the current state of the DOM (like#html), by popular request [Jonas Nicklas] Node#allno longer returns an array, but rather an enumerableCapybara::Result[Jonas Nicklas]- The arguments to
selectandunselectneeds to be the exact text of an option in a select box, substrings are no longer allowed [Jonas Nicklas] - The
optionsoption tohas_select?must match the exact set of options. Usewith_optionsfor the old behaviour. [Gonzalo Rodriguez] - The
selectedoption tohas_select?must match all selected options for multiple selects. [Gonzalo Rodriguez] - Various internals for running driver specs, this should only affect driver authors [Jonas Nicklas]
- No longer possible to specify
failure_messagefor custom selectors. [Jonas Nicklas] - #589:
Capybara.server_boot_timeouthas been removed in favor of a higher (60-second) hard-coded timeout [Jo Liss] Capybara.prefer_visible_elementshas been removed, as it is no longer needed with the changed find semantics [Jonas Nicklas]Node#wait_untilandSession#wait_untilhave been removed. SeeNode#synchronizefor an alternative [Jonas Nicklas]Capybara.timeouthas been removed [Jonas Nicklas]- The
:resynchronizeoption has been removed from the Selenium driver [Jonas Nicklas] - The
rowsoption tohas_table?has been removed without replacement. [Jonas Nicklas]
- Nodes found via
allare no longer reloaded. This fixes weird quirks where nodes would seemingly randomly replace themselves with other nodes [Jonas Nicklas] - Session is only reset if it has been modified, dramatically improves performance if only part of the test suite runs Capybara. [Jonas Nicklas]
- Test suite now passes on Ruby 1.8 [Jo Liss]
- #565:
require 'capybara/dsl'is no longer necessary [Jo Liss] Rack::Testnow respects ports when changing hosts [Jo Liss]- #603:
Rack::Testnow preserves the original referer URL when following a redirect [Rob van Dijk] - Rack::Test now does not send a referer when calling
visitmultiple times [Jo Liss] - Exceptions during server boot now propagate to main thread [James Tucker]
- RSpec integration now cleans up before the test instead of after [Darwin]
- If
respect_data_methodis true, the data-method attribute can be capitalized [Marco Antonio] - Rack app boot timing out raises an error as opposed to just logging to STDOUT [Adrian Irving-Beer]
#sourcereturns an empty string instead of nil if no pages have been visited [Jonas Nicklas]- Ignore first leading newline in textareas in RackTest [Vitalii Khustochka]
within_framereturns the value of the given block [Alistair Hutchison]- Running
Node.seton text fields will not trigger more than one change event [Andrew Kasper] - Throw an error when an option is given to a finder method, like
allorhas_selector?which Capybara doesn't understand [Jonas Nicklas] - Two references to the node now register as equal when comparing them with
==[Jonas Nicklas]
- Much improved error message [Jonas Nicklas]
- Errors from inside the session for apps running in a server are raised when session is reset [James Tucker, Jonas Nicklas]
- A ton of new selectors built in out of the box, like
field,link,button, etc... [Adam McCrea, Jonas Nicklas] has_text?has been added as an alias forhas_content?[Jonas Nicklas]- Add
Capybara.server_hostoption (default: 127.0.0.1) [David Balatero] - Add
:typeoption forpage.has_field?[Gonzalo Rodríguez] - Custom matchers can now be specified in CSS in addition to XPath [Jonas Nicklas]
Node#synchronizemethod to rerun a block of code if certain errors are raised [Jonas Nicklas]Capybara.always_include_portconfig option always includes the server port in URLs when usingvisit. Facilitates testing different domain names`. [Douwe Maan]- Redirect limit for RackTest driver is configurable [Josh Lane]
- Server port can be manually specified during initialization of server. [Jonas Nicklas, John Wilger]
has_content?andhas_text?can be given a regular expression [Vasiliy Ermolovich]