mache 2.1.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/{LICENSE → LICENSE.md} +0 -0
- data/README.md +19 -31
- data/lib/mache/dsl.rb +3 -3
- data/lib/mache/helpers/rails/flash.rb +9 -9
- data/lib/mache/helpers/rails/routes.rb +1 -1
- data/lib/mache/helpers/rails.rb +2 -2
- data/lib/mache/node.rb +3 -3
- data/lib/mache/page.rb +4 -4
- data/lib/mache/version.rb +1 -1
- data/lib/mache.rb +3 -3
- metadata +14 -24
- data/.gitignore +0 -4
- data/.rspec +0 -2
- data/.rubocop.yml +0 -22
- data/.ruby-version +0 -1
- data/.travis.yml +0 -2
- data/.yardopts +0 -1
- data/Gemfile +0 -4
- data/Rakefile +0 -8
- data/bin/console +0 -14
- data/mache.gemspec +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 140c5404ef81c74103be5b606b9e8bc96602028e
|
4
|
+
data.tar.gz: f684a099e524469994a8d6b39d9bd23f0f2fb7b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b61dc1430d309738643a23eca9666ec8bd340653beb4d481ebc966e5cd32b5ca5d0d4e2fcc532cbbceefeb3f7764a2c65e5017b1d6073cc3b0d806b2780ef55
|
7
|
+
data.tar.gz: '048b1bd8e9c1f2cfd0a8160a82a3338e8330d28fac7107b70c9d4b3c140d5942a4230e7e0c94734f8073a2b1f2bc8280f2f6f82035993c339c19a42831a39dd5'
|
data/CHANGELOG.md
CHANGED
data/{LICENSE → LICENSE.md}
RENAMED
File without changes
|
data/README.md
CHANGED
@@ -5,21 +5,18 @@
|
|
5
5
|
Mâché (pronounced "mash-ay") is a tool that helps you to write cleaner and more
|
6
6
|
expressive acceptance tests for your Ruby web applications using page objects.
|
7
7
|
|
8
|
-
## Table of
|
9
|
-
|
10
|
-
* [
|
11
|
-
|
12
|
-
* [
|
13
|
-
* [
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
* [License](#license)
|
21
|
-
|
22
|
-
## What is a page object?
|
8
|
+
## Table of Contents
|
9
|
+
|
10
|
+
* [What is a Page Object?](#what-is-a-page-object)
|
11
|
+
* [Getting Started](#getting-started)
|
12
|
+
* [Elements](#elements)
|
13
|
+
* [Components](#components)
|
14
|
+
* [Helpers](#helpers)
|
15
|
+
* [Examples](#examples)
|
16
|
+
* [Documentation](#documentation)
|
17
|
+
* [License](#license)
|
18
|
+
|
19
|
+
## What is a Page Object?
|
23
20
|
|
24
21
|
A [page object](https://martinfowler.com/bliki/PageObject.html) is a data
|
25
22
|
structure that provides an interface to your web application for the purposes
|
@@ -39,12 +36,12 @@ low-level API methods like `find`, `fill_in`, and `click_button`, but it
|
|
39
36
|
doesn't provide us with high-level methods to do things like "sign in to the
|
40
37
|
app" or "click the Dashboard item in the navigation bar".
|
41
38
|
|
42
|
-
This is where page objects come in. Using
|
43
|
-
|
39
|
+
This is where page objects come in. Using Mâché, we can define a page object
|
40
|
+
class called `SignInPage` and use it any time we want to automate
|
44
41
|
authenticating with our app. It could handle visiting the sign in page,
|
45
42
|
entering the user's credentials, and clicking the "Sign in" button.
|
46
43
|
|
47
|
-
## Getting
|
44
|
+
## Getting Started
|
48
45
|
|
49
46
|
Let's dive straight in and take a look at an example. Consider the following
|
50
47
|
HTML fragment for the welcome page in our app:
|
@@ -216,7 +213,7 @@ class WelcomePage < Mache::Page
|
|
216
213
|
end
|
217
214
|
```
|
218
215
|
|
219
|
-
##
|
216
|
+
## Examples
|
220
217
|
|
221
218
|
Let's look at an example of an acceptance test for our `WelcomePage`. Note that
|
222
219
|
the `Header`, `NavItem`, and `Nav` components can be reused in any other page
|
@@ -287,19 +284,10 @@ feature "Welcome page" do
|
|
287
284
|
end
|
288
285
|
```
|
289
286
|
|
290
|
-
##
|
291
|
-
|
292
|
-
Read the [API documentation](http://www.rubydoc.info/gems/mache) on RubyDoc.
|
293
|
-
|
294
|
-
## Contributing
|
287
|
+
## Documentation
|
295
288
|
|
296
|
-
|
297
|
-
submitting your PR:
|
298
|
-
|
299
|
-
```
|
300
|
-
> bundle exec rake
|
301
|
-
```
|
289
|
+
Read the [API reference](http://www.rubydoc.info/gems/mache) on RubyDoc.
|
302
290
|
|
303
291
|
## License
|
304
292
|
|
305
|
-
Mâché is licensed under the [MIT License](/LICENSE).
|
293
|
+
Mâché is licensed under the [MIT License](/LICENSE.md).
|
data/lib/mache/dsl.rb
CHANGED
@@ -55,7 +55,7 @@ module Mache
|
|
55
55
|
#
|
56
56
|
module ClassMethods
|
57
57
|
def automation(*ids)
|
58
|
-
ids.map { |id| %([data-automation="#{id}"]) }.join(
|
58
|
+
ids.map { |id| %([data-automation="#{id}"]) }.join(' ')
|
59
59
|
end
|
60
60
|
|
61
61
|
# Defines an element that wraps an HTML fragment.
|
@@ -96,7 +96,7 @@ module Mache
|
|
96
96
|
# @param options [Hash] a hash of options to pass to the Capybara finder
|
97
97
|
def component(name, klass, selector, options = {})
|
98
98
|
unless klass < Node
|
99
|
-
raise ArgumentError,
|
99
|
+
raise ArgumentError, 'Must be given a subclass of Node'
|
100
100
|
end
|
101
101
|
|
102
102
|
define_method(name.to_s) do
|
@@ -114,7 +114,7 @@ module Mache
|
|
114
114
|
# @param options [Hash] a hash of options to pass to the Capybara finder
|
115
115
|
def components(name, klass, selector, options = {})
|
116
116
|
unless klass < Node
|
117
|
-
raise ArgumentError,
|
117
|
+
raise ArgumentError, 'Must be given a subclass of Node'
|
118
118
|
end
|
119
119
|
|
120
120
|
options = {minimum: 1}.merge(options)
|
@@ -4,7 +4,7 @@ module Mache
|
|
4
4
|
# The {Flash} module can be Included into page object classes that support
|
5
5
|
# flash behaviour.
|
6
6
|
#
|
7
|
-
# rubocop:disable
|
7
|
+
# rubocop:disable Naming/PredicateName
|
8
8
|
module Flash
|
9
9
|
def self.included(base)
|
10
10
|
base.extend(ClassMethods)
|
@@ -18,18 +18,18 @@ module Mache
|
|
18
18
|
|
19
19
|
# Tests whether the page has a flash message.
|
20
20
|
#
|
21
|
-
# @param [String, Symbol]
|
22
|
-
# @param [Regexp, String]
|
21
|
+
# @param type [String, Symbol] a flash message type
|
22
|
+
# @param text [Regexp, String] a value to match
|
23
23
|
# @return `true` if the page has a matching message, `false` otherwise
|
24
24
|
def has_message?(type, text)
|
25
|
-
css_class = flash[:class] ||
|
25
|
+
css_class = flash[:class] || ''
|
26
26
|
regexp = text.is_a?(String) ? /\A#{Regexp.escape(text)}\Z/ : text
|
27
27
|
css_class.include?(type.to_s) && flash.text.strip =~ regexp
|
28
28
|
end
|
29
29
|
|
30
30
|
# Tests whether the page has a success message.
|
31
31
|
#
|
32
|
-
# @param [Regexp, String]
|
32
|
+
# @param text [Regexp, String] a value to match
|
33
33
|
# @return `true` if the page has a matching message, `false` otherwise
|
34
34
|
def has_success_message?(text)
|
35
35
|
has_message?(:success, text)
|
@@ -37,7 +37,7 @@ module Mache
|
|
37
37
|
|
38
38
|
# Tests whether the page has a notice message.
|
39
39
|
#
|
40
|
-
# @param [Regexp, String]
|
40
|
+
# @param text [Regexp, String] a value to match
|
41
41
|
# @return `true` if the page has a matching message, `false` otherwise
|
42
42
|
def has_notice_message?(text)
|
43
43
|
has_message?(:notice, text)
|
@@ -45,7 +45,7 @@ module Mache
|
|
45
45
|
|
46
46
|
# Tests whether the page has an alert message.
|
47
47
|
#
|
48
|
-
# @param [Regexp, String]
|
48
|
+
# @param text [Regexp, String] a value to match
|
49
49
|
# @return `true` if the page has a matching message, `false` otherwise
|
50
50
|
def has_alert_message?(text)
|
51
51
|
has_message?(:alert, text)
|
@@ -53,13 +53,13 @@ module Mache
|
|
53
53
|
|
54
54
|
# Tests whether the page has an error message.
|
55
55
|
#
|
56
|
-
# @param [Regexp, String]
|
56
|
+
# @param text [Regexp, String] a value to match
|
57
57
|
# @return `true` if the page has a matching message, `false` otherwise
|
58
58
|
def has_error_message?(text)
|
59
59
|
has_message?(:error, text)
|
60
60
|
end
|
61
61
|
end
|
62
|
-
# rubocop:enable
|
62
|
+
# rubocop:enable Naming/PredicateName
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
data/lib/mache/helpers/rails.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'mache/helpers/rails/flash'
|
2
|
+
require 'mache/helpers/rails/routes'
|
data/lib/mache/node.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
1
|
+
require 'mache/dsl'
|
2
2
|
|
3
3
|
module Mache
|
4
4
|
# The {Node} class represents a wrapped HTML page, or fragment. It exposes all
|
5
|
-
# methods from the Mache
|
5
|
+
# methods from the Mache DSL, and forwards any Capybara API methods to the
|
6
6
|
# {#node} object.
|
7
7
|
#
|
8
8
|
# @abstract
|
@@ -11,7 +11,7 @@ module Mache
|
|
11
11
|
|
12
12
|
# The underlying Capybara node object wrapped by this instance.
|
13
13
|
#
|
14
|
-
# @return [Capybara::Node]
|
14
|
+
# @return [Capybara::Node] a node object
|
15
15
|
attr_reader :node
|
16
16
|
|
17
17
|
# Returns a new instance of Node.
|
data/lib/mache/page.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'capybara'
|
2
|
+
require 'mache/node'
|
3
3
|
|
4
4
|
module Mache
|
5
5
|
# The {Page} class wraps an HTML page with an application-specific API. You
|
@@ -38,7 +38,7 @@ module Mache
|
|
38
38
|
|
39
39
|
# Visits the page at its {#path}.
|
40
40
|
#
|
41
|
-
# @return [Page]
|
41
|
+
# @return [Page] a page object
|
42
42
|
def visit
|
43
43
|
@node.visit(path)
|
44
44
|
self
|
@@ -53,7 +53,7 @@ module Mache
|
|
53
53
|
|
54
54
|
# Creates a new page object and calls {#visit} on it.
|
55
55
|
#
|
56
|
-
# @return [Page]
|
56
|
+
# @return [Page] a page object
|
57
57
|
def self.visit
|
58
58
|
new.visit
|
59
59
|
end
|
data/lib/mache/version.rb
CHANGED
data/lib/mache.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
1
|
+
require 'mache/node'
|
2
|
+
require 'mache/page'
|
3
|
+
require 'mache/version'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mache
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joshua Bassett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-09-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -16,42 +16,42 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '3'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '3'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.16'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.16'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '12.
|
47
|
+
version: '12.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '12.
|
54
|
+
version: '12.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rack
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.7'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '3.
|
82
|
+
version: '3.7'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rubocop
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.54'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.54'
|
97
97
|
description: Mâché provides helps you to write cleaner and more expressive acceptance
|
98
98
|
tests for your web applications using page objects.
|
99
99
|
email:
|
@@ -102,18 +102,9 @@ executables: []
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
-
- ".gitignore"
|
106
|
-
- ".rspec"
|
107
|
-
- ".rubocop.yml"
|
108
|
-
- ".ruby-version"
|
109
|
-
- ".travis.yml"
|
110
|
-
- ".yardopts"
|
111
105
|
- CHANGELOG.md
|
112
|
-
-
|
113
|
-
- LICENSE
|
106
|
+
- LICENSE.md
|
114
107
|
- README.md
|
115
|
-
- Rakefile
|
116
|
-
- bin/console
|
117
108
|
- lib/mache.rb
|
118
109
|
- lib/mache/dsl.rb
|
119
110
|
- lib/mache/helpers/rails.rb
|
@@ -122,7 +113,6 @@ files:
|
|
122
113
|
- lib/mache/node.rb
|
123
114
|
- lib/mache/page.rb
|
124
115
|
- lib/mache/version.rb
|
125
|
-
- mache.gemspec
|
126
116
|
homepage: https://github.com/nullobject/mache
|
127
117
|
licenses:
|
128
118
|
- MIT
|
@@ -143,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
133
|
version: '0'
|
144
134
|
requirements: []
|
145
135
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.6.
|
136
|
+
rubygems_version: 2.6.13
|
147
137
|
signing_key:
|
148
138
|
specification_version: 4
|
149
139
|
summary: A library for writing cleaner and more expressive acceptance tests using
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/.rubocop.yml
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
Exclude:
|
3
|
-
- "mache.gemspec"
|
4
|
-
|
5
|
-
Metrics/BlockLength:
|
6
|
-
ExcludedMethods: describe
|
7
|
-
|
8
|
-
Style/BlockDelimiters:
|
9
|
-
Enabled: false
|
10
|
-
|
11
|
-
Style/Documentation:
|
12
|
-
Exclude:
|
13
|
-
- "spec/**/*"
|
14
|
-
|
15
|
-
Style/FrozenStringLiteralComment:
|
16
|
-
Enabled: false
|
17
|
-
|
18
|
-
Style/SpaceInsideHashLiteralBraces:
|
19
|
-
Enabled: false
|
20
|
-
|
21
|
-
Style/StringLiterals:
|
22
|
-
EnforcedStyle: double_quotes
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.3.3
|
data/.travis.yml
DELETED
data/.yardopts
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
--markup markdown
|
data/Gemfile
DELETED
data/Rakefile
DELETED
data/bin/console
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require "bundler/setup"
|
4
|
-
require "mache"
|
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/mache.gemspec
DELETED
@@ -1,27 +0,0 @@
|
|
1
|
-
lib = File.expand_path("../lib", __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
|
4
|
-
require "mache/version"
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "mache"
|
8
|
-
spec.version = Mache::VERSION
|
9
|
-
spec.authors = ["Joshua Bassett"]
|
10
|
-
spec.email = ["josh.bassett@gmail.com"]
|
11
|
-
spec.summary = "A library for writing cleaner and more expressive acceptance tests using page objects."
|
12
|
-
spec.description = "Mâché provides helps you to write cleaner and more expressive acceptance tests for your web applications using page objects."
|
13
|
-
spec.homepage = "https://github.com/nullobject/mache"
|
14
|
-
spec.license = "MIT"
|
15
|
-
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
-
f.match(%r{^(test|spec|features)/})
|
17
|
-
end
|
18
|
-
spec.require_paths = ["lib"]
|
19
|
-
|
20
|
-
spec.add_dependency "capybara", "~> 2"
|
21
|
-
|
22
|
-
spec.add_development_dependency "bundler", "~> 1.14"
|
23
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
24
|
-
spec.add_development_dependency "rack", "~> 2.0"
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.5"
|
26
|
-
spec.add_development_dependency "rubocop", "~> 0.47"
|
27
|
-
end
|