testable 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +33 -25
- data/.hound.yml +21 -12
- data/.rubocop.yml +4 -0
- data/.travis.yml +7 -0
- data/CODE_OF_CONDUCT.md +1 -1
- data/Gemfile +3 -1
- data/{LICENSE.txt → LICENSE.md} +2 -2
- data/README.md +12 -25
- data/Rakefile +20 -11
- data/bin/console +2 -2
- data/examples/testable-info.rb +65 -0
- data/examples/testable-watir-context.rb +67 -0
- data/examples/testable-watir-datasetter.rb +52 -0
- data/examples/testable-watir-events.rb +44 -0
- data/examples/testable-watir-ready.rb +34 -0
- data/examples/testable-watir-test.rb +67 -0
- data/examples/testable-watir.rb +118 -0
- data/lib/testable/attribute.rb +38 -0
- data/lib/testable/context.rb +72 -0
- data/lib/testable/element.rb +162 -31
- data/lib/testable/errors.rb +6 -2
- data/lib/testable/extensions/data_setter.rb +109 -0
- data/lib/testable/extensions/dom_observer.js +58 -4
- data/lib/testable/extensions/dom_observer.rb +73 -0
- data/lib/testable/locator.rb +63 -0
- data/lib/testable/page.rb +216 -0
- data/lib/testable/ready.rb +49 -7
- data/lib/testable/situation.rb +9 -28
- data/lib/testable/version.rb +7 -6
- data/lib/testable.rb +37 -10
- data/testable.gemspec +16 -8
- metadata +70 -18
- data/circle.yml +0 -3
- data/lib/testable/data_setter.rb +0 -51
- data/lib/testable/dom_update.rb +0 -19
- data/lib/testable/factory.rb +0 -27
- data/lib/testable/interface.rb +0 -114
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f0b41932f26b804cd3a7216914b135ed21c72e716734b485452d8ba89fade529
|
4
|
+
data.tar.gz: f0b824f615eebe4edd4520f1c1705ee50dc76a6efd2ba7c5281931e42910b162
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa8a4ac245684d7b7ac89104534eb2aa285779c2ed1b064c04fe2a248d73f56cf16b7fc9fab5c593cd37f3e270759aa4e13227418c04e1a4d926eb68a921aa6d
|
7
|
+
data.tar.gz: ec136ec9fb01d955d3e40f2984a10764d03a5e7eb2a9c32a804a40f1db3cf17af856ad778ecd3b48f8b7f6e8d3ae7652accffe77b73eaac5b40c37d738da3190
|
data/.gitignore
CHANGED
@@ -1,41 +1,49 @@
|
|
1
|
-
# Ruby
|
1
|
+
# Ruby Generated
|
2
2
|
|
3
|
+
/Gemfile.lock
|
3
4
|
/.bundle/
|
4
5
|
/.yardoc
|
5
|
-
/Gemfile.lock
|
6
6
|
/_yardoc/
|
7
|
-
|
8
|
-
# Ouput-Specific
|
9
|
-
|
10
7
|
/coverage/
|
11
8
|
/doc/
|
12
9
|
/pkg/
|
13
10
|
/spec/reports/
|
14
|
-
/spec/
|
11
|
+
/spec/coverage/
|
15
12
|
/tmp/
|
16
|
-
*.log
|
17
|
-
*.tmp
|
18
|
-
*.swp
|
19
|
-
*.bak
|
20
13
|
|
21
|
-
#
|
14
|
+
# Generated Reports
|
15
|
+
reports/
|
22
16
|
|
23
|
-
|
24
|
-
.settings
|
25
|
-
.project
|
26
|
-
.classpath
|
27
|
-
*.iws
|
17
|
+
# Rspec Failure Tracking
|
28
18
|
|
29
|
-
|
19
|
+
.rspec_status
|
30
20
|
|
31
|
-
|
21
|
+
# IDE Files
|
32
22
|
|
33
|
-
|
34
|
-
|
35
|
-
*.
|
36
|
-
|
23
|
+
.idea/
|
24
|
+
*.iml
|
25
|
+
*.iws
|
26
|
+
*.ipr
|
27
|
+
.vscode/
|
28
|
+
.settings/
|
29
|
+
.metadata
|
30
|
+
.classpath
|
31
|
+
.loadpath
|
32
|
+
.buildpath
|
33
|
+
.project
|
37
34
|
|
38
|
-
#
|
35
|
+
# OS Files
|
39
36
|
|
40
|
-
.
|
41
|
-
.
|
37
|
+
.DS_Store
|
38
|
+
.DS_Store?
|
39
|
+
._*
|
40
|
+
.Spotlight-V100
|
41
|
+
.Trashes
|
42
|
+
ehthumbs.db
|
43
|
+
Thumbs.db
|
44
|
+
$RECYCLE.BIN/
|
45
|
+
Desktop.ini
|
46
|
+
*.tmp
|
47
|
+
*.bak
|
48
|
+
*.swp
|
49
|
+
*~.nib
|
data/.hound.yml
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
Exclude:
|
3
3
|
- testable.gemspec
|
4
|
-
- test/*.rb
|
5
4
|
- spec/**/*
|
6
5
|
|
7
6
|
# Removing need for frozen string literal comment.
|
@@ -30,15 +29,15 @@ Style/SignalException:
|
|
30
29
|
Enabled: false
|
31
30
|
|
32
31
|
# This never works for validations.
|
33
|
-
|
32
|
+
Layout/AlignHash:
|
34
33
|
EnforcedLastArgumentHashStyle: ignore_implicit
|
35
34
|
|
36
35
|
# Align multi-line params with previous line.
|
37
|
-
|
36
|
+
Layout/AlignParameters:
|
38
37
|
EnforcedStyle: with_fixed_indentation
|
39
38
|
|
40
39
|
# Indent `when` clause one step from `case`.
|
41
|
-
|
40
|
+
Layout/CaseIndentation:
|
42
41
|
IndentOneStep: true
|
43
42
|
|
44
43
|
# Don't force bad var names for reduce/inject loops.
|
@@ -46,23 +45,33 @@ Style/SingleLineBlockParams:
|
|
46
45
|
Enabled: false
|
47
46
|
|
48
47
|
# For method chains, keep the dot with the method name.
|
49
|
-
|
48
|
+
Layout/DotPosition:
|
50
49
|
EnforcedStyle: leading
|
51
50
|
|
52
|
-
# Allow methods with has_ for predicates.
|
53
|
-
Style/PredicateName:
|
54
|
-
NameWhitelist:
|
55
|
-
- has_correct_url?
|
56
|
-
- has_correct_title?
|
57
|
-
|
58
51
|
# Stop nesting so hard.
|
59
52
|
Metrics/BlockNesting:
|
60
53
|
Max: 2
|
61
54
|
|
62
55
|
# Encourage short methods.
|
63
56
|
Metrics/MethodLength:
|
64
|
-
Max:
|
57
|
+
Max: 15
|
58
|
+
|
59
|
+
# Encourage short (as possible) modules.
|
60
|
+
Metrics/ModuleLength:
|
61
|
+
Max: 100
|
65
62
|
|
66
63
|
# Encourage fewer parameters.
|
67
64
|
Metrics/ParameterLists:
|
68
65
|
Max: 4
|
66
|
+
|
67
|
+
# Remove execute permissions check.
|
68
|
+
Lint/ScriptPermission:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
# Testable Exceptions
|
72
|
+
|
73
|
+
# Allow methods with has_ for predicates.
|
74
|
+
Naming/PredicateName:
|
75
|
+
NameWhitelist:
|
76
|
+
- has_correct_title?
|
77
|
+
- has_correct_url?
|
data/.rubocop.yml
CHANGED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
CHANGED
@@ -55,7 +55,7 @@ further defined and clarified by project maintainers.
|
|
55
55
|
## Enforcement
|
56
56
|
|
57
57
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
-
reported by contacting the project team at
|
58
|
+
reported by contacting the project team at TODO: Write your email address. All
|
59
59
|
complaints will be reviewed and investigated and will result in a response that
|
60
60
|
is deemed necessary and appropriate to the circumstances. The project team is
|
61
61
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
data/Gemfile
CHANGED
data/{LICENSE.txt → LICENSE.md}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
|
-
The MIT License (MIT)
|
1
|
+
**The MIT License (MIT)**
|
2
2
|
|
3
|
-
Copyright
|
3
|
+
Copyright © 2019 Jeff Nyman
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# Testable
|
2
2
|
|
3
|
-
[
|
4
|
-
[![Gem Version](https://badge.fury.io/rb/testable.svg)](http://badge.fury.io/rb/testable)
|
5
|
-
[![License](http://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jeffnyman/testable/blob/master/LICENSE.txt)
|
3
|
+
Testable is an automated test micro-framework that provides a thin wrapper around [Watir](http://watir.com/) and [Capybara](http://teamcapybara.github.io/capybara/). Testable is based on many ideas from tools like [SitePrism](https://github.com/natritmeyer/site_prism) and [Watirsome](https://github.com/p0deje/watirsome), while also being a logical evolution of my own tool, [Tapestry](https://github.com/jeffnyman/tapestry).
|
6
4
|
|
7
|
-
|
5
|
+
An automated test framework provides a machine-executable abstraction around testing and encodes a set of guiding principles and heuristics for writing tests-as-code.
|
8
6
|
|
9
|
-
|
7
|
+
One of the obstacles to covering the gap between principles of testing and the practice of testing is the mechanics of writing tests. These mechanics are focused on abstractions. A lot of the practice of testing comes down to that: finding the right abstractions. Any automated test framework should be capable of consuming your preferred abstractions because ultimately your automation is simply a tool that supports testing, which means how the framework encourages tests to be expressed should have high fidelty with how human tests would be expressed.
|
10
8
|
|
11
|
-
|
9
|
+
Testable is built, as are all of my test-supporting tools, on the idea that automation should largely be small-footprint, low-fiction, and high-yield.
|
10
|
+
|
11
|
+
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 but, more importantly, allows Testable to be fit within a cost of mistake model, where the goal is to get feedback as quickly as possible regarding when mistakes are made.
|
12
12
|
|
13
13
|
## Installation
|
14
14
|
|
@@ -34,22 +34,7 @@ You can also install Testable just as you would any other gem:
|
|
34
34
|
|
35
35
|
## Usage
|
36
36
|
|
37
|
-
|
38
|
-
|
39
|
-
* [Standard test script](https://github.com/jeffnyman/testable/blob/master/test/testable-standard.rb)
|
40
|
-
* [Factory test script](https://github.com/jeffnyman/testable/blob/master/test/testable-factory.rb)
|
41
|
-
|
42
|
-
If you clone the repository, you can see this script in action by running the command `rake script:standard` or `rake script:factory`.
|
43
|
-
|
44
|
-
You'll see references to "Veilus" and a localhost URL. I'm using my own [Veilus application](https://veilus.herokuapp.com/). The localhost refers to using the [Veilus repo](https://github.com/jeffnyman/veilus) locally.
|
45
|
-
|
46
|
-
More details will be forthcoming as the project evolves.
|
47
|
-
|
48
|
-
## Implementation Ideas
|
49
|
-
|
50
|
-
I want to hide driver details (i.e., Selenium) as much as possible but still allow access to the full API. Ideally I'd like to avoid the low-level Selenium and use a wrapper around it while not inventing my own. Since both watir-webdriver and capybara delegate down to Selenium, it seems wise to use one of those. (Or maybe allow for both as Symbiont currently does.) An open question is whether I should proxy the driver library to my own implementation or not. Symbiont currently does exactly that, which is a very different model than [page-object](https://github.com/cheezy/page-object), which has to add an incredible amount of wasted code rather than just relying on delegation and a proxy pattern.
|
51
|
-
|
52
|
-
I don't want to presume a particular modeling structure, such as the use of page objects. That being said, most such modeling structures are really just classes that are being utilized in a certain way, which means I really want to model the more generic notion of an interface. An interface could, theoretically, be an application (screens), a site (pages), or an API (services). An interface would be a Screen class, a Page class, or a Service class. These then become screen objects, page objects or service objects. An open question is how those distinctions are purely conceptual versus have specific implementations.
|
37
|
+
Instructions coming soon.
|
53
38
|
|
54
39
|
## Development
|
55
40
|
|
@@ -61,9 +46,11 @@ To install this gem onto your local machine, run `bundle exec rake install`.
|
|
61
46
|
|
62
47
|
## Contributing
|
63
48
|
|
64
|
-
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
|
49
|
+
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 test-supporting tool.
|
50
|
+
|
51
|
+
Everyone interacting in the Testable project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jeffnyman/testable/blob/master/CODE_OF_CONDUCT.md).
|
65
52
|
|
66
|
-
|
53
|
+
The Testable gem follows [semantic versioning](http://semver.org).
|
67
54
|
|
68
55
|
To contribute to Testable:
|
69
56
|
|
@@ -80,4 +67,4 @@ To contribute to Testable:
|
|
80
67
|
## License
|
81
68
|
|
82
69
|
Testable is distributed under the [MIT](http://www.opensource.org/licenses/MIT) license.
|
83
|
-
See the [LICENSE](https://github.com/jeffnyman/testable/blob/master/LICENSE.
|
70
|
+
See the [LICENSE](https://github.com/jeffnyman/testable/blob/master/LICENSE.md) file for details.
|
data/Rakefile
CHANGED
@@ -1,22 +1,30 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require "bundler/gem_tasks"
|
3
|
+
|
3
4
|
require "rdoc/task"
|
4
|
-
require "rspec/core/rake_task"
|
5
5
|
require "rubocop/rake_task"
|
6
|
+
require "rspec/core/rake_task"
|
6
7
|
|
7
8
|
RuboCop::RakeTask.new
|
8
9
|
|
9
10
|
RSpec::Core::RakeTask.new(:spec)
|
10
11
|
|
11
|
-
namespace :
|
12
|
-
desc "Run the Testable
|
13
|
-
task :
|
14
|
-
system("ruby ./
|
12
|
+
namespace :script_testable do
|
13
|
+
desc "Run the Testable info script"
|
14
|
+
task :info do
|
15
|
+
system("ruby ./examples/testable-info.rb")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
namespace :script_watir do
|
20
|
+
desc "Run the Testable Watir script"
|
21
|
+
task :watir do
|
22
|
+
system("ruby ./examples/testable-watir.rb")
|
15
23
|
end
|
16
24
|
|
17
|
-
desc "Run the Testable
|
18
|
-
task :
|
19
|
-
system("ruby ./
|
25
|
+
desc "Run the Testable Watir example test"
|
26
|
+
task :test do
|
27
|
+
system("ruby ./examples/testable-watir-test.rb")
|
20
28
|
end
|
21
29
|
end
|
22
30
|
|
@@ -24,12 +32,13 @@ namespace :spec do
|
|
24
32
|
desc 'Clean all generated reports'
|
25
33
|
task :clean do
|
26
34
|
system('rm -rf spec/reports')
|
35
|
+
system('rm -rf spec/coverage')
|
27
36
|
end
|
28
37
|
|
29
38
|
RSpec::Core::RakeTask.new(all: :clean) do |config|
|
30
|
-
options = %w
|
31
|
-
options += %w
|
32
|
-
options += %w
|
39
|
+
options = %w[--color]
|
40
|
+
options += %w[--format documentation]
|
41
|
+
options += %w[--format html --out spec/reports/unit-test-report.html]
|
33
42
|
|
34
43
|
config.rspec_opts = options
|
35
44
|
end
|
data/bin/console
CHANGED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH << "./lib"
|
3
|
+
|
4
|
+
require "testable"
|
5
|
+
|
6
|
+
require "rspec"
|
7
|
+
# rubocop:disable Style/MixinUsage
|
8
|
+
include RSpec::Matchers
|
9
|
+
# rubocop:enable Style/MixinUsage
|
10
|
+
|
11
|
+
puts Testable::VERSION
|
12
|
+
|
13
|
+
puts "================================="
|
14
|
+
puts "Testable's Version"
|
15
|
+
puts "================================="
|
16
|
+
puts Testable.version
|
17
|
+
|
18
|
+
puts "================================="
|
19
|
+
puts "Testable's Dependencies"
|
20
|
+
puts "================================="
|
21
|
+
puts Testable.dependencies
|
22
|
+
|
23
|
+
puts "================================="
|
24
|
+
puts "Testable's API"
|
25
|
+
puts "================================="
|
26
|
+
puts Testable.api
|
27
|
+
|
28
|
+
class Home
|
29
|
+
include Testable
|
30
|
+
end
|
31
|
+
|
32
|
+
Testable.start_browser :firefox, headless: true
|
33
|
+
|
34
|
+
page = Home.new
|
35
|
+
|
36
|
+
expect(Testable.browser).to be_an_instance_of(Watir::Browser)
|
37
|
+
expect(Testable.browser.driver).to be_an_instance_of(
|
38
|
+
Selenium::WebDriver::Firefox::Marionette::Driver
|
39
|
+
)
|
40
|
+
|
41
|
+
expect(page).to be_a_kind_of(Testable)
|
42
|
+
expect(page).to be_an_instance_of(Home)
|
43
|
+
|
44
|
+
puts "================================="
|
45
|
+
puts "Testable's Watir API"
|
46
|
+
puts "================================="
|
47
|
+
puts Testable.watir_api
|
48
|
+
|
49
|
+
puts "================================="
|
50
|
+
puts "Testable's Selenium API"
|
51
|
+
puts "================================="
|
52
|
+
puts Testable.selenium_api
|
53
|
+
|
54
|
+
puts "================================="
|
55
|
+
puts "Testable's Definition API"
|
56
|
+
puts "================================="
|
57
|
+
puts page.definition_api
|
58
|
+
|
59
|
+
puts "================================="
|
60
|
+
puts "Testable's Elements"
|
61
|
+
puts "================================="
|
62
|
+
puts Testable.elements?
|
63
|
+
puts Testable.recognizes?("div")
|
64
|
+
|
65
|
+
Testable.quit_browser
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH << "./lib"
|
3
|
+
|
4
|
+
require "rspec"
|
5
|
+
# rubocop:disable Style/MixinUsage
|
6
|
+
include RSpec::Matchers
|
7
|
+
# rubocop:enable Style/MixinUsage
|
8
|
+
|
9
|
+
require "testable"
|
10
|
+
# rubocop:disable Style/MixinUsage
|
11
|
+
include Testable::Context
|
12
|
+
# rubocop:enable Style/MixinUsage
|
13
|
+
|
14
|
+
class Home
|
15
|
+
include Testable
|
16
|
+
|
17
|
+
url_is "https://veilus.herokuapp.com/"
|
18
|
+
url_matches(/heroku/)
|
19
|
+
title_is "Veilus"
|
20
|
+
|
21
|
+
# Elements can be defined with HTML-style names as found in Watir.
|
22
|
+
p :login_form, id: "open", visible: true
|
23
|
+
text_field :username, id: "username"
|
24
|
+
text_field :password
|
25
|
+
button :login, id: "login-button"
|
26
|
+
div :message, class: "notice"
|
27
|
+
|
28
|
+
# Elements can be defined with a generic name.
|
29
|
+
# element :login_form, id: "open", visible: true
|
30
|
+
# element :username, id: "username"
|
31
|
+
# element :password
|
32
|
+
# element :login, id: "login-button"
|
33
|
+
# element :message, class: "notice"
|
34
|
+
|
35
|
+
def begin_with
|
36
|
+
move_to(0, 0)
|
37
|
+
resize_to(screen_width, screen_height)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class Navigation
|
42
|
+
include Testable
|
43
|
+
|
44
|
+
p :page_list, id: "navlist"
|
45
|
+
link :planets, id: "planets"
|
46
|
+
|
47
|
+
image :planet_logo, id: "planet-logo"
|
48
|
+
end
|
49
|
+
|
50
|
+
Testable.start_browser :firefox
|
51
|
+
|
52
|
+
on_visit(Home) do
|
53
|
+
@active.login_form.click
|
54
|
+
@active.username.set "admin"
|
55
|
+
@active.password(id: 'password').set "admin"
|
56
|
+
@active.login.click
|
57
|
+
expect(@active.message.text).to eq('You are now logged in as admin.')
|
58
|
+
end
|
59
|
+
|
60
|
+
on(Navigation) do |page|
|
61
|
+
page.page_list.click
|
62
|
+
# page.page_list.wait_until(&:dom_updated?).click
|
63
|
+
page.planets.click
|
64
|
+
expect(page.planet_logo.exists?).to be true
|
65
|
+
end
|
66
|
+
|
67
|
+
Testable.quit_browser
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH << "./lib"
|
3
|
+
|
4
|
+
require "rspec"
|
5
|
+
# rubocop:disable Style/MixinUsage
|
6
|
+
include RSpec::Matchers
|
7
|
+
# rubocop:enable Style/MixinUsage
|
8
|
+
|
9
|
+
require "testable"
|
10
|
+
# rubocop:disable Style/MixinUsage
|
11
|
+
include Testable::Context
|
12
|
+
# rubocop:enable Style/MixinUsage
|
13
|
+
|
14
|
+
class Home
|
15
|
+
include Testable
|
16
|
+
|
17
|
+
url_is "https://veilus.herokuapp.com/"
|
18
|
+
|
19
|
+
p :login_form, id: "open", visible: true
|
20
|
+
text_field :username, id: "username"
|
21
|
+
text_field :password
|
22
|
+
button :login, id: "login-button"
|
23
|
+
div :message, class: 'notice'
|
24
|
+
|
25
|
+
def begin_with
|
26
|
+
move_to(0, 0)
|
27
|
+
resize_to(screen_width, screen_height)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class WarpTravel
|
32
|
+
include Testable
|
33
|
+
|
34
|
+
url_is "https://veilus.herokuapp.com/warp"
|
35
|
+
|
36
|
+
text_field :warp_factor, id: 'warpInput'
|
37
|
+
text_field :velocity, id: 'velocityInput'
|
38
|
+
text_field :distance, id: 'distInput'
|
39
|
+
end
|
40
|
+
|
41
|
+
Testable.start_browser :firefox
|
42
|
+
|
43
|
+
on_visit(Home) do
|
44
|
+
@active.login_form.click
|
45
|
+
@active.username.set "admin"
|
46
|
+
@active.password(id: 'password').set "admin"
|
47
|
+
@active.login.click
|
48
|
+
end
|
49
|
+
|
50
|
+
on_visit(WarpTravel).using_data("warp factor": 1, velocity: 1, distance: 4.3)
|
51
|
+
|
52
|
+
Testable.quit_browser
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH << "./lib"
|
3
|
+
|
4
|
+
require "rspec"
|
5
|
+
# rubocop:disable Style/MixinUsage
|
6
|
+
include RSpec::Matchers
|
7
|
+
# rubocop:enable Style/MixinUsage
|
8
|
+
|
9
|
+
require "testable"
|
10
|
+
|
11
|
+
class Dynamic
|
12
|
+
include Testable
|
13
|
+
|
14
|
+
url_is "https://veilus.herokuapp.com/practice/dynamic_events"
|
15
|
+
|
16
|
+
button :long, id: 'long'
|
17
|
+
button :quick, id: 'quick'
|
18
|
+
button :stale, id: 'stale'
|
19
|
+
button :fade, id: 'fade'
|
20
|
+
|
21
|
+
div :dom_events, id: 'container1'
|
22
|
+
div :stale_event, id: 'container2'
|
23
|
+
div :effect_events, id: 'container3'
|
24
|
+
end
|
25
|
+
|
26
|
+
Testable.start_browser :firefox
|
27
|
+
|
28
|
+
page = Dynamic.new
|
29
|
+
|
30
|
+
page.visit
|
31
|
+
|
32
|
+
expect(page.dom_events.dom_updated?).to be_truthy
|
33
|
+
expect(page.dom_events.wait_until(&:dom_updated?).spans.count).to eq(0)
|
34
|
+
|
35
|
+
page.long.click
|
36
|
+
|
37
|
+
expect(page.dom_events.dom_updated?).to be_falsey
|
38
|
+
expect(page.dom_events.wait_until(&:dom_updated?).spans.count).to eq(4)
|
39
|
+
|
40
|
+
page.quick.click
|
41
|
+
|
42
|
+
expect(page.dom_events.wait_until(&:dom_updated?).spans.count).to eq(23)
|
43
|
+
|
44
|
+
Testable.quit_browser
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH << "./lib"
|
3
|
+
|
4
|
+
require "rspec"
|
5
|
+
# rubocop:disable Style/MixinUsage
|
6
|
+
include RSpec::Matchers
|
7
|
+
# rubocop:enable Style/MixinUsage
|
8
|
+
|
9
|
+
require "testable"
|
10
|
+
|
11
|
+
class PageReady
|
12
|
+
include Testable
|
13
|
+
|
14
|
+
url_is "https://veilus.herokuapp.com"
|
15
|
+
|
16
|
+
element :logo, id: 'site-'
|
17
|
+
element :login_form, id: 'openski'
|
18
|
+
|
19
|
+
page_ready { [logo.exists?, "Test Gorilla logo is not present"] }
|
20
|
+
end
|
21
|
+
|
22
|
+
Testable.start_browser :firefox
|
23
|
+
|
24
|
+
page = PageReady.new
|
25
|
+
|
26
|
+
page.visit
|
27
|
+
|
28
|
+
# Uncomment one of these at a time to see that the page_ready part
|
29
|
+
# is working. The element definitions above are purposely incorrect.
|
30
|
+
|
31
|
+
# page.when_ready { page.login_form.click }
|
32
|
+
# page.login_form.click
|
33
|
+
|
34
|
+
Testable.quit_browser
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
$LOAD_PATH << "./lib"
|
3
|
+
|
4
|
+
require "rspec"
|
5
|
+
# rubocop:disable Style/MixinUsage
|
6
|
+
include RSpec::Matchers
|
7
|
+
# rubocop:enable Style/MixinUsage
|
8
|
+
|
9
|
+
require "testable"
|
10
|
+
|
11
|
+
class Home
|
12
|
+
include Testable
|
13
|
+
|
14
|
+
url_is "https://veilus.herokuapp.com/"
|
15
|
+
url_matches(/heroku/)
|
16
|
+
title_is "Veilus"
|
17
|
+
|
18
|
+
# Elements can be defined with HTML-style names as found in Watir.
|
19
|
+
p :login_form, id: "open", visible: true
|
20
|
+
text_field :username, id: "username"
|
21
|
+
text_field :password
|
22
|
+
button :login, id: "login-button"
|
23
|
+
div :message, class: "notice"
|
24
|
+
|
25
|
+
# Elements can be defined with a generic name.
|
26
|
+
# element :login_form, id: "open", visible: true
|
27
|
+
# element :username, id: "username"
|
28
|
+
# element :password
|
29
|
+
# element :login, id: "login-button"
|
30
|
+
# element :message, class: "notice"
|
31
|
+
|
32
|
+
def begin_with
|
33
|
+
move_to(0, 0)
|
34
|
+
resize_to(screen_width, screen_height)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
class Navigation
|
39
|
+
include Testable
|
40
|
+
|
41
|
+
p :page_list, id: "navlist"
|
42
|
+
link :planets, id: "planets"
|
43
|
+
|
44
|
+
image :planet_logo, id: "planet-logo"
|
45
|
+
end
|
46
|
+
|
47
|
+
Testable.start_browser :firefox
|
48
|
+
|
49
|
+
page = Home.new
|
50
|
+
|
51
|
+
page.visit
|
52
|
+
|
53
|
+
page.login_form.click
|
54
|
+
page.username.set "admin"
|
55
|
+
page.password(id: 'password').set "admin"
|
56
|
+
page.login.click
|
57
|
+
expect(page.message.text).to eq('You are now logged in as admin.')
|
58
|
+
|
59
|
+
page = Navigation.new
|
60
|
+
|
61
|
+
page.page_list.click
|
62
|
+
# page.page_list.wait_until(&:dom_updated?).click
|
63
|
+
|
64
|
+
page.planets.click
|
65
|
+
expect(page.planet_logo.exists?).to be true
|
66
|
+
|
67
|
+
Testable.quit_browser
|