capybara_objects 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/capybara_objects.gemspec +27 -0
- data/lib/capybara_objects.rb +9 -0
- data/lib/capybara_objects/component_object.rb +23 -0
- data/lib/capybara_objects/configure_capybara.rb +23 -0
- data/lib/capybara_objects/convenience_methods.rb +22 -0
- data/lib/capybara_objects/exceptions.rb +2 -0
- data/lib/capybara_objects/exceptions/missing_locator.rb +9 -0
- data/lib/capybara_objects/exceptions/missing_url.rb +9 -0
- data/lib/capybara_objects/exceptions/type_not_registered.rb +15 -0
- data/lib/capybara_objects/initialize_methods.rb +22 -0
- data/lib/capybara_objects/location_methods.rb +25 -0
- data/lib/capybara_objects/page_object.rb +60 -0
- data/lib/capybara_objects/registry_instance.rb +50 -0
- data/lib/capybara_objects/registry_methods.rb +16 -0
- data/lib/capybara_objects/rspec.rb +6 -0
- data/lib/capybara_objects/rspec/helpers.rb +1 -0
- data/lib/capybara_objects/rspec/helpers/feature_helpers.rb +27 -0
- data/lib/capybara_objects/scoped_finders.rb +57 -0
- data/lib/capybara_objects/validation_methods.rb +18 -0
- data/lib/capybara_objects/version.rb +3 -0
- metadata +130 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 760fe81c054babc77fca4124d22114c54351f2b8
|
4
|
+
data.tar.gz: 8a5dfcf3396fb746eadced9fec1140deb31a3bfa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 40b8e7d963047ba538f089be89ab1f80caf792247bb4a8a4aa74e056a61f7be5158b24b0aa436cea7b1995cfb146592880694d82908a7d669c0b2b32792eb83b
|
7
|
+
data.tar.gz: f30701daf9381c01760faf6daf2bee4d62e247f29cc70eda9b0a373f25b623cec27d60cebbe6f4ceebbbb7e42f5cbf042d853a562266a6f1e9d5dc8892aaad7f
|
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) 2015 Gary Taylor
|
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,41 @@
|
|
1
|
+
# CapybaraObjects
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/capybara_objects`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'capybara_objects'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install capybara_objects
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/capybara_objects.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "capybara_objects"
|
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
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capybara_objects/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capybara_objects"
|
8
|
+
spec.version = CapybaraObjects::VERSION
|
9
|
+
spec.authors = ["Gary Taylor"]
|
10
|
+
spec.email = ["gary.taylor@hismessages.com"]
|
11
|
+
|
12
|
+
spec.summary = "OO Style page objects for capybara"
|
13
|
+
spec.description = "OO Style page objects for capybara"
|
14
|
+
spec.homepage = ""
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec"
|
25
|
+
|
26
|
+
spec.add_runtime_dependency "activesupport", "~> 4.2"
|
27
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
require "capybara_objects/version"
|
2
|
+
require "capybara_objects/exceptions"
|
3
|
+
require "capybara_objects/configure_capybara"
|
4
|
+
require "capybara_objects/rspec"
|
5
|
+
require "capybara_objects/component_object"
|
6
|
+
require "capybara_objects/page_object"
|
7
|
+
module CapybaraObjects
|
8
|
+
# Your code goes here...
|
9
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "capybara_objects/registry_methods"
|
2
|
+
require "capybara_objects/initialize_methods"
|
3
|
+
require "capybara_objects/scoped_finders"
|
4
|
+
require "capybara_objects/location_methods"
|
5
|
+
require "capybara_objects/validation_methods"
|
6
|
+
require "capybara_objects/convenience_methods"
|
7
|
+
module CapybaraObjects
|
8
|
+
class ComponentObject
|
9
|
+
include RegistryMethods
|
10
|
+
include InitializeMethods
|
11
|
+
include LocationMethods
|
12
|
+
include ValidationMethods
|
13
|
+
include ConvenienceMethods
|
14
|
+
include ScopedFinders
|
15
|
+
class << self
|
16
|
+
def ctype(type)
|
17
|
+
registry.register_ctype type, self
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Allows the use of :ctype in a capybara finder spec
|
2
|
+
# the argument can either be a symbol, string or an array
|
3
|
+
# If a symbol or string, the component object is looked up by its ctype in the registry
|
4
|
+
# If an array, these are treated as multiple arguments, the first one being as above,
|
5
|
+
# and the remainder are passed on to the instance of the component object
|
6
|
+
Capybara.add_selector(:ctype) do
|
7
|
+
xpath do |args|
|
8
|
+
local_args = args
|
9
|
+
local_args = [args] unless args.is_a? Array
|
10
|
+
ctype, *other_args = local_args
|
11
|
+
component = ::CapybaraObjects::RegistryInstance.instance.lookup_ctype(ctype).new(*other_args)
|
12
|
+
query = ::Capybara::Query.new(*component.locator)
|
13
|
+
selector = query.selector
|
14
|
+
@format = selector.format
|
15
|
+
if selector.format == :css
|
16
|
+
@css = selector.css
|
17
|
+
@xpath = nil
|
18
|
+
else
|
19
|
+
@xpath = selector.xpath
|
20
|
+
end
|
21
|
+
query.expression
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "active_support/concern"
|
2
|
+
module CapybaraObjects
|
3
|
+
module ConvenienceMethods
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
delegate :find, :within, to: :page
|
7
|
+
# The capybara current session
|
8
|
+
# @return [Capybara::Session] The current session
|
9
|
+
def page
|
10
|
+
Capybara.current_session
|
11
|
+
end
|
12
|
+
# Hovers over the root node of this component
|
13
|
+
def hover
|
14
|
+
root_node.hover
|
15
|
+
end
|
16
|
+
# Clicks on the root node of this component
|
17
|
+
def click
|
18
|
+
root_node.click
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
module CapybaraObjects
|
2
|
+
module Exceptions
|
3
|
+
class MissingLocator < StandardError
|
4
|
+
def to_s
|
5
|
+
"CapybaraObjects::Exceptions::MissingLocator - Please ensure either a default_locator (class level) or a locator (instance level) has been declared"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module CapybaraObjects
|
2
|
+
module Exceptions
|
3
|
+
class TypeNotRegistered < StandardError
|
4
|
+
attr_accessor :type
|
5
|
+
def initialize(type)
|
6
|
+
self.type = type
|
7
|
+
end
|
8
|
+
|
9
|
+
def to_s
|
10
|
+
"Type not registered in CapybaraObjects::RegistryInstance (#{type})"
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require "active_support/concern"
|
2
|
+
module CapybaraObjects
|
3
|
+
module InitializeMethods
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
included do
|
6
|
+
private
|
7
|
+
|
8
|
+
attr_accessor :options
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(options = {})
|
13
|
+
my_options = options.dup
|
14
|
+
my_options.keys.each do |key|
|
15
|
+
if respond_to?("#{key}=".to_sym)
|
16
|
+
send("#{key}=", my_options.delete(key))
|
17
|
+
end
|
18
|
+
end
|
19
|
+
self.options = my_options
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "active_support/concern"
|
2
|
+
require "capybara_objects/registry_instance"
|
3
|
+
module CapybaraObjects
|
4
|
+
module LocationMethods
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do |base|
|
7
|
+
class_attribute :default_locator
|
8
|
+
attr_accessor :locator, :scope
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(attrs = {})
|
12
|
+
self.locator = default_locator
|
13
|
+
self.scope = []
|
14
|
+
super
|
15
|
+
locator.freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
class_methods do
|
19
|
+
def locator(*args)
|
20
|
+
self.default_locator = args
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require "capybara_objects/registry_methods"
|
2
|
+
require "capybara_objects/initialize_methods"
|
3
|
+
require "capybara_objects/scoped_finders"
|
4
|
+
require "capybara_objects/location_methods"
|
5
|
+
require "capybara_objects/validation_methods"
|
6
|
+
require "capybara_objects/convenience_methods"
|
7
|
+
module CapybaraObjects
|
8
|
+
#
|
9
|
+
# A page object
|
10
|
+
#
|
11
|
+
class PageObject
|
12
|
+
include RegistryMethods
|
13
|
+
include InitializeMethods
|
14
|
+
include LocationMethods
|
15
|
+
include ValidationMethods
|
16
|
+
include ConvenienceMethods
|
17
|
+
include ScopedFinders
|
18
|
+
attr_accessor :url
|
19
|
+
class << self
|
20
|
+
# Registers a "ptype" alias for this class
|
21
|
+
# @param [String] type The alias or type to register this class with.
|
22
|
+
def ptype(type)
|
23
|
+
registry.register_ptype type, self
|
24
|
+
end
|
25
|
+
|
26
|
+
# Defines the default url. Can be overriden in the instance
|
27
|
+
# @param [String] url The default url
|
28
|
+
def url(url)
|
29
|
+
self.default_url = url
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(options = {})
|
34
|
+
super
|
35
|
+
self.url ||= default_url
|
36
|
+
end
|
37
|
+
|
38
|
+
# Visits the pre configured URL to make this page available
|
39
|
+
# @raise ::CapybaraPageObjects::Exceptions::MissingUrl
|
40
|
+
# @return [::CapybaraObjects::PageObject] self - allows chaining of methods
|
41
|
+
def visit
|
42
|
+
raise ::CapybaraObjects::Exceptions::MissingUrl unless url.present?
|
43
|
+
page.visit url
|
44
|
+
validate!
|
45
|
+
self
|
46
|
+
end
|
47
|
+
|
48
|
+
# Attaches the page object to the current page
|
49
|
+
# @return [::CapybaraObjects::PageObject] self - allows chaining of methods
|
50
|
+
def attach(options = {})
|
51
|
+
validate!
|
52
|
+
self
|
53
|
+
end
|
54
|
+
|
55
|
+
private
|
56
|
+
cattr_accessor :default_url
|
57
|
+
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module CapybaraObjects
|
2
|
+
class RegistryInstance
|
3
|
+
include Singleton
|
4
|
+
def initialize
|
5
|
+
self.ctypes = HashWithIndifferentAccess.new
|
6
|
+
self.ptypes = HashWithIndifferentAccess.new
|
7
|
+
end
|
8
|
+
|
9
|
+
#
|
10
|
+
# Registers a component class so an alias can be used rather than worrying about
|
11
|
+
# the module path etc..
|
12
|
+
# @param [String] type The type of component to register
|
13
|
+
# @param [Class] klass The class to register
|
14
|
+
def register_ctype(type, klass)
|
15
|
+
ctypes[type] = klass
|
16
|
+
end
|
17
|
+
|
18
|
+
# @TODO Raise exceptions if ptype or ctype not found
|
19
|
+
|
20
|
+
#
|
21
|
+
# Registers a page object class so an alias can be used rather than worrying about
|
22
|
+
# the module path etc..
|
23
|
+
# @param [String] type The type of page object to register
|
24
|
+
# @param [Class] klass The class to register
|
25
|
+
# @raise ::CapybaraObjects::Exceptions::UnregisteredType
|
26
|
+
def register_ptype(type, klass)
|
27
|
+
ptypes[type] = klass
|
28
|
+
end
|
29
|
+
|
30
|
+
# Lookup a component object by its type
|
31
|
+
# @param [String] ctype The component type to lookup
|
32
|
+
# @return [Class] The registered class
|
33
|
+
# @raise ::CapybaraObjects::Exceptions::TypeNotRegistered
|
34
|
+
def lookup_ctype(ctype)
|
35
|
+
ctypes[ctype] or raise Exceptions::TypeNotRegistered.new(ctype)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Lookup a page object by its type
|
39
|
+
# @param [String] ptype The page object type to lookup
|
40
|
+
# @return [Class] The registered class
|
41
|
+
# @raise ::CapybaraObjects::Exceptions::TypeNotRegistered
|
42
|
+
def lookup_ptype(ptype)
|
43
|
+
ptypes[ptype] or raise Exceptions::TypeNotRegistered.new(ptype)
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
private
|
48
|
+
attr_accessor :ctypes, :ptypes
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "active_support/concern"
|
2
|
+
require "capybara_objects/registry_instance"
|
3
|
+
module CapybaraObjects
|
4
|
+
module RegistryMethods
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
included do
|
7
|
+
private
|
8
|
+
cattr_accessor :registry
|
9
|
+
self.registry = RegistryInstance.instance
|
10
|
+
end
|
11
|
+
class_methods do
|
12
|
+
private
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "capybara_objects/rspec/helpers/feature_helpers"
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require "capybara_objects/registry_instance"
|
2
|
+
module CapybaraObjects
|
3
|
+
module RSpec
|
4
|
+
module Helpers
|
5
|
+
module FeatureHelpers
|
6
|
+
|
7
|
+
# Fetches a page object instance by its alias
|
8
|
+
# @param [String] ptype The page object type to lookup
|
9
|
+
# @param [*] args Any extra params are passed to the instance of the looked up class
|
10
|
+
# @return [::CapybaraObjects::PageObject] A new page object instance
|
11
|
+
def page_object_for(ptype, *args)
|
12
|
+
::CapybaraObjects::RegistryInstance.instance.lookup_ptype(ptype).new(*args)
|
13
|
+
end
|
14
|
+
|
15
|
+
# Fetches a component object instance by its alias
|
16
|
+
# @param [String] ctype The component object type to lookup
|
17
|
+
# @param [*] args Any extra params are passed to the instance of the looked up class
|
18
|
+
# @return [::CapybaraObjects::ComponentObject] A new component object instance
|
19
|
+
def component_object_for(ctype, *args)
|
20
|
+
::CapybaraObjects::RegistryInstance.instance.lookup_ctype(ctype, *args).tap do |instance|
|
21
|
+
instance.validate!
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require "active_support/concern"
|
2
|
+
module CapybaraObjects
|
3
|
+
module ScopedFinders
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
# Fetch a component from within this component
|
7
|
+
# @TODO Make this operate within the scope
|
8
|
+
# @TODO Pass the scope on to any found instances
|
9
|
+
# @param [String|Symbol] ctype The component alias to find
|
10
|
+
# @param [Any] args Any further arguments are passed on to the instance of the component
|
11
|
+
# @return [CapybaraObjects::ComponentObject] An instance inheriting from the component object
|
12
|
+
def get_component(ctype, *args)
|
13
|
+
registry.lookup_ctype(ctype).new(*args).tap do |comp|
|
14
|
+
comp.scope = full_scope
|
15
|
+
comp.validate!
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def root_node
|
20
|
+
within_parent_scope do
|
21
|
+
find(*locator)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Finds a node within the scope of this component
|
26
|
+
# @param [Any] args - All args get passed on to the normal capybara find method
|
27
|
+
# @return [Capybara::Node] The found node
|
28
|
+
def scoped_find(*args)
|
29
|
+
within_my_scope do
|
30
|
+
find(*args)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def full_scope
|
39
|
+
scope + [locator]
|
40
|
+
end
|
41
|
+
|
42
|
+
def within_my_scope(current_scope = full_scope, &blk)
|
43
|
+
next_scope = current_scope.shift
|
44
|
+
if next_scope
|
45
|
+
within(*next_scope) do
|
46
|
+
within_my_scope(current_scope, &blk)
|
47
|
+
end
|
48
|
+
else
|
49
|
+
yield
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def within_parent_scope(&blk)
|
54
|
+
within_my_scope(scope.dup, &blk)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "active_support/concern"
|
2
|
+
require "capybara_objects/registry_instance"
|
3
|
+
require "capybara_objects/exceptions/missing_locator"
|
4
|
+
module CapybaraObjects
|
5
|
+
module ValidationMethods
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
# Validates that the component exists
|
8
|
+
# this is simply done by searching for the root node.
|
9
|
+
# However, a sub class may implement its own stricter
|
10
|
+
# validation if required.
|
11
|
+
# @raise CapybaraObjects::Exceptions::MissingLocator If a locator hasn't been defined using default_locator or locator (instance)
|
12
|
+
def validate!
|
13
|
+
raise Exceptions::MissingLocator unless locator.present?
|
14
|
+
root_node.present?
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,130 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capybara_objects
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Gary Taylor
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-10 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: activesupport
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.2'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.2'
|
69
|
+
description: OO Style page objects for capybara
|
70
|
+
email:
|
71
|
+
- gary.taylor@hismessages.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- capybara_objects.gemspec
|
86
|
+
- lib/capybara_objects.rb
|
87
|
+
- lib/capybara_objects/component_object.rb
|
88
|
+
- lib/capybara_objects/configure_capybara.rb
|
89
|
+
- lib/capybara_objects/convenience_methods.rb
|
90
|
+
- lib/capybara_objects/exceptions.rb
|
91
|
+
- lib/capybara_objects/exceptions/missing_locator.rb
|
92
|
+
- lib/capybara_objects/exceptions/missing_url.rb
|
93
|
+
- lib/capybara_objects/exceptions/type_not_registered.rb
|
94
|
+
- lib/capybara_objects/initialize_methods.rb
|
95
|
+
- lib/capybara_objects/location_methods.rb
|
96
|
+
- lib/capybara_objects/page_object.rb
|
97
|
+
- lib/capybara_objects/registry_instance.rb
|
98
|
+
- lib/capybara_objects/registry_methods.rb
|
99
|
+
- lib/capybara_objects/rspec.rb
|
100
|
+
- lib/capybara_objects/rspec/helpers.rb
|
101
|
+
- lib/capybara_objects/rspec/helpers/feature_helpers.rb
|
102
|
+
- lib/capybara_objects/scoped_finders.rb
|
103
|
+
- lib/capybara_objects/validation_methods.rb
|
104
|
+
- lib/capybara_objects/version.rb
|
105
|
+
homepage: ''
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
metadata: {}
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
requirements: []
|
124
|
+
rubyforge_project:
|
125
|
+
rubygems_version: 2.4.8
|
126
|
+
signing_key:
|
127
|
+
specification_version: 4
|
128
|
+
summary: OO Style page objects for capybara
|
129
|
+
test_files: []
|
130
|
+
has_rdoc:
|