capybara-page-dsl 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +65 -0
- data/Rakefile +2 -0
- data/capybara-page-dsl.gemspec +23 -0
- data/lib/capybara-page-dsl.rb +7 -0
- data/lib/capybara-page-dsl/helpers.rb +16 -0
- data/lib/capybara-page-dsl/page.rb +18 -0
- data/lib/capybara-page-dsl/version.rb +3 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a0a4b85a0eaea4077009492c3189226bc41b6e8f
|
4
|
+
data.tar.gz: 2edd2c3347edda86d77412965bd1144da76eb965
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a533b0424c6bd5033a5cc637bd08f8fb316b9d4a7f98a862daecdceb0dcd6a739ffb122271731b0fd87d18434f2bd63657a5369a57500cb86d2f3b723c0773c9
|
7
|
+
data.tar.gz: 08485cc332baf8cabcc24bc184f25e5f031c3a0115234415b26ef82e17a779b5787925ddfd30b594172111dc33c0b873c48503fba452b227f242951bdbedb3fa
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Stefan Roex
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
# CapybaraPageDSL
|
2
|
+
|
3
|
+
This is an extremely lightweight gem which adds a small layer atop off Capybara to increase reusablitiy. Instead of doing:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
visit signup_path
|
7
|
+
fill_in 'Email', with: 'user@example.com'
|
8
|
+
fill_in 'Password', with: 'password'
|
9
|
+
click_button 'Sign up'
|
10
|
+
```
|
11
|
+
|
12
|
+
Your are able to define an page object:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
class SignupPage < CapybaraPageDSL::Page
|
16
|
+
def visit
|
17
|
+
page.visit signup_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def fill_form(email:, password:)
|
21
|
+
fill_in 'Email', with: email
|
22
|
+
fill_in 'Password', with: password
|
23
|
+
click_button 'Sign up'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
```
|
27
|
+
|
28
|
+
And use them in the features:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
signup_page do |p|
|
32
|
+
p.visit
|
33
|
+
p.fill_form email: 'user@example.com', password: 'password'
|
34
|
+
end
|
35
|
+
```
|
36
|
+
|
37
|
+
## Installation
|
38
|
+
|
39
|
+
Add this line to your application's Gemfile:
|
40
|
+
|
41
|
+
gem 'capybara-page-dsl', group: :test, require: false
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
Add the following code to your `spec_helper` to require CapybaraPageDSL, load the page objects and inject the spec helpers.
|
46
|
+
|
47
|
+
``` ruby
|
48
|
+
require 'capybara-page-dsl'
|
49
|
+
|
50
|
+
Dir[Rails.root.join("spec/features/pages/*.rb")].each {|f| require f}
|
51
|
+
|
52
|
+
RSpec.configure do |config|
|
53
|
+
config.include CapybaraPageDSL::Helpers, type: :feature
|
54
|
+
end
|
55
|
+
```
|
56
|
+
|
57
|
+
You're now able to define the page objects in `spec/features/pages` and use the spec helpers. When you define an object called `UserPage`, you are able to access it by calling `user_page` in the feature.
|
58
|
+
|
59
|
+
## Contributing
|
60
|
+
|
61
|
+
1. Fork it ( https://github.com/stefan-roex/capybara-page-dsl/fork )
|
62
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
63
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
64
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
65
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capybara-page-dsl/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capybara-page-dsl"
|
8
|
+
spec.version = CapybaraPageDSL::VERSION
|
9
|
+
spec.authors = ["Stefan Roex"]
|
10
|
+
spec.email = ["info@stefanroex.nl"]
|
11
|
+
spec.summary = "Simple page objects to help write feature specs"
|
12
|
+
spec.description = ""
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module CapybaraPageDSL
|
2
|
+
module Helpers
|
3
|
+
Page.registered_pages.each do |page_class|
|
4
|
+
module_eval %Q{
|
5
|
+
def #{page_class.helper_name}(&block)
|
6
|
+
@#{page_class.helper_name} ||= #{page_class}.new
|
7
|
+
if block_given?
|
8
|
+
block.call(@#{page_class.helper_name})
|
9
|
+
else
|
10
|
+
@#{page_class.helper_name}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module CapybaraPageDSL
|
2
|
+
class Page
|
3
|
+
include Capybara::DSL
|
4
|
+
include RSpec::Matchers
|
5
|
+
include Rails.application.routes.url_helpers
|
6
|
+
|
7
|
+
cattr_reader :registered_pages
|
8
|
+
@@registered_pages = []
|
9
|
+
|
10
|
+
def self.inherited(klass)
|
11
|
+
@@registered_pages << klass
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.helper_name
|
15
|
+
to_s.underscore
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capybara-page-dsl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefan Roex
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-22 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: ''
|
42
|
+
email:
|
43
|
+
- info@stefanroex.nl
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- capybara-page-dsl.gemspec
|
54
|
+
- lib/capybara-page-dsl.rb
|
55
|
+
- lib/capybara-page-dsl/helpers.rb
|
56
|
+
- lib/capybara-page-dsl/page.rb
|
57
|
+
- lib/capybara-page-dsl/version.rb
|
58
|
+
homepage: ''
|
59
|
+
licenses:
|
60
|
+
- MIT
|
61
|
+
metadata: {}
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubyforge_project:
|
78
|
+
rubygems_version: 2.2.2
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: Simple page objects to help write feature specs
|
82
|
+
test_files: []
|