testable 0.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +31 -5
- data/.hound.yml +62 -0
- data/.rspec +3 -0
- data/.rubocop.yml +2 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/LICENSE.txt +17 -18
- data/README.md +50 -9
- data/Rakefile +42 -0
- data/bin/console +13 -0
- data/bin/setup +8 -0
- data/lib/testable/element.rb +55 -0
- data/lib/testable/errors.rb +7 -0
- data/lib/testable/factory.rb +23 -0
- data/lib/testable/interface.rb +73 -0
- data/lib/testable/situation.rb +45 -0
- data/lib/testable/version.rb +16 -1
- data/lib/testable.rb +13 -0
- data/testable.gemspec +17 -14
- metadata +109 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca79301e385c9f1457040532815cfe04632a4977
|
4
|
+
data.tar.gz: 315f37f4f0e4afe12e610e5d87d1b5e36194e80e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2132bbcc51ddbc97d9416c1e80c72e6b4b245bfadd2dd0179e1fac1c75f794080fe917ec59dfff3e3e424b057d007c984aa41eda885df1fc0748910ed69b6e18
|
7
|
+
data.tar.gz: 64f358af899249bed9b2eaa06936420090a0b209440d3ad63d81475903c02d7845792a3a1df33c983650e4f67c8dd48339d63ccf17d5924710e9bdcf0d2bde22
|
data/.gitignore
CHANGED
@@ -1,14 +1,40 @@
|
|
1
|
+
# Ruby-Specific
|
2
|
+
|
1
3
|
/.bundle/
|
2
4
|
/.yardoc
|
3
5
|
/Gemfile.lock
|
4
6
|
/_yardoc/
|
7
|
+
|
8
|
+
# Ouput-Specific
|
9
|
+
|
5
10
|
/coverage/
|
6
11
|
/doc/
|
7
12
|
/pkg/
|
8
13
|
/spec/reports/
|
9
14
|
/tmp/
|
10
|
-
*.
|
11
|
-
*.
|
12
|
-
*.
|
13
|
-
*.
|
14
|
-
|
15
|
+
*.log
|
16
|
+
*.tmp
|
17
|
+
*.swp
|
18
|
+
*.bak
|
19
|
+
|
20
|
+
# IDE-Specific
|
21
|
+
|
22
|
+
.idea
|
23
|
+
.settings
|
24
|
+
.project
|
25
|
+
.classpath
|
26
|
+
*.iws
|
27
|
+
|
28
|
+
# Windows-Specific
|
29
|
+
|
30
|
+
Thumbs.db
|
31
|
+
|
32
|
+
# Mac OS-Specific
|
33
|
+
|
34
|
+
*.DS_Store
|
35
|
+
._*
|
36
|
+
|
37
|
+
# Linux-Specific
|
38
|
+
|
39
|
+
.directory
|
40
|
+
.Trash-*
|
data/.hound.yml
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- testable.gemspec
|
4
|
+
- test/*.rb
|
5
|
+
- spec/**/*
|
6
|
+
|
7
|
+
# Removing need for frozen string literal comment.
|
8
|
+
Style/FrozenStringLiteralComment:
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
# Removing the preference for string single quotes.
|
12
|
+
Style/StringLiterals:
|
13
|
+
Enabled: false
|
14
|
+
|
15
|
+
# Missing top-level module documentation comment.
|
16
|
+
Style/Documentation:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
# Prefer reduce over inject.
|
20
|
+
Style/CollectionMethods:
|
21
|
+
PreferredMethods:
|
22
|
+
reduce: 'inject'
|
23
|
+
|
24
|
+
# Use each_with_object instead of inject.
|
25
|
+
Style/EachWithObject:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
# Prefer fail over raise.
|
29
|
+
Style/SignalException:
|
30
|
+
Enabled: false
|
31
|
+
|
32
|
+
# This never works for validations.
|
33
|
+
Style/AlignHash:
|
34
|
+
EnforcedLastArgumentHashStyle: ignore_implicit
|
35
|
+
|
36
|
+
# Align multi-line params with previous line.
|
37
|
+
Style/AlignParameters:
|
38
|
+
EnforcedStyle: with_fixed_indentation
|
39
|
+
|
40
|
+
# Indent `when` clause one step from `case`.
|
41
|
+
Style/CaseIndentation:
|
42
|
+
IndentOneStep: true
|
43
|
+
|
44
|
+
# Don't force bad var names for reduce/inject loops.
|
45
|
+
Style/SingleLineBlockParams:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# For method chains, keep the dot with the method name.
|
49
|
+
Style/DotPosition:
|
50
|
+
EnforcedStyle: leading
|
51
|
+
|
52
|
+
# Stop nesting so hard.
|
53
|
+
Metrics/BlockNesting:
|
54
|
+
Max: 2
|
55
|
+
|
56
|
+
# Encourage short methods.
|
57
|
+
Metrics/MethodLength:
|
58
|
+
Max: 10
|
59
|
+
|
60
|
+
# Encourage fewer parameters.
|
61
|
+
Metrics/ParameterLists:
|
62
|
+
Max: 4
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at jeffnyman@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/LICENSE.txt
CHANGED
@@ -1,22 +1,21 @@
|
|
1
|
-
|
1
|
+
The MIT License (MIT)
|
2
2
|
|
3
|
-
|
3
|
+
Copyright (c) 2016 Jeff Nyman
|
4
4
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
the following conditions:
|
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:
|
12
11
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
15
14
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
OF
|
22
|
-
|
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
CHANGED
@@ -1,35 +1,76 @@
|
|
1
1
|
# Testable
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/testable.svg)](http://badge.fury.io/rb/testable)
|
4
|
+
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jeffnyman/testable/blob/master/LICENSE.txt)
|
4
5
|
|
5
|
-
|
6
|
+
[![Dependency Status](https://gemnasium.com/jeffnyman/testable.png)](https://gemnasium.com/jeffnyman/testable)
|
7
|
+
|
8
|
+
Testable provides a semantic DSL to construct a fluent interface for test execution libraries.
|
9
|
+
|
10
|
+
This fluent interface promotes the idea of compressibility of your test logic, allowing for more factoring, more reuse, and less repetition. You can use Testable directly as an automated test library or you can use it with other tools such as RSpec, Cucumber, or anything else that allows you to delegate down to a different level of abstraction.
|
11
|
+
|
12
|
+
Unlike many of my other tooling experiments with Ruby, Testable relies on [Capybara](https://github.com/jnicklas/capybara) as its execution library.
|
6
13
|
|
7
14
|
## Installation
|
8
15
|
|
9
|
-
|
16
|
+
To get the latest stable release, add this line to your application's Gemfile:
|
10
17
|
|
11
18
|
```ruby
|
12
19
|
gem 'testable'
|
13
20
|
```
|
14
21
|
|
15
|
-
|
22
|
+
To get the latest code:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'testable', git: 'https://github.com/jeffnyman/testable'
|
26
|
+
```
|
27
|
+
|
28
|
+
After doing one of the above, execute the following command:
|
16
29
|
|
17
30
|
$ bundle
|
18
31
|
|
19
|
-
|
32
|
+
You can also install Testable just as you would any other gem:
|
20
33
|
|
21
34
|
$ gem install testable
|
22
35
|
|
23
36
|
## Usage
|
24
37
|
|
25
|
-
|
38
|
+
Probably the best way to get a feel for the current state of the code is to look at the test scripts:
|
39
|
+
|
40
|
+
* [Standard test script](https://github.com/jeffnyman/testable/blob/master/test/testable-standard.rb)
|
41
|
+
* [Factory test script](https://github.com/jeffnyman/testable/blob/master/test/testable-factory.rb)
|
42
|
+
|
43
|
+
If you clone the repository, you can see this script in action by running the command `rake scripts:standard` or `rake scripts:factory`.
|
44
|
+
|
45
|
+
More details will be forthcoming as the project evolves.
|
46
|
+
|
47
|
+
## Development
|
48
|
+
|
49
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rake spec:all` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
50
|
+
|
51
|
+
The default `rake` command will run all tests as well as a RuboCop analysis.
|
52
|
+
|
53
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/jeffnyman/testable](https://github.com/jeffnyman/testable). The testing ecosystem of Ruby is very large and this project is intended to be a welcoming arena for collaboration on yet another testing tool. As such, contributors are very much welcome but are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
58
|
+
|
59
|
+
This gem follows [semantic versioning](http://semver.org).
|
60
|
+
|
61
|
+
To contribute to Testable:
|
26
62
|
|
27
63
|
1. [Fork the project](http://gun.io/blog/how-to-github-fork-branch-and-pull-request/).
|
28
|
-
2. Create
|
64
|
+
2. Create your feature branch. (`git checkout -b my-new-feature`)
|
29
65
|
3. Commit your changes. (`git commit -am 'new feature'`)
|
30
66
|
4. Push the branch. (`git push origin my-new-feature`)
|
31
67
|
5. Create a new [pull request](https://help.github.com/articles/using-pull-requests).
|
32
68
|
|
33
|
-
##
|
69
|
+
## Author
|
70
|
+
|
71
|
+
* [Jeff Nyman](http://testerstories.com)
|
72
|
+
|
73
|
+
## License
|
34
74
|
|
35
|
-
Testable is distributed under the MIT
|
75
|
+
Testable is distributed under the [MIT](http://www.opensource.org/licenses/MIT) license.
|
76
|
+
See the [LICENSE](https://github.com/jeffnyman/testable/blob/master/LICENSE.txt) file for details.
|
data/Rakefile
CHANGED
@@ -1,2 +1,44 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
1
3
|
require "bundler/gem_tasks"
|
4
|
+
require "rdoc/task"
|
5
|
+
require "rubocop/rake_task"
|
6
|
+
require "rspec/core/rake_task"
|
7
|
+
|
8
|
+
RuboCop::RakeTask.new
|
9
|
+
|
10
|
+
namespace :scripts do
|
11
|
+
desc "Run the standard script."
|
12
|
+
task :standard do
|
13
|
+
system("ruby ./test/testable-standard.rb")
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Run the script with a factory."
|
17
|
+
task :factory do
|
18
|
+
system("ruby ./test/testable-factory.rb")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
namespace :spec do
|
23
|
+
desc "Clean all generated reports."
|
24
|
+
task :clean do
|
25
|
+
system('rm -rf spec/reports')
|
26
|
+
end
|
27
|
+
|
28
|
+
RSpec::Core::RakeTask.new(all: :clean) do |config|
|
29
|
+
options = %w(--color)
|
30
|
+
options += %w(--format documentation)
|
31
|
+
options += %w(--format html --out spec/reports/unit-test-report.html)
|
32
|
+
|
33
|
+
config.rspec_opts = options
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
rdoc.rdoc_dir = 'doc'
|
39
|
+
rdoc.main = 'README.md'
|
40
|
+
rdoc.title = "Testable #{Testable::VERSION}"
|
41
|
+
rdoc.rdoc_files.include('README*', 'lib/**/*.rb')
|
42
|
+
end
|
2
43
|
|
44
|
+
task default: ['spec:all', :rubocop]
|
data/bin/console
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "testable"
|
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
|
+
require "pry"
|
10
|
+
Pry.start
|
11
|
+
|
12
|
+
# require "irb"
|
13
|
+
# IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module Testable
|
2
|
+
module Element
|
3
|
+
def element(name, locator = nil)
|
4
|
+
no_locator(name) if locator.nil?
|
5
|
+
build(name, locator) do
|
6
|
+
define_method(name.to_s) do |*options|
|
7
|
+
find_first(locator, *options)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def elements(name, locator = nil)
|
13
|
+
no_locator(name) if locator.nil?
|
14
|
+
build(name, locator) do
|
15
|
+
define_method(name.to_s) do |*options|
|
16
|
+
find_all(locator, *options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def build(name, locator)
|
24
|
+
yield
|
25
|
+
add_element_methods(name, locator)
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_element_methods(name, locator)
|
29
|
+
existence_check(name, locator)
|
30
|
+
nonexistence_check(name, locator)
|
31
|
+
end
|
32
|
+
|
33
|
+
def existence_check(name, locator)
|
34
|
+
method_name = "has_#{name}?"
|
35
|
+
create_element_method(name, locator) do
|
36
|
+
define_method(method_name) do |*args|
|
37
|
+
element_exists?(locator, *args)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def nonexistence_check(name, locator)
|
43
|
+
method_name = "has_no_#{name}?"
|
44
|
+
create_element_method(name, locator) do
|
45
|
+
define_method(method_name) do |*args|
|
46
|
+
element_does_not_exist?(locator, *args)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def create_element_method(_name, _locator)
|
52
|
+
yield
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Testable
|
2
|
+
module Factory
|
3
|
+
# Creates a definition context for actions. If an existing context
|
4
|
+
# exists, that context will be re-used.
|
5
|
+
def on(definition, visit = false, &block)
|
6
|
+
unless @context.is_a?(definition)
|
7
|
+
@context = definition.new
|
8
|
+
@context.view if visit
|
9
|
+
end
|
10
|
+
|
11
|
+
yield @context if block
|
12
|
+
@context
|
13
|
+
end
|
14
|
+
|
15
|
+
# Creates a definition context for actions and establishes the
|
16
|
+
# context for execution.
|
17
|
+
def on_view(definition, &block)
|
18
|
+
on(definition, true, &block)
|
19
|
+
end
|
20
|
+
|
21
|
+
alias on_visit on_view
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "capybara/dsl"
|
2
|
+
require "testable/situation"
|
3
|
+
require "testable/element"
|
4
|
+
|
5
|
+
module Testable
|
6
|
+
include Situation
|
7
|
+
module Interface
|
8
|
+
module Page
|
9
|
+
include Capybara::DSL
|
10
|
+
|
11
|
+
module Attribute
|
12
|
+
include Situation
|
13
|
+
|
14
|
+
def url_is(url = nil)
|
15
|
+
url_is_empty if url.nil? || url.empty?
|
16
|
+
@url = url
|
17
|
+
end
|
18
|
+
|
19
|
+
def title_is(title = nil)
|
20
|
+
title_is_empty if title.nil? || title.empty?
|
21
|
+
@title = title
|
22
|
+
end
|
23
|
+
|
24
|
+
def url_attribute
|
25
|
+
@url
|
26
|
+
end
|
27
|
+
|
28
|
+
def title_attribute
|
29
|
+
@title
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def view
|
34
|
+
no_url_provided if (url.nil? || url == 'data:,') && url_attribute.nil?
|
35
|
+
visit(url_attribute)
|
36
|
+
end
|
37
|
+
|
38
|
+
def url
|
39
|
+
current_url
|
40
|
+
end
|
41
|
+
|
42
|
+
def url_attribute
|
43
|
+
self.class.url_attribute
|
44
|
+
end
|
45
|
+
|
46
|
+
def title_attribute
|
47
|
+
self.class.title_attribute
|
48
|
+
end
|
49
|
+
|
50
|
+
def secure?
|
51
|
+
!url.match(/^https/).nil?
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def find_first(*locator)
|
57
|
+
find(*locator)
|
58
|
+
end
|
59
|
+
|
60
|
+
def find_all(*locator)
|
61
|
+
all(*locator)
|
62
|
+
end
|
63
|
+
|
64
|
+
def element_exists?(*locator)
|
65
|
+
has_selector?(*locator)
|
66
|
+
end
|
67
|
+
|
68
|
+
def element_does_not_exist?(*locator)
|
69
|
+
has_no_selector?(*locator)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "testable/errors"
|
2
|
+
|
3
|
+
module Testable
|
4
|
+
module Situation
|
5
|
+
private
|
6
|
+
|
7
|
+
def url_is_empty
|
8
|
+
puts "PROBLEM: url_is attribute empty.\n" \
|
9
|
+
"The url_is attribute is empty on the definition " \
|
10
|
+
"'#{retrieve_class(caller)}'.\n\n"
|
11
|
+
raise Testable::Errors::NoUrlForDefinition
|
12
|
+
end
|
13
|
+
|
14
|
+
def title_is_empty
|
15
|
+
puts "PROBLEM: title_is attribute empty.\n" \
|
16
|
+
"The title_is attribute is empty on the definition " \
|
17
|
+
"'#{retrieve_class(caller)}'.\n\n"
|
18
|
+
raise Testable::Errors::NoTitleForDefinition
|
19
|
+
end
|
20
|
+
|
21
|
+
def no_url_provided
|
22
|
+
puts "PROBLEM: no url provided.\n" \
|
23
|
+
"You called a '#{retrieve_method(caller)}' action but the " \
|
24
|
+
"definition '#{self.class}' does not have a url_is attribute.\n" \
|
25
|
+
"Either provide the url_is attribute or pass the url as an " \
|
26
|
+
"argument to the visit call.\n\n"
|
27
|
+
raise Testable::Errors::NoUrlForDefinition
|
28
|
+
end
|
29
|
+
|
30
|
+
def no_locator(name)
|
31
|
+
puts "PROBLEM: No locator provided.\n" \
|
32
|
+
"You are using '#{name}' on '#{retrieve_class(caller)}'. " \
|
33
|
+
"But there is no locator provided with it.\n\n"
|
34
|
+
raise Testable::Errors::NoLocatorForDefinition
|
35
|
+
end
|
36
|
+
|
37
|
+
def retrieve_class(caller)
|
38
|
+
caller[1][/`.*'/][8..-3]
|
39
|
+
end
|
40
|
+
|
41
|
+
def retrieve_method(caller)
|
42
|
+
caller[0][/`.*'/][1..-2]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/testable/version.rb
CHANGED
@@ -1,3 +1,18 @@
|
|
1
1
|
module Testable
|
2
|
-
VERSION = "0.0.
|
2
|
+
VERSION = "0.2.0".freeze
|
3
|
+
|
4
|
+
module_function
|
5
|
+
|
6
|
+
def version
|
7
|
+
"""
|
8
|
+
Testable v#{Testable::VERSION}
|
9
|
+
Capybara: #{Gem.loaded_specs['capybara'].version}
|
10
|
+
selenium-webdriver: #{Gem.loaded_specs['selenium-webdriver'].version}
|
11
|
+
"""
|
12
|
+
end
|
13
|
+
|
14
|
+
def dependencies
|
15
|
+
Gem.loaded_specs.values.map { |x| "#{x.name} #{x.version}\n" }
|
16
|
+
.uniq.sort.join(",").split(",")
|
17
|
+
end
|
3
18
|
end
|
data/lib/testable.rb
CHANGED
@@ -1,4 +1,17 @@
|
|
1
|
+
require "capybara"
|
2
|
+
require "selenium-webdriver"
|
3
|
+
|
1
4
|
require "testable/version"
|
5
|
+
require "testable/element"
|
6
|
+
require "testable/factory"
|
7
|
+
require "testable/interface"
|
2
8
|
|
3
9
|
module Testable
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def included(caller)
|
13
|
+
caller.extend Testable::Element
|
14
|
+
caller.extend Testable::Interface::Page::Attribute
|
15
|
+
caller.__send__ :include, Testable::Interface::Page
|
16
|
+
end
|
4
17
|
end
|
data/testable.gemspec
CHANGED
@@ -8,28 +8,31 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Testable::VERSION
|
9
9
|
spec.authors = ["Jeff Nyman"]
|
10
10
|
spec.email = ["jeffnyman@gmail.com"]
|
11
|
-
|
12
|
-
spec.
|
13
|
-
|
14
|
-
|
15
|
-
referenced by test libraries using the DSL that Testable provides.
|
16
|
-
}
|
17
|
-
spec.homepage = "https://github.com/jnyman/testable"
|
11
|
+
|
12
|
+
spec.summary = %q{Provides a semantic DSL to construct fluent interfaces for test execution logic.}
|
13
|
+
spec.description = %q{Provides a semantic DSL to construct fluent interfaces for test execution logic.}
|
14
|
+
spec.homepage = "https://github.com/jeffnyman/testable"
|
18
15
|
spec.license = "MIT"
|
19
16
|
|
20
|
-
spec.files = `git ls-files -z`.split("\x0")
|
21
|
-
|
22
|
-
|
23
|
-
spec.
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
24
23
|
|
25
|
-
spec.add_development_dependency "bundler", "~> 1.
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
26
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
spec.add_development_dependency "rubocop"
|
28
|
+
spec.add_development_dependency "pry"
|
29
|
+
|
30
|
+
spec.add_runtime_dependency "capybara", [">= 2.10", "< 3.0"]
|
31
|
+
spec.add_runtime_dependency "selenium-webdriver", "~> 3.0"
|
27
32
|
|
28
33
|
spec.post_install_message = %{
|
29
34
|
(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
|
30
|
-
|
31
35
|
Testable #{Testable::VERSION} has been installed.
|
32
|
-
|
33
36
|
(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)
|
34
37
|
}
|
35
38
|
end
|
metadata
CHANGED
@@ -1,86 +1,172 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Nyman
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.13'
|
20
20
|
type: :development
|
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: '1.
|
26
|
+
version: '1.13'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
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
40
|
version: '10.0'
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: capybara
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.10'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '3.0'
|
93
|
+
type: :runtime
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '2.10'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '3.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: selenium-webdriver
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '3.0'
|
117
|
+
description: Provides a semantic DSL to construct fluent interfaces for test execution
|
118
|
+
logic.
|
45
119
|
email:
|
46
120
|
- jeffnyman@gmail.com
|
47
121
|
executables: []
|
48
122
|
extensions: []
|
49
123
|
extra_rdoc_files: []
|
50
124
|
files:
|
51
|
-
- .gitignore
|
125
|
+
- ".gitignore"
|
126
|
+
- ".hound.yml"
|
127
|
+
- ".rspec"
|
128
|
+
- ".rubocop.yml"
|
129
|
+
- ".travis.yml"
|
130
|
+
- CODE_OF_CONDUCT.md
|
52
131
|
- Gemfile
|
53
132
|
- LICENSE.txt
|
54
133
|
- README.md
|
55
134
|
- Rakefile
|
135
|
+
- bin/console
|
136
|
+
- bin/setup
|
56
137
|
- lib/testable.rb
|
138
|
+
- lib/testable/element.rb
|
139
|
+
- lib/testable/errors.rb
|
140
|
+
- lib/testable/factory.rb
|
141
|
+
- lib/testable/interface.rb
|
142
|
+
- lib/testable/situation.rb
|
57
143
|
- lib/testable/version.rb
|
58
144
|
- testable.gemspec
|
59
|
-
homepage: https://github.com/
|
145
|
+
homepage: https://github.com/jeffnyman/testable
|
60
146
|
licenses:
|
61
147
|
- MIT
|
62
148
|
metadata: {}
|
63
|
-
post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n
|
64
|
-
\ Testable 0.0
|
65
|
-
(::) (::) (::)
|
149
|
+
post_install_message: "\n(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::)\n
|
150
|
+
\ Testable 0.2.0 has been installed.\n(::) (::) (::) (::) (::) (::) (::) (::) (::)
|
151
|
+
(::) (::) (::)\n "
|
66
152
|
rdoc_options: []
|
67
153
|
require_paths:
|
68
154
|
- lib
|
69
155
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
156
|
requirements:
|
71
|
-
- -
|
157
|
+
- - ">="
|
72
158
|
- !ruby/object:Gem::Version
|
73
159
|
version: '0'
|
74
160
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
161
|
requirements:
|
76
|
-
- -
|
162
|
+
- - ">="
|
77
163
|
- !ruby/object:Gem::Version
|
78
164
|
version: '0'
|
79
165
|
requirements: []
|
80
166
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.5.1
|
82
168
|
signing_key:
|
83
169
|
specification_version: 4
|
84
|
-
summary:
|
170
|
+
summary: Provides a semantic DSL to construct fluent interfaces for test execution
|
171
|
+
logic.
|
85
172
|
test_files: []
|
86
|
-
has_rdoc:
|