capybara-extensions 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2c9967dbf793edfaa80f0ff458df34676c135057
4
- data.tar.gz: 826fad27ed93d9cfab4c5cf593d2043d03640bd3
3
+ metadata.gz: e000c9d34cc71f496e29e483dac07fcea42e1fd9
4
+ data.tar.gz: 76351d2000bb77d54ded8b7b4c2e7b5f306cebe9
5
5
  SHA512:
6
- metadata.gz: 98eb5242121ad891d8473e7abc76e88cd47e1dd5d3ab0c45f29f2a87574f6beefe7bb46a404ac0bc9a6f2fff4b5a43abc594f2b148303d8e3c59767c49ed068a
7
- data.tar.gz: d57a543692c616475290f1fdafd1261442867bd55f69222b071bbfad05380345d0b9c0cc8cf76478242f3e3cb5844928b4250513b5fcf12c260bc2db84d656be
6
+ metadata.gz: 935553b44049f65f0bc4835ee08846de94cca8b80f754e02d84557b2dc7c652e7a40701c201af912410772d9cd8bea337ae87129b565d6e5970d39c5b43ec094
7
+ data.tar.gz: eaaddfdc4082f786691073dcc8ed1c406c45a7c8224b42fc4d211ecdb62a5cdefd036a22c57a28a6efd37bc5f0f4094030a777888db4c22c298a5c7e5f4958a5
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ cache: bundler
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # CapybaraExtensions
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/capybara-extensions.png)](http://badge.fury.io/rb/capybara-extensions)
4
+ [![Build Status](https://travis-ci.org/dockyard/capybara-extensions.png?branch=master)](https://travis-ci.org/dockyard/capybara-extensions)
5
+
3
6
  [Capybara](https://github.com/jnicklas/capybara) has an intuitive API which mimics the language of an actual user. This library extends Capybara's finders and matchers with additional methods for interacting with tables, lists, and list items, as well as many HTML5 elements.
4
7
 
5
8
  ## Installation
6
-
7
9
  Add this line to your application's Gemfile:
8
10
 
9
11
  gem 'capybara-extensions'
@@ -17,28 +19,84 @@ Or install it yourself as:
17
19
  $ gem install capybara-extensions
18
20
 
19
21
  ## Setup
20
-
21
22
  Require `capybara-extensions`:
22
23
 
23
24
  ```ruby
24
25
  require 'capybara-extensions'
25
- ```
26
+ ```
26
27
 
27
- ## The DSL
28
+ ## Usage
29
+ `CapybaraExtensions` extends Capybara's finders and matchers. Our goal is to cull many of the find statements from our tests and remove the verbose CSS and xpath locators that come along with them. Jonas Nicklas, who maintains Capybara, has [an excellent post](http://www.elabs.se/blog/51-simple-tricks-to-clean-up-your-capybara-tests) about augmenting Capybara with helper methods; this is what `CapybaraExtensions` aims to do.
28
30
 
29
- A complete reference of the finders and matchers added by CapybaraExtensions is available at [Rubydoc.info](http://rubydoc.info/github/dockyard/capybara-extensions). You can read more about the library in [this blog post](http://reefpoints.dockyard.com/2013/11/11/capybara-extensions.html).
31
+ You can read more about the library in [this blog post](http://reefpoints.dockyard.com/2013/11/11/capybara-extensions.html).
30
32
 
31
- ## Versioning
33
+ ### Finders
34
+ The library contains helper methods for finding elements like `form`, `table`, and `li`, as well as many HTML5 elements like `article`, `aside`, `footer`, `header`, and `nav`.
35
+ A complete reference of the finders added by `CapybaraExtensions` is available at [Rubydoc.info](http://rubydoc.info/gems/capybara-extensions/frames).
36
+
37
+ So the following code:
38
+ ```ruby
39
+ within find('form#session-new') do
40
+ ...
41
+ end
42
+ ```
43
+
44
+ becomes the following:
45
+ ```ruby
46
+ within form('Login') do
47
+ ...
48
+ end
49
+ ```
50
+
51
+ Each `find` method also has a corresponding `first` method. So when you have multiple article elements on a page with the text 'Lorem ipsum,' you can call `first_article('Lorem ipsum')` without returning an ambiguous match in Capybara.
52
+
53
+ In instances when you have lists or tables and you'd like to verify the content of a specific `li` or `tr`, `CapybaraExtensions` allows you to target the nth occurence of the element via `#list_item_number` and `#row_number`.
54
+
55
+ So given the following HTML:
56
+ ```html
57
+ <ul>
58
+ <li>John Doe</li>
59
+ <li>Jane Doe</li>
60
+ <li>Juan Doe</li>
61
+ </ul>
62
+ ```
63
+
64
+ You can find the second li with:
65
+ ```ruby
66
+ list_item_number(2) # => 'Jane Doe'
67
+ ```
68
+
69
+ Use these methods for testing how elements are being ordered.
70
+
71
+ ### Matchers
72
+ `CapybaraExtensions` extends Capybara's matchers with methods for verifying the presence of images, the value of input fields, and the presence of meta tags. All of these methods return a boolean.
73
+ A complete reference of the matchers added by `CapybaraExtensions` is available at [Rubydoc.info](http://rubydoc.info/gems/capybara-extensions/frames).
74
+
75
+ `CapybaraExtensions` comes with a `#has_field_value?` method which checks the value of a form field. Ensuring that your records save and update correctly should be the domain of your unit tests, however this method can come in handy when you're not persisting data to the back-end. For example, after performing a search, you may want to ensure that the query persists in the search field after redirect.
76
+
77
+ ```ruby
78
+ within form('Search') do
79
+ has_field_value?('search', 'capybara images')
80
+ end
81
+ # => true
82
+ ```
32
83
 
84
+ Asserting that text appears on the page is easy with Capybara's `#has_content?` method; asserting that a particular image appears has always been a little tougher. `#has_image?` takes a hash with the `src` and/or `alt` attributes you're looking for. You can pass a string for either of these keys, and an instance of Regexp to the `src` attribute when you want to hone in on a portion of the URL.
85
+
86
+ ```ruby
87
+ page.has_image?(src: 'http://gallery.photo.net/photo/8385754-md.jpg',
88
+ alt: 'Capybara')
89
+ # => true
90
+ ```
91
+
92
+ ## Versioning
33
93
  This gem follows [semantic versioning](http://semver.org).
34
94
 
35
95
  ## Contributing
36
-
37
96
  Please see our [contribution guidelines](/CONTRIBUTING.md) on how to
38
97
  properly submit issues and pull requests.
39
98
 
40
99
  ## Legal
41
-
42
100
  [DockYard, Inc](http://dockyard.com) © 2013
43
101
 
44
102
  Licensed under the [MIT
@@ -1,5 +1,4 @@
1
1
  require 'capybara'
2
- require 'capybara_minitest_spec'
3
2
 
4
3
  module CapybaraExtensions
5
4
  def self.extension_methods
@@ -1,3 +1,3 @@
1
1
  module CapybaraExtensions
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
data/test/test_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'byebug'
2
2
  require 'capybara-extensions'
3
+ require 'capybara_minitest_spec'
3
4
  require 'minitest/autorun'
4
5
  require 'minitest/reporters'
5
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capybara-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Dupuis Jr.
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-11 00:00:00.000000000 Z
12
+ date: 2013-11-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -146,6 +146,7 @@ extensions: []
146
146
  extra_rdoc_files: []
147
147
  files:
148
148
  - .gitignore
149
+ - .travis.yml
149
150
  - CONTRIBUTING.md
150
151
  - Gemfile
151
152
  - LICENSE.txt