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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 9fe925fea55efebca8a07a490fb639669355cecf
4
- data.tar.gz: 750388f14ff7df442cba5c4abb60ea51125a70c6
2
+ SHA256:
3
+ metadata.gz: f0b41932f26b804cd3a7216914b135ed21c72e716734b485452d8ba89fade529
4
+ data.tar.gz: f0b824f615eebe4edd4520f1c1705ee50dc76a6efd2ba7c5281931e42910b162
5
5
  SHA512:
6
- metadata.gz: 4ae956962245d4326c31028c59b96fb060d1e46765d8db56309eadfe8460bb308a79876bfcafaa57fdfde38ad9e2a9c676c83c10ce9f7eef8df231a3938d0c57
7
- data.tar.gz: 2b986d69188ff6df56efe57e3dbb5724d83ed21bc6aefc0acb19198ad2e3f8b8da21dbf1c9aa31b7cdbbce156757528bed75d1f116c635c9f66b0cc736c19598
6
+ metadata.gz: fa8a4ac245684d7b7ac89104534eb2aa285779c2ed1b064c04fe2a248d73f56cf16b7fc9fab5c593cd37f3e270759aa4e13227418c04e1a4d926eb68a921aa6d
7
+ data.tar.gz: ec136ec9fb01d955d3e40f2984a10764d03a5e7eb2a9c32a804a40f1db3cf17af856ad778ecd3b48f8b7f6e8d3ae7652accffe77b73eaac5b40c37d738da3190
data/.gitignore CHANGED
@@ -1,41 +1,49 @@
1
- # Ruby-Specific
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/examples.txt
11
+ /spec/coverage/
15
12
  /tmp/
16
- *.log
17
- *.tmp
18
- *.swp
19
- *.bak
20
13
 
21
- # IDE-Specific
14
+ # Generated Reports
15
+ reports/
22
16
 
23
- .idea
24
- .settings
25
- .project
26
- .classpath
27
- *.iws
17
+ # Rspec Failure Tracking
28
18
 
29
- # Windows-Specific
19
+ .rspec_status
30
20
 
31
- Thumbs.db
21
+ # IDE Files
32
22
 
33
- # Mac OS-Specific
34
-
35
- *.DS_Store
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
- # Linux-Specific
35
+ # OS Files
39
36
 
40
- .directory
41
- .Trash-*
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
- Style/AlignHash:
32
+ Layout/AlignHash:
34
33
  EnforcedLastArgumentHashStyle: ignore_implicit
35
34
 
36
35
  # Align multi-line params with previous line.
37
- Style/AlignParameters:
36
+ Layout/AlignParameters:
38
37
  EnforcedStyle: with_fixed_indentation
39
38
 
40
39
  # Indent `when` clause one step from `case`.
41
- Style/CaseIndentation:
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
- Style/DotPosition:
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: 10
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
@@ -1,2 +1,6 @@
1
+ inherit_mode:
2
+ merge:
3
+ - Exclude
4
+
1
5
  inherit_from:
2
6
  - .hound.yml
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.3.4
7
+ before_install: gem install bundler -v 2.0.2
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 jeffnyman@gmail.com. All
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
@@ -1,4 +1,6 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
+
3
+ gem "coveralls", require: false
2
4
 
3
5
  # Specify your gem's dependencies in testable.gemspec
4
6
  gemspec
@@ -1,6 +1,6 @@
1
- The MIT License (MIT)
1
+ **The MIT License (MIT)**
2
2
 
3
- Copyright (c) 2016 Jeff Nyman
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
- [![Build Status](https://circleci.com/gh/jeffnyman/testable.svg?style=shield)](https://circleci.com/gh/jeffnyman/testable)
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
- [![Dependency Status](https://gemnasium.com/jeffnyman/testable.png)](https://gemnasium.com/jeffnyman/testable)
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
- The Testable gem aims to be a micro-framework that will provide a semantic DSL to construct a fluent interface for test execution libraries.
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
- 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.
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
- Probably the best way to get a feel for the current state of the code is to look at the test scripts:
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 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.
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
- This gem follows [semantic versioning](http://semver.org).
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.txt) file for details.
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 :script do
12
- desc "Run the Testable standard script"
13
- task :standard do
14
- system("ruby ./test/testable-standard.rb")
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 factory script"
18
- task :factory do
19
- system("ruby ./test/testable-factory.rb")
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(--color)
31
- options += %w(--format documentation)
32
- options += %w(--format html --out spec/reports/unit-test-report.html)
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
@@ -9,5 +9,5 @@ require "testable"
9
9
  require "pry"
10
10
  Pry.start
11
11
 
12
- # require "irb"
13
- # IRB.start
12
+ require "irb"
13
+ IRB.start(__FILE__)
@@ -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