watir-rails 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.yardopts +6 -0
- data/LICENSE +2 -2
- data/README.md +46 -42
- data/Rakefile +2 -0
- data/lib/watir/browser.rb +16 -1
- data/lib/watir/rails.rb +12 -0
- data/lib/watir/version.rb +1 -1
- data/watir-rails.gemspec +3 -0
- metadata +35 -2
data/.yardopts
ADDED
data/LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2012 Jarmo Pertman
|
1
|
+
Copyright (c) 2012-2013 Jarmo Pertman
|
2
2
|
|
3
3
|
MIT License
|
4
4
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,42 +1,46 @@
|
|
1
|
-
# Watir::Rails
|
2
|
-
|
3
|
-
This gem adds the [Watir](http://github.com/watir/watir) usage support when writing integration tests in Rails.
|
4
|
-
|
5
|
-
## Installation
|
6
|
-
|
7
|
-
Add this code to your Gemfile:
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
##
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
1
|
+
# Watir::Rails
|
2
|
+
|
3
|
+
This gem adds the [Watir](http://github.com/watir/watir) usage support when writing integration tests in Rails.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this code to your Gemfile:
|
8
|
+
|
9
|
+
````ruby
|
10
|
+
group :test do
|
11
|
+
gem 'watir-rails'
|
12
|
+
end
|
13
|
+
````
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
Just use Watir like you've always done in your requests/integration tests:
|
18
|
+
|
19
|
+
````ruby
|
20
|
+
browser = Watir::Browser.new
|
21
|
+
browser.goto home_path
|
22
|
+
browser.text_field(name: "first").set "Jarmo"
|
23
|
+
browser.text_field(name: "last").set "Pertman"
|
24
|
+
browser.button(name: "sign_in").click
|
25
|
+
````
|
26
|
+
|
27
|
+
## Limitations
|
28
|
+
|
29
|
+
* Watir-Rails works currently only with the [Watir-WebDriver](http://github.com/watir/watir-webdriver) and not with
|
30
|
+
the [Watir-Classic](http://github.com/watir/watir-classic) due to the problems of running a server
|
31
|
+
in the separate thread when WIN32OLE is used.
|
32
|
+
The problem is probably caused by the fact that [WIN32OLE overwrites Thread#initialize](https://github.com/ruby/ruby/blob/trunk/test/ruby/test_thread.rb#L607).
|
33
|
+
|
34
|
+
* When using Rails path/url helpers in your tests then always use path instead of url methods, because latter won't work!
|
35
|
+
|
36
|
+
## License
|
37
|
+
|
38
|
+
See [LICENSE](https://github.com/watir/watir-rails/blob/master/LICENSE).
|
39
|
+
|
40
|
+
## Contributing
|
41
|
+
|
42
|
+
1. Fork it
|
43
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
44
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
45
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
46
|
+
5. Create new Pull Request
|
data/Rakefile
CHANGED
data/lib/watir/browser.rb
CHANGED
@@ -1,16 +1,31 @@
|
|
1
1
|
module Watir
|
2
|
+
# Reopened Watir::Browser class for working with Rails
|
2
3
|
class Browser
|
4
|
+
# @private
|
3
5
|
alias_method :original_initialize, :initialize
|
4
6
|
|
7
|
+
# Will start Rails instance for Watir automatically and then invoke the
|
8
|
+
# original Watir::Browser#initialize method.
|
5
9
|
def initialize(*args)
|
6
10
|
Rails.boot
|
7
11
|
original_initialize *args
|
8
12
|
end
|
9
13
|
|
14
|
+
# @private
|
10
15
|
alias_method :original_goto, :goto
|
11
16
|
|
17
|
+
# Opens the url with the browser instance.
|
18
|
+
# Will add {Rails.host} and {Rails.port} to the url when path is specified.
|
19
|
+
#
|
20
|
+
# @example Open the regular url:
|
21
|
+
# browser.goto "http://google.com"
|
22
|
+
#
|
23
|
+
# @example Open the controller path:
|
24
|
+
# browser.goto home_path
|
25
|
+
#
|
26
|
+
# @param [String] url URL to be navigated to.
|
12
27
|
def goto(url)
|
13
|
-
url = "http://#{Rails.host}:#{Rails.port}#{url}" unless url =~ %r{^
|
28
|
+
url = "http://#{Rails.host}:#{Rails.port}#{url}" unless url =~ %r{^https?://}i || url == "about:blank"
|
14
29
|
original_goto url
|
15
30
|
end
|
16
31
|
end
|
data/lib/watir/rails.rb
CHANGED
@@ -6,6 +6,7 @@ require File.expand_path("browser.rb", File.dirname(__FILE__))
|
|
6
6
|
|
7
7
|
module Watir
|
8
8
|
class Rails
|
9
|
+
# @private
|
9
10
|
class Middleware
|
10
11
|
def initialize(app)
|
11
12
|
@app = app
|
@@ -24,6 +25,8 @@ module Watir
|
|
24
25
|
private :new
|
25
26
|
attr_reader :port, :middleware
|
26
27
|
|
28
|
+
# Start the Rails server for tests.
|
29
|
+
# Will be called automatically by {Watir::Browser#initialize}.
|
27
30
|
def boot
|
28
31
|
unless running?
|
29
32
|
@middleware = Middleware.new(app)
|
@@ -39,10 +42,16 @@ module Watir
|
|
39
42
|
raise "Rack application timed out during boot"
|
40
43
|
end
|
41
44
|
|
45
|
+
# Host for Rails app under test.
|
46
|
+
#
|
47
|
+
# @return [String] Host for Rails app for testing.
|
42
48
|
def host
|
43
49
|
"127.0.0.1"
|
44
50
|
end
|
45
51
|
|
52
|
+
# Check if Rails app under test is running.
|
53
|
+
#
|
54
|
+
# @return [Boolean] true when Rails app under test is running, false otherwise.
|
46
55
|
def running?
|
47
56
|
return false if @server_thread && @server_thread.join(0)
|
48
57
|
|
@@ -55,6 +64,9 @@ module Watir
|
|
55
64
|
return false
|
56
65
|
end
|
57
66
|
|
67
|
+
# Rails app under test.
|
68
|
+
#
|
69
|
+
# @return [Object] Rails Rack app.
|
58
70
|
def app
|
59
71
|
@app ||= Rack::Builder.new do
|
60
72
|
map "/" do
|
data/lib/watir/version.rb
CHANGED
data/watir-rails.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -59,6 +59,38 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: yard
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: redcarpet
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
62
94
|
description: Add support for Watir (http://github.com/watir/watir) in Rails.
|
63
95
|
email:
|
64
96
|
- jarmo.p@gmail.com
|
@@ -67,6 +99,7 @@ extensions: []
|
|
67
99
|
extra_rdoc_files: []
|
68
100
|
files:
|
69
101
|
- .gitignore
|
102
|
+
- .yardopts
|
70
103
|
- Gemfile
|
71
104
|
- LICENSE
|
72
105
|
- README.md
|