capybara_error_intel 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/Rakefile +6 -0
- data/bin/console +12 -0
- data/bin/setup +8 -0
- data/capybara_error_intel.gemspec +40 -0
- data/lib/capybara_error_intel.rb +10 -0
- data/lib/capybara_error_intel/dsl.rb +32 -0
- data/lib/capybara_error_intel/version.rb +3 -0
- metadata +225 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b277ca0a65c2accc4fe3d184b5a6316300f1f93
|
4
|
+
data.tar.gz: 753725ace06c7903af7635fce2aa940fac326a6a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6039fab260fdd7597eb66a6a8730288b46f1d618d63d4f147fd17cf22fe40107d71cbce118ee965c8cd7454d051cbb585ec5410f0ab4b7981d727e2c303c5f46
|
7
|
+
data.tar.gz: 591d92977f83615f0a503bc58811b9c45e7e85fbfbd6f13509beed75e772320ba6746776a499247234d18a828e30140a6835b36e9b91f522e1d9e86669d66138
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Dorian Karter
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# CapybaraErrorIntel
|
2
|
+
|
3
|
+
Capybara provides excellent error messages for it's built in predicate methods: has_selector?, has_text?, and has_title? but when those are used from Page Objects while exposing predicate methods from the PageObjects themselves the error messages are lost and all we get is "expected true, got false". Including this module into your PageObject by adding "include CapybaraErrorIntel::DSL" after "include Capybara::DSL" will return the heuristic error messages.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
group :test do
|
11
|
+
gem 'capybara_error_intel'
|
12
|
+
end
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install capybara_error_intel
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Simply include at the top of your PageObject, **after** `include Capybara::DSL`.
|
26
|
+
Then use the built in Capybara::DSL as you are used to.
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
module Pages
|
30
|
+
class PostIndex
|
31
|
+
include Capybara::DSL
|
32
|
+
include CapybaraErrorIntel::DSL
|
33
|
+
|
34
|
+
def on_page?
|
35
|
+
has_selector?('h1', text: 'Posts')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
```
|
40
|
+
|
41
|
+
Note: currently this gem only supports the following Capybara built-in predicate
|
42
|
+
methods:
|
43
|
+
|
44
|
+
- `has_selector?`
|
45
|
+
- `has_text?`
|
46
|
+
- `has_title?`
|
47
|
+
|
48
|
+
It should be rather trivial to add more of them like `has_css` etc. I will try
|
49
|
+
to implement the rest in the near future but feel free to submit a pull
|
50
|
+
request.
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
## Development
|
55
|
+
|
56
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
57
|
+
|
58
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
59
|
+
|
60
|
+
## Contributing
|
61
|
+
|
62
|
+
Bug reports and pull requests are welcome on GitHub at
|
63
|
+
https://github.com/dkarter/capybara_error_intel
|
64
|
+
|
65
|
+
Please make sure the test suite passes and that you added tests for any new
|
66
|
+
method implemented.
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
## License
|
71
|
+
|
72
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
73
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "capybara_error_intel"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
require "pry"
|
11
|
+
Pry.start
|
12
|
+
|
data/bin/setup
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capybara_error_intel/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'capybara_error_intel'
|
8
|
+
spec.version = CapybaraErrorIntel::VERSION
|
9
|
+
spec.authors = ['Dorian Karter']
|
10
|
+
spec.email = ['jobs@doriankarter.com']
|
11
|
+
|
12
|
+
spec.summary = %q{Provides Capybara's heuristic error messages for Page Objects}
|
13
|
+
spec.description = %q{Capybara provides excellent error messages for it's
|
14
|
+
built in predicate methods: has_selector?, has_text?,
|
15
|
+
and has_title? but when those are used from Page
|
16
|
+
Objects while exposing predicate methods from the
|
17
|
+
PageObjects themselves the error messages are lost
|
18
|
+
and all we get is "expected true, got false".
|
19
|
+
Including this module into your PageObject by adding
|
20
|
+
"include CapybaraErrorIntel::DSL" after
|
21
|
+
"include Capybara::DSL" will return the heuristic
|
22
|
+
error messages.}
|
23
|
+
spec.homepage = 'https://github.com/dkarter/capybara_error_intel'
|
24
|
+
spec.license = 'MIT'
|
25
|
+
|
26
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
|
+
spec.add_development_dependency 'sinatra', '~> 1.4', '>= 1.4.7'
|
32
|
+
spec.add_development_dependency 'launchy', '~> 0'
|
33
|
+
spec.add_development_dependency 'rack', '~> 1.6', '>= 1.6.4'
|
34
|
+
spec.add_development_dependency 'rack-test', '~> 0.5', '>= 0.5.4'
|
35
|
+
spec.add_development_dependency 'pry', '~> 0.10'
|
36
|
+
spec.add_development_dependency 'pry-byebug', '~> 3.4'
|
37
|
+
|
38
|
+
spec.add_runtime_dependency 'rspec', '~> 3.0'
|
39
|
+
spec.add_runtime_dependency 'capybara', '~> 2'
|
40
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CapybaraErrorIntel
|
2
|
+
module DSL
|
3
|
+
def has_selector?(*args)
|
4
|
+
matcher = Capybara::RSpecMatchers::HaveSelector.new(*args)
|
5
|
+
match_or_error(matcher)
|
6
|
+
end
|
7
|
+
|
8
|
+
def has_text?(*args)
|
9
|
+
matcher = Capybara::RSpecMatchers::HaveText.new(*args)
|
10
|
+
match_or_error(matcher)
|
11
|
+
end
|
12
|
+
|
13
|
+
def has_title?(title, options = {})
|
14
|
+
matcher = Capybara::RSpecMatchers::HaveTitle.new(title, options)
|
15
|
+
match_or_error(matcher)
|
16
|
+
end
|
17
|
+
|
18
|
+
def match_or_error(matcher)
|
19
|
+
matcher.matches?(Capybara.current_session) || handle_failure(matcher)
|
20
|
+
end
|
21
|
+
|
22
|
+
def handle_failure(matcher)
|
23
|
+
message = matcher.failure_message
|
24
|
+
|
25
|
+
if matcher.respond_to?(:diffable?) && matcher.diffable?
|
26
|
+
RSpec::Expectations.fail_with message, matcher.expected, matcher.actual
|
27
|
+
else
|
28
|
+
RSpec::Expectations.fail_with message
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
metadata
ADDED
@@ -0,0 +1,225 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capybara_error_intel
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dorian Karter
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-09-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sinatra
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.4'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 1.4.7
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '1.4'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.4.7
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: launchy
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - "~>"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rack
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.6'
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 1.6.4
|
85
|
+
type: :development
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - "~>"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '1.6'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.6.4
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rack-test
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - "~>"
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.5'
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 0.5.4
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.5'
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: 0.5.4
|
115
|
+
- !ruby/object:Gem::Dependency
|
116
|
+
name: pry
|
117
|
+
requirement: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - "~>"
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0.10'
|
122
|
+
type: :development
|
123
|
+
prerelease: false
|
124
|
+
version_requirements: !ruby/object:Gem::Requirement
|
125
|
+
requirements:
|
126
|
+
- - "~>"
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: '0.10'
|
129
|
+
- !ruby/object:Gem::Dependency
|
130
|
+
name: pry-byebug
|
131
|
+
requirement: !ruby/object:Gem::Requirement
|
132
|
+
requirements:
|
133
|
+
- - "~>"
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
version: '3.4'
|
136
|
+
type: :development
|
137
|
+
prerelease: false
|
138
|
+
version_requirements: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - "~>"
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '3.4'
|
143
|
+
- !ruby/object:Gem::Dependency
|
144
|
+
name: rspec
|
145
|
+
requirement: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - "~>"
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '3.0'
|
150
|
+
type: :runtime
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
requirements:
|
154
|
+
- - "~>"
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
version: '3.0'
|
157
|
+
- !ruby/object:Gem::Dependency
|
158
|
+
name: capybara
|
159
|
+
requirement: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - "~>"
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '2'
|
164
|
+
type: :runtime
|
165
|
+
prerelease: false
|
166
|
+
version_requirements: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - "~>"
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '2'
|
171
|
+
description: |-
|
172
|
+
Capybara provides excellent error messages for it's
|
173
|
+
built in predicate methods: has_selector?, has_text?,
|
174
|
+
and has_title? but when those are used from Page
|
175
|
+
Objects while exposing predicate methods from the
|
176
|
+
PageObjects themselves the error messages are lost
|
177
|
+
and all we get is "expected true, got false".
|
178
|
+
Including this module into your PageObject by adding
|
179
|
+
"include CapybaraErrorIntel::DSL" after
|
180
|
+
"include Capybara::DSL" will return the heuristic
|
181
|
+
error messages.
|
182
|
+
email:
|
183
|
+
- jobs@doriankarter.com
|
184
|
+
executables: []
|
185
|
+
extensions: []
|
186
|
+
extra_rdoc_files: []
|
187
|
+
files:
|
188
|
+
- ".gitignore"
|
189
|
+
- ".rspec"
|
190
|
+
- ".travis.yml"
|
191
|
+
- Gemfile
|
192
|
+
- LICENSE.txt
|
193
|
+
- README.md
|
194
|
+
- Rakefile
|
195
|
+
- bin/console
|
196
|
+
- bin/setup
|
197
|
+
- capybara_error_intel.gemspec
|
198
|
+
- lib/capybara_error_intel.rb
|
199
|
+
- lib/capybara_error_intel/dsl.rb
|
200
|
+
- lib/capybara_error_intel/version.rb
|
201
|
+
homepage: https://github.com/dkarter/capybara_error_intel
|
202
|
+
licenses:
|
203
|
+
- MIT
|
204
|
+
metadata: {}
|
205
|
+
post_install_message:
|
206
|
+
rdoc_options: []
|
207
|
+
require_paths:
|
208
|
+
- lib
|
209
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
210
|
+
requirements:
|
211
|
+
- - ">="
|
212
|
+
- !ruby/object:Gem::Version
|
213
|
+
version: '0'
|
214
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
requirements: []
|
220
|
+
rubyforge_project:
|
221
|
+
rubygems_version: 2.5.1
|
222
|
+
signing_key:
|
223
|
+
specification_version: 4
|
224
|
+
summary: Provides Capybara's heuristic error messages for Page Objects
|
225
|
+
test_files: []
|