-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 93d5240
Showing
19 changed files
with
661 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/Gemfile.lock | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
|
||
# rspec failure tracking | ||
.rspec_status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
AllCops: | ||
Exclude: | ||
- tapestry.gemspec | ||
- examples/*.rb | ||
- spec/**/* | ||
|
||
# Removing need for frozen string literal comment. | ||
#Style/FrozenStringLiteralComment: | ||
# Enabled: false | ||
|
||
# Removing the preference for string single quotes. | ||
Style/StringLiterals: | ||
Enabled: false | ||
|
||
# Missing top-level module documentation comment. | ||
Style/Documentation: | ||
Enabled: false | ||
|
||
# Prefer reduce over inject. | ||
Style/CollectionMethods: | ||
PreferredMethods: | ||
reduce: 'inject' | ||
|
||
# Use each_with_object instead of inject. | ||
Style/EachWithObject: | ||
Enabled: false | ||
|
||
# Prefer fail over raise. | ||
Style/SignalException: | ||
Enabled: false | ||
|
||
# This never works for validations. | ||
Style/AlignHash: | ||
EnforcedLastArgumentHashStyle: ignore_implicit | ||
|
||
# Align multi-line params with previous line. | ||
Style/AlignParameters: | ||
EnforcedStyle: with_fixed_indentation | ||
|
||
# Indent `when` clause one step from `case`. | ||
Style/CaseIndentation: | ||
IndentOneStep: true | ||
|
||
# Don't force bad var names for reduce/inject loops. | ||
Style/SingleLineBlockParams: | ||
Enabled: false | ||
|
||
# For method chains, keep the dot with the method name. | ||
Style/DotPosition: | ||
EnforcedStyle: leading | ||
|
||
# Stop nesting so hard. | ||
Metrics/BlockNesting: | ||
Max: 2 | ||
|
||
# Encourage short methods. | ||
Metrics/MethodLength: | ||
Max: 15 | ||
|
||
# Encourage fewer parameters. | ||
Metrics/ParameterLists: | ||
Max: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
--format documentation | ||
--color | ||
--require spec_helper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
inherit_from: | ||
- .hound.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
sudo: false | ||
language: ruby | ||
rvm: | ||
- 2.3.1 | ||
before_install: gem install bundler -v 1.14.3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Contributor Covenant Code of Conduct | ||
|
||
## Our Pledge | ||
|
||
In the interest of fostering an open and welcoming environment, we as | ||
contributors and maintainers pledge to making participation in our project and | ||
our community a harassment-free experience for everyone, regardless of age, body | ||
size, disability, ethnicity, gender identity and expression, level of experience, | ||
nationality, personal appearance, race, religion, or sexual identity and | ||
orientation. | ||
|
||
## Our Standards | ||
|
||
Examples of behavior that contributes to creating a positive environment | ||
include: | ||
|
||
* Using welcoming and inclusive language | ||
* Being respectful of differing viewpoints and experiences | ||
* Gracefully accepting constructive criticism | ||
* Focusing on what is best for the community | ||
* Showing empathy towards other community members | ||
|
||
Examples of unacceptable behavior by participants include: | ||
|
||
* The use of sexualized language or imagery and unwelcome sexual attention or | ||
advances | ||
* Trolling, insulting/derogatory comments, and personal or political attacks | ||
* Public or private harassment | ||
* Publishing others' private information, such as a physical or electronic | ||
address, without explicit permission | ||
* Other conduct which could reasonably be considered inappropriate in a | ||
professional setting | ||
|
||
## Our Responsibilities | ||
|
||
Project maintainers are responsible for clarifying the standards of acceptable | ||
behavior and are expected to take appropriate and fair corrective action in | ||
response to any instances of unacceptable behavior. | ||
|
||
Project maintainers have the right and responsibility to remove, edit, or | ||
reject comments, commits, code, wiki edits, issues, and other contributions | ||
that are not aligned to this Code of Conduct, or to ban temporarily or | ||
permanently any contributor for other behaviors that they deem inappropriate, | ||
threatening, offensive, or harmful. | ||
|
||
## Scope | ||
|
||
This Code of Conduct applies both within project spaces and in public spaces | ||
when an individual is representing the project or its community. Examples of | ||
representing a project or community include using an official project e-mail | ||
address, posting via an official social media account, or acting as an appointed | ||
representative at an online or offline event. Representation of a project may be | ||
further defined and clarified by project maintainers. | ||
|
||
## Enforcement | ||
|
||
Instances of abusive, harassing, or otherwise unacceptable behavior may be | ||
reported by contacting the project team at jeff.nyman@sproutsocial.com. All | ||
complaints will be reviewed and investigated and will result in a response that | ||
is deemed necessary and appropriate to the circumstances. The project team is | ||
obligated to maintain confidentiality with regard to the reporter of an incident. | ||
Further details of specific enforcement policies may be posted separately. | ||
|
||
Project maintainers who do not follow or enforce the Code of Conduct in good | ||
faith may face temporary or permanent repercussions as determined by other | ||
members of the project's leadership. | ||
|
||
## Attribution | ||
|
||
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, | ||
available at [http://contributor-covenant.org/version/1/4][version] | ||
|
||
[homepage]: http://contributor-covenant.org | ||
[version]: http://contributor-covenant.org/version/1/4/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in tapestry.gemspec | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2017 Jeff Nyman | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Tapestry | ||
|
||
> _Nature uses only the longest threads to weave her patterns, so that each | ||
> small piece of her fabric reveals the organization of the entire tapestry._ | ||
> | ||
> **Richard Feynman** | ||
The Tapestry gem serves as a micro-framework that provides a semantic DSL to construct a fluent interface for test execution libraries. | ||
|
||
The fluent interface is designed to promote the idea of compressibility of your test logic, allowing for more factoring, more reuse, and less repetition. You can use Tapestry directly as an automated checking 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. | ||
|
||
> _There were loose threads ... untidy parts of me that I would like to | ||
> remove. But when I pulled on one of those threads ... it unraveled the | ||
> tapestry of my life._ | ||
> | ||
> **Captain Jean-Luc Picard, _Star Trek: The Next Generation_ ("Tapestry")** | ||
Tapestry is an abstraction layer on top of WebDriver, quite similar to how, say, Express is an abstraction layer on top of Node's built-in HTTP server. Just as you could, in theory, write everything with plain vanilla Node and never touch Express, you could write everything directly at the level of Selenium and never worry about Tapestry. | ||
|
||
The whole point of an abstraction layer is to smooth out the difficult and/or fiddly bits. As such, Tapestry is actually an abstraction on top of a library called Watir (Web Application Testing in Ruby). Watir itself is an abstraction layer over Selenium which is, in turn, a particular abstraction of WebDriver. | ||
|
||
> _We look at life from the back side of the tapestry. And most of the time, | ||
> what we see is loose threads, tangled knots and the like. But occasionally, | ||
> God's light shines through the tapestry, and we get a glimpse of the larger | ||
> design with God weaving together the darks and lights of existence._ | ||
> | ||
> **John Piper** | ||
Tapestry is built, as are all my test-supporting tools, on the idea that automation should largely be small-footprint, low-fiction, high-yield. | ||
|
||
The code that a test-supporting micro-framework allows should be modular, promoting both high cohesion and low coupling, as well as promoting a single level of abstraction. These concepts together lead to lightweight design as well as support traits that make change affordable. That makes the automation code less expensive to maintain and easier to change. That, ultimately, has a positive impact on the cost of change. | ||
|
||
## Installation | ||
|
||
To get the latest stable release, add this line to your application's Gemfile: | ||
|
||
```ruby | ||
gem 'tapestry' | ||
``` | ||
|
||
To get the latest code: | ||
|
||
```ruby | ||
gem 'tapestry', git: 'https://github.com/jeffnyman/tapestry' | ||
``` | ||
|
||
After doing one of the above, execute the following command: | ||
|
||
$ bundle | ||
|
||
You can also install Tapestry just as you would any other gem: | ||
|
||
$ gem install tapestry | ||
|
||
## Usage | ||
|
||
Probably the best way to get a feel for the current state of the code is to look at the examples: | ||
|
||
* [Simple script](https://github.com/jeffnyman/tapestry/blob/master/examples/tapestry-simple.rb) | ||
|
||
You'll see references to "Veilus" and a "localhost" in the script. I'm using my own [Veilus application](https://veilus.herokuapp.com/). As far as the localhost, you can use the [Veilus repo](https://github.com/jeffnyman/veilus) to get a local copy to play around with. | ||
|
||
If you clone this repository, you can see this script in action by running the command `rake script:simple`. | ||
|
||
More details will be forthcoming as the project evolves. | ||
|
||
## Development | ||
|
||
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. | ||
|
||
The default `rake` command will run all tests as well as a RuboCop analysis. | ||
|
||
To install this gem onto your local machine, run `bundle exec rake install`. | ||
|
||
## Contributing | ||
|
||
Bug reports and pull requests are welcome on GitHub at [https://github.com/jeffnyman/tapestry](https://github.com/jeffnyman/tapestry). The testing ecosystem of Ruby is very large and this project is intended to be a welcoming arena for collaboration on yet another test-supporting tool. As such, contributors are very much welcome but are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct. | ||
|
||
The Tapestry gems follows [semantic versioning](http://semver.org). | ||
|
||
To contribute to Tapestry: | ||
|
||
1. [Fork the project](http://gun.io/blog/how-to-github-fork-branch-and-pull-request/). | ||
2. Create your feature branch. (`git checkout -b my-new-feature`) | ||
3. Commit your changes. (`git commit -am 'new feature'`) | ||
4. Push the branch. (`git push origin my-new-feature`) | ||
5. Create a new [pull request](https://help.github.com/articles/using-pull-requests). | ||
|
||
## Author | ||
|
||
* [Jeff Nyman](http://testerstories.com) | ||
|
||
## License | ||
|
||
Tapestry is distributed under the [MIT](http://www.opensource.org/licenses/MIT) license. | ||
See the [LICENSE](https://github.com/jeffnyman/tapestry/blob/master/LICENSE.md) file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env rake | ||
require "bundler/gem_tasks" | ||
require "rdoc/task" | ||
require "rspec/core/rake_task" | ||
require "rubocop/rake_task" | ||
|
||
RuboCop::RakeTask.new | ||
|
||
RSpec::Core::RakeTask.new(:spec) | ||
|
||
namespace :script do | ||
desc "Run the Tapestry simple script" | ||
task :simple do | ||
system("ruby ./examples/tapestry-simple.rb") | ||
end | ||
end | ||
|
||
namespace :spec do | ||
desc 'Clean all generated reports' | ||
task :clean do | ||
system('rm -rf spec/reports') | ||
end | ||
|
||
RSpec::Core::RakeTask.new(all: :clean) do |config| | ||
options = %w(--color) | ||
options += %w(--format documentation) | ||
options += %w(--format html --out spec/reports/unit-test-report.html) | ||
|
||
config.rspec_opts = options | ||
end | ||
end | ||
|
||
Rake::RDocTask.new do |rdoc| | ||
rdoc.rdoc_dir = 'doc' | ||
rdoc.main = 'README.md' | ||
rdoc.title = "Tapestry #{Tapestry::VERSION}" | ||
rdoc.rdoc_files.include('README*', 'lib/**/*.rb') | ||
end | ||
|
||
task default: ['spec:all', :rubocop] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/usr/bin/env ruby | ||
|
||
require "bundler/setup" | ||
require "tapestry" | ||
|
||
# You can add fixtures and/or initialization code here to make experimenting | ||
# with your gem easier. You can also use a different console, if you like. | ||
|
||
require "pry" | ||
Pry.start | ||
|
||
# require "irb" | ||
# IRB.start(__FILE__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
set -vx | ||
|
||
bundle install | ||
|
||
# Do any other automated setup that you need to do here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env ruby | ||
$: << "./lib" | ||
|
||
require "rspec" | ||
include RSpec::Matchers | ||
|
||
require "tapestry" | ||
|
||
puts Tapestry::VERSION | ||
|
||
browser = Watir::Browser.new | ||
|
||
class Home | ||
include Tapestry | ||
|
||
p :login_form, id: "open", visible: true | ||
text_field :username, id: "username" | ||
text_field :password | ||
button :login, id: "login-button" | ||
|
||
#element :login_form, id: "open", visible: true | ||
#element :username, id: "username" | ||
#element :password | ||
#element :login, id: "login-button" | ||
end | ||
|
||
browser.goto("http://localhost:9292") | ||
page = Home.new(browser) | ||
page.login_form.click | ||
page.username.set "admin" | ||
page.password(id: 'password').set "admin" | ||
page.login.click | ||
|
||
browser.quit() |
Oops, something went wrong.