ripl-watir 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.rdoc +119 -0
- data/Rakefile +1 -0
- data/bin/ripl-watir +7 -0
- data/lib/ripl_watir/page.rb +10 -0
- data/lib/ripl_watir/version.rb +3 -0
- data/lib/ripl_watir.rb +44 -0
- data/ripl-watir.gemspec +28 -0
- metadata +98 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
== Description
|
2
|
+
|
3
|
+
Experimental ripl shell for incremental development of an automation
|
4
|
+
testing infrastructure for a web site. Manual testing of the site
|
5
|
+
may then be performed with bionic superpowers.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
gem install ripl_watir
|
10
|
+
|
11
|
+
== Demonstration
|
12
|
+
|
13
|
+
Hopefully this serves as some kind of demonstration:
|
14
|
+
|
15
|
+
cd /tmp
|
16
|
+
mkdir lib
|
17
|
+
ripl watir
|
18
|
+
|
19
|
+
... opens a browser session (firefox by default) and enters a
|
20
|
+
ripl console shell.
|
21
|
+
|
22
|
+
$: << 'lib'
|
23
|
+
|
24
|
+
... add the 'lib' directory to the load path
|
25
|
+
|
26
|
+
Now create a file 'lib/ripl_watir/github.rb' containing the following:
|
27
|
+
|
28
|
+
require 'watir-page-helper'
|
29
|
+
|
30
|
+
module RiplWatir::Github
|
31
|
+
extend WatirPageHelper::ClassMethods
|
32
|
+
|
33
|
+
direct_url 'github.com'
|
34
|
+
link :login, text: 'Login'
|
35
|
+
|
36
|
+
def logged_in?
|
37
|
+
browser.div(id: 'user').exists?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
... and now be amazed:
|
42
|
+
|
43
|
+
>> p = visit_page :github
|
44
|
+
|
45
|
+
... this creates an instance of the RiplWatir::Page class, requires 'ripl_watir/github' (from whereever it happens to be on the load
|
46
|
+
path), mixes RiplWatir::Github into the page class and calls the
|
47
|
+
goto method (which tells the browser to goto github.com).
|
48
|
+
|
49
|
+
>> p.login
|
50
|
+
|
51
|
+
... calls the login method on the page (which clicks the login button).
|
52
|
+
|
53
|
+
Now create a file 'lib/ripl_watir/github/login.rb' containing the following:
|
54
|
+
|
55
|
+
require 'watir-page-helper'
|
56
|
+
|
57
|
+
module RiplWatir::Github::Login
|
58
|
+
extend WatirPageHelper::ClassMethods
|
59
|
+
|
60
|
+
text_field :email, id: 'login_field'
|
61
|
+
text_field :password, id: 'password'
|
62
|
+
button :submit, value: 'Log in'
|
63
|
+
|
64
|
+
def login email, password
|
65
|
+
self.email = email
|
66
|
+
self.password = password
|
67
|
+
self.submit
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
... and be further amazed:
|
72
|
+
|
73
|
+
>> on_page(:github, :login) do |login_page|
|
74
|
+
| login_page.login 'me@my.mail.com', 'password'
|
75
|
+
| end
|
76
|
+
|
77
|
+
... creates another instance of the RiplWatir::Page class, requires
|
78
|
+
'ripl_watir/github/home' (from whereever it happens to be on the load
|
79
|
+
path), mixes RiplWatir::Github::Login into it and yields to the block.
|
80
|
+
|
81
|
+
The main purpose of all this is to be able to modify/define page mixins,
|
82
|
+
and reload them all without having to restart the console or create a
|
83
|
+
new browser session.
|
84
|
+
|
85
|
+
If for example, you added a new page mixin or a new method to an already instantiated one, you can simply reload the class and should find the new method is available.
|
86
|
+
|
87
|
+
>> load 'ripl_watir/github/login'
|
88
|
+
|
89
|
+
If the page mixin you've created has not been loaded already, this step
|
90
|
+
is not necessary since the page mixins are only required on first use.
|
91
|
+
|
92
|
+
If you just want to tell the browser to do something, it is directly
|
93
|
+
available as 'browser' without needing a page object.
|
94
|
+
|
95
|
+
>> browser.goto 'google.com'
|
96
|
+
|
97
|
+
== Page Objects
|
98
|
+
|
99
|
+
At this time, the page objects are always a RiplWatir::Page instance
|
100
|
+
(which is a delegate of Watir::Browser) with a specified mixin.
|
101
|
+
|
102
|
+
This mixin can add methods specifically for interacting with that page.
|
103
|
+
The watir-page-helper mixin may be used as in the github examples in this gem but is not mandatory. You can just define methods
|
104
|
+
against the @browser instance varaible or delegate to the page itself.
|
105
|
+
|
106
|
+
These page mixins will be loaded from anywhere on the load path.
|
107
|
+
|
108
|
+
== Cucumber
|
109
|
+
|
110
|
+
To use page mixins defined in this way with cucumber, define your
|
111
|
+
page objects in a 'lib' (make sure this directory is on the load path)
|
112
|
+
and mix the commands into the cucumber 'world' in env.rb:
|
113
|
+
|
114
|
+
require 'ripl_watir/'
|
115
|
+
World RiplWatir::Commands
|
116
|
+
|
117
|
+
As long as your page mixins are in a 'ripl_watir' directory on the path
|
118
|
+
and are constants defined (at any depth) under the RiplWatir module, they
|
119
|
+
should be located.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/ripl-watir
ADDED
data/lib/ripl_watir.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'watir-webdriver'
|
2
|
+
require 'ripl_watir/page'
|
3
|
+
|
4
|
+
module RiplWatir
|
5
|
+
class << self
|
6
|
+
attr_accessor :browser
|
7
|
+
end
|
8
|
+
|
9
|
+
module Array
|
10
|
+
def classify
|
11
|
+
self.map(&:classify).join('::')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Commands
|
16
|
+
def classify s
|
17
|
+
s.to_s.split('_').map(&:capitalize).join
|
18
|
+
end
|
19
|
+
|
20
|
+
def page_class *args
|
21
|
+
page = Page.new RiplWatir.browser
|
22
|
+
require "ripl_watir/#{args.join '/'}"
|
23
|
+
mod = RiplWatir
|
24
|
+
args.each do |name|
|
25
|
+
mod = mod.const_get classify name
|
26
|
+
end
|
27
|
+
page.extend mod
|
28
|
+
page
|
29
|
+
end
|
30
|
+
|
31
|
+
def on_page *args
|
32
|
+
page_class(*args).tap do |p|
|
33
|
+
yield p if block_given?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def visit_page *args
|
38
|
+
on_page(*args) do |p|
|
39
|
+
p.goto
|
40
|
+
yield p if block_given?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/ripl-watir.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "ripl_watir/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "ripl-watir"
|
7
|
+
s.version = RiplWatir::VERSION
|
8
|
+
s.authors = ["Mark Ryall"]
|
9
|
+
s.email = ["mark@ryall.name"]
|
10
|
+
s.homepage = "https://github.com/markryall/ripl_watir"
|
11
|
+
s.summary = %q{watir repl for efficiently creating page objects}
|
12
|
+
s.description = <<EOF
|
13
|
+
A ripl plugin to provide an interactive shell for creating page objects
|
14
|
+
to build an automated testing infrastructure for a site.
|
15
|
+
EOF
|
16
|
+
|
17
|
+
s.rubyforge_project = "ripl-watir"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
|
24
|
+
s.add_runtime_dependency "ripl"
|
25
|
+
s.add_runtime_dependency "watir-page-helper"
|
26
|
+
|
27
|
+
s.add_development_dependency "rspec"
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ripl-watir
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Mark Ryall
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: ripl
|
16
|
+
requirement: &70117511154860 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70117511154860
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: watir-page-helper
|
27
|
+
requirement: &70117511154400 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70117511154400
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70117511153920 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70117511153920
|
47
|
+
description: ! 'A ripl plugin to provide an interactive shell for creating page objects
|
48
|
+
|
49
|
+
to build an automated testing infrastructure for a site.
|
50
|
+
|
51
|
+
'
|
52
|
+
email:
|
53
|
+
- mark@ryall.name
|
54
|
+
executables:
|
55
|
+
- ripl-watir
|
56
|
+
extensions: []
|
57
|
+
extra_rdoc_files: []
|
58
|
+
files:
|
59
|
+
- .gitignore
|
60
|
+
- Gemfile
|
61
|
+
- README.rdoc
|
62
|
+
- Rakefile
|
63
|
+
- bin/ripl-watir
|
64
|
+
- lib/ripl_watir.rb
|
65
|
+
- lib/ripl_watir/page.rb
|
66
|
+
- lib/ripl_watir/version.rb
|
67
|
+
- ripl-watir.gemspec
|
68
|
+
homepage: https://github.com/markryall/ripl_watir
|
69
|
+
licenses: []
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ! '>='
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
hash: 749351036081304174
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
hash: 749351036081304174
|
92
|
+
requirements: []
|
93
|
+
rubyforge_project: ripl-watir
|
94
|
+
rubygems_version: 1.8.11
|
95
|
+
signing_key:
|
96
|
+
specification_version: 3
|
97
|
+
summary: watir repl for efficiently creating page objects
|
98
|
+
test_files: []
|