watir-webdriver-rails 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -2
- data/Gemfile +1 -0
- data/README.md +108 -98
- data/lib/watir-webdriver-rails/browser.rb +33 -28
- data/lib/watir-webdriver-rails/driver.rb +47 -47
- data/lib/watir-webdriver-rails/rails.rb +74 -74
- data/lib/watir-webdriver-rails/rspec.rb +8 -8
- data/lib/watir-webdriver-rails/util/timeout.rb +23 -23
- data/lib/watir-webdriver-rails/version.rb +1 -1
- data/lib/watir-webdriver-rails.rb +42 -37
- data/spec/controllers/home_controller_spec.rb +7 -7
- data/spec/integration/rails_spec.rb +8 -8
- data/spec/rails/Gemfile +2 -2
- data/spec/rails/app/controllers/home_controller.rb +4 -4
- data/spec/rails/app/views/home/index.html.erb +1 -1
- data/spec/rails/app/views/layouts/main.html.erb +9 -9
- data/spec/rails/config/application.rb +23 -23
- data/spec/rails/config/boot.rb +6 -6
- data/spec/rails/config/environment.rb +10 -10
- data/spec/rails/config/routes.rb +4 -4
- data/spec/rails/config.ru +4 -4
- data/spec/rails/script/rails +6 -6
- data/spec/spec_helper.rb +24 -23
- data/watir-webdriver-rails.gemspec +23 -23
- metadata +21 -5
data/.gitignore
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
/.loadpath
|
1
|
+
|
2
|
+
/.loadpath
|
3
3
|
/.project
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,98 +1,108 @@
|
|
1
|
-
watir-webdriver-rails
|
2
|
-
===============
|
3
|
-
|
4
|
-
watir-webdriver-rails provides a dead-simple way to use Watir with Rails 3.
|
5
|
-
|
6
|
-
Current version
|
7
|
-
----------------
|
8
|
-
``
|
9
|
-
0.0.
|
10
|
-
``
|
11
|
-
|
12
|
-
Installation
|
13
|
-
--------
|
14
|
-
|
15
|
-
In your Gemfile, drop the below line
|
16
|
-
|
17
|
-
``
|
18
|
-
gem 'watir-webdriver-rails'
|
19
|
-
``
|
20
|
-
|
21
|
-
and type:
|
22
|
-
|
23
|
-
``
|
24
|
-
bundle install
|
25
|
-
``
|
26
|
-
|
27
|
-
from your command line and Rails's root folder
|
28
|
-
|
29
|
-
How to use
|
30
|
-
-------
|
31
|
-
|
32
|
-
In your spec_helper.rb, please place the below lines:
|
33
|
-
(watir-webdriver-rails uses RSpec as the testing framework)
|
34
|
-
|
35
|
-
```ruby
|
36
|
-
|
37
|
-
require 'rspec/rails'
|
38
|
-
require 'watir-webdriver-rails'
|
39
|
-
|
40
|
-
WatirWebdriverRails.host = "localhost"
|
41
|
-
WatirWebdriverRails.port = 57124
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
browser.text_field(:id=>"
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
*
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
1
|
+
watir-webdriver-rails
|
2
|
+
===============
|
3
|
+
|
4
|
+
watir-webdriver-rails provides a dead-simple way to use Watir with Rails 3.
|
5
|
+
|
6
|
+
Current version
|
7
|
+
----------------
|
8
|
+
``
|
9
|
+
0.0.7
|
10
|
+
``
|
11
|
+
|
12
|
+
Installation
|
13
|
+
--------
|
14
|
+
|
15
|
+
In your Gemfile, drop the below line
|
16
|
+
|
17
|
+
``
|
18
|
+
gem 'watir-webdriver-rails'
|
19
|
+
``
|
20
|
+
|
21
|
+
and type:
|
22
|
+
|
23
|
+
``
|
24
|
+
bundle install
|
25
|
+
``
|
26
|
+
|
27
|
+
from your command line and Rails's root folder
|
28
|
+
|
29
|
+
How to use
|
30
|
+
-------
|
31
|
+
|
32
|
+
In your spec_helper.rb, please place the below lines:
|
33
|
+
(watir-webdriver-rails uses RSpec as the testing framework)
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
|
37
|
+
require 'rspec/rails'
|
38
|
+
require 'watir-webdriver-rails'
|
39
|
+
|
40
|
+
WatirWebdriverRails.host = "localhost"
|
41
|
+
WatirWebdriverRails.port = 57124
|
42
|
+
WatirWebdriverRails.close_browser_after_finish = true
|
43
|
+
|
44
|
+
```
|
45
|
+
|
46
|
+
In your integration test file, it should look something like this:
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
|
50
|
+
require 'spec_helper'
|
51
|
+
|
52
|
+
describe "Test something" do
|
53
|
+
|
54
|
+
it "should go to some page and fill textbox" do
|
55
|
+
|
56
|
+
browser.goto "/member"
|
57
|
+
|
58
|
+
browser.text_field(:id=>"first_name").set "Tanin"
|
59
|
+
browser.text_field(:id=>"last_name").set "Na Nakorn"
|
60
|
+
|
61
|
+
browser.text_field(:id=>"first_name").value.should == "Tanin"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
```
|
66
|
+
|
67
|
+
browser is of type Watir::Browser. You may interact with it freely.
|
68
|
+
See http://rubydoc.info/gems/watir-webdriver/0.3.2/Watir/Browser
|
69
|
+
|
70
|
+
Issues
|
71
|
+
----------
|
72
|
+
|
73
|
+
On Mac OS X 10.6.8, I have found that if you do not close the browser from the previous test,
|
74
|
+
your current test will hang because the browser is not initilized.
|
75
|
+
|
76
|
+
Please do close the browser before running a new test.
|
77
|
+
|
78
|
+
Dependencies
|
79
|
+
------------
|
80
|
+
|
81
|
+
* watir-webdriver
|
82
|
+
* rspec
|
83
|
+
|
84
|
+
Development
|
85
|
+
-----------------------------
|
86
|
+
|
87
|
+
* Fork the project.
|
88
|
+
* Add features or fix bugs
|
89
|
+
* Add test cases for it
|
90
|
+
* Send me a pull request
|
91
|
+
|
92
|
+
Please try running all the test cases first by going to the root folder and type:
|
93
|
+
|
94
|
+
``
|
95
|
+
bundle exec rspec spec/*
|
96
|
+
``
|
97
|
+
|
98
|
+
|
99
|
+
License
|
100
|
+
---------
|
101
|
+
|
102
|
+
There are parts which are copied from capybara and capybara-firebug gems. Please also be aware of their licenses.
|
103
|
+
Other than that, you can do anything with it.
|
104
|
+
|
105
|
+
Author
|
106
|
+
---------
|
107
|
+
Tanin Na Nakorn
|
108
|
+
homanchou (The first contributor)
|
@@ -1,28 +1,33 @@
|
|
1
|
-
module WatirWebdriverRails
|
2
|
-
class << self
|
3
|
-
attr_accessor :browser,:browser_initialized
|
4
|
-
|
5
|
-
def initialize_browser
|
6
|
-
|
7
|
-
return if @browser_initialized == true
|
8
|
-
|
9
|
-
@browser = Watir::Browser.new(WatirWebdriverRails.driver)
|
10
|
-
|
11
|
-
@browser.class_eval do
|
12
|
-
alias_method :old_goto,:goto
|
13
|
-
|
14
|
-
def goto(*args)
|
15
|
-
|
16
|
-
if !args[0].match(/^https?:/)
|
17
|
-
args[0] = "http://#{WatirWebdriverRails.host}:#{WatirWebdriverRails.port}#{args[0]}"
|
18
|
-
end
|
19
|
-
|
20
|
-
old_goto(*args)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
@browser_initialized = true
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
|
1
|
+
module WatirWebdriverRails
|
2
|
+
class << self
|
3
|
+
attr_accessor :browser,:browser_initialized
|
4
|
+
|
5
|
+
def initialize_browser
|
6
|
+
|
7
|
+
return if @browser_initialized == true
|
8
|
+
|
9
|
+
@browser = Watir::Browser.new(WatirWebdriverRails.driver)
|
10
|
+
|
11
|
+
@browser.class_eval do
|
12
|
+
alias_method :old_goto,:goto
|
13
|
+
|
14
|
+
def goto(*args)
|
15
|
+
|
16
|
+
if !args[0].match(/^https?:/)
|
17
|
+
args[0] = "http://#{WatirWebdriverRails.host}:#{WatirWebdriverRails.port}#{args[0]}"
|
18
|
+
end
|
19
|
+
|
20
|
+
old_goto(*args)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
@browser_initialized = true
|
25
|
+
end
|
26
|
+
|
27
|
+
def close_browser
|
28
|
+
@browser.close if @browser_initialized == true
|
29
|
+
@browser_initialized = false
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -1,47 +1,47 @@
|
|
1
|
-
require 'watir-webdriver'
|
2
|
-
|
3
|
-
module WatirWebdriverRails
|
4
|
-
|
5
|
-
# Copied from capybara-firebug
|
6
|
-
class Selenium::WebDriver::Firefox::Profile
|
7
|
-
def self.firebug_version
|
8
|
-
@firebug_version ||= '1.7.3'
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.firebug_version=(version)
|
12
|
-
@firebug_version = version
|
13
|
-
end
|
14
|
-
|
15
|
-
def enable_firebug(version = nil)
|
16
|
-
version ||= Selenium::WebDriver::Firefox::Profile.firebug_version
|
17
|
-
add_extension(File.expand_path("../firebug/firebug-1.7.3.xpi", __FILE__))
|
18
|
-
add_extension(File.expand_path("../firebug/firebug-1.8.1.xpi", __FILE__))
|
19
|
-
|
20
|
-
# Prevent "Welcome!" tab
|
21
|
-
self["extensions.firebug.currentVersion"] = "999"
|
22
|
-
|
23
|
-
# Enable for all sites.
|
24
|
-
self["extensions.firebug.allPagesActivation"] = "on"
|
25
|
-
|
26
|
-
# Enable all features.
|
27
|
-
['console', 'net', 'script'].each do |feature|
|
28
|
-
self["extensions.firebug.#{feature}.enableSites"] = true
|
29
|
-
end
|
30
|
-
|
31
|
-
# Closed by default.
|
32
|
-
self["extensions.firebug.previousPlacement"] = 3
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
class << self
|
37
|
-
def driver
|
38
|
-
profile = Selenium::WebDriver::Firefox::Profile.new
|
39
|
-
profile.enable_firebug
|
40
|
-
driver = Selenium::WebDriver.for(:firefox, { :profile => profile })
|
41
|
-
|
42
|
-
return driver
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
end
|
1
|
+
require 'watir-webdriver'
|
2
|
+
|
3
|
+
module WatirWebdriverRails
|
4
|
+
|
5
|
+
# Copied from capybara-firebug
|
6
|
+
class Selenium::WebDriver::Firefox::Profile
|
7
|
+
def self.firebug_version
|
8
|
+
@firebug_version ||= '1.7.3'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.firebug_version=(version)
|
12
|
+
@firebug_version = version
|
13
|
+
end
|
14
|
+
|
15
|
+
def enable_firebug(version = nil)
|
16
|
+
version ||= Selenium::WebDriver::Firefox::Profile.firebug_version
|
17
|
+
#add_extension(File.expand_path("../firebug/firebug-1.7.3.xpi", __FILE__))
|
18
|
+
add_extension(File.expand_path("../firebug/firebug-1.8.1.xpi", __FILE__))
|
19
|
+
|
20
|
+
# Prevent "Welcome!" tab
|
21
|
+
self["extensions.firebug.currentVersion"] = "999"
|
22
|
+
|
23
|
+
# Enable for all sites.
|
24
|
+
self["extensions.firebug.allPagesActivation"] = "on"
|
25
|
+
|
26
|
+
# Enable all features.
|
27
|
+
['console', 'net', 'script'].each do |feature|
|
28
|
+
self["extensions.firebug.#{feature}.enableSites"] = true
|
29
|
+
end
|
30
|
+
|
31
|
+
# Closed by default.
|
32
|
+
self["extensions.firebug.previousPlacement"] = 3
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class << self
|
37
|
+
def driver
|
38
|
+
profile = Selenium::WebDriver::Firefox::Profile.new
|
39
|
+
profile.enable_firebug
|
40
|
+
driver = Selenium::WebDriver.for(:firefox, { :profile => profile })
|
41
|
+
|
42
|
+
return driver
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
end
|
@@ -1,75 +1,75 @@
|
|
1
|
-
require 'rspec/core'
|
2
|
-
require 'uri'
|
3
|
-
require 'net/http'
|
4
|
-
|
5
|
-
module WatirWebdriverRails
|
6
|
-
|
7
|
-
class Identify
|
8
|
-
def initialize(app)
|
9
|
-
@app = app
|
10
|
-
end
|
11
|
-
|
12
|
-
def call(env)
|
13
|
-
if env["PATH_INFO"] == "/__identify__"
|
14
|
-
[200, {}, [@app.object_id.to_s]]
|
15
|
-
else
|
16
|
-
@app.call(env)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class << self
|
22
|
-
attr_accessor :host, :port, :server_boot_timeout, :app, :server_running
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
def run_server
|
27
|
-
return if @server_running == true
|
28
|
-
|
29
|
-
@app = Rack::Builder.new {
|
30
|
-
map "/" do
|
31
|
-
if Rails.version.to_f >= 3.0
|
32
|
-
run Rails.application
|
33
|
-
else # Rails 2
|
34
|
-
use Rails::Rack::Static
|
35
|
-
run ActionController::Dispatcher.new
|
36
|
-
end
|
37
|
-
end
|
38
|
-
}.to_app
|
39
|
-
|
40
|
-
Thread.new do
|
41
|
-
begin
|
42
|
-
require 'rack/handler/thin'
|
43
|
-
Thin::Logging.silent = true
|
44
|
-
Rack::Handler::Thin.run(Identify.new(app), :Port => @port)
|
45
|
-
rescue LoadError
|
46
|
-
require 'rack/handler/webrick'
|
47
|
-
Rack::Handler::WEBrick.run(Identify.new(app), :Port => @port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
timeout(@server_boot_timeout) do
|
52
|
-
if responsive?
|
53
|
-
true
|
54
|
-
else
|
55
|
-
sleep(0.5)
|
56
|
-
false
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
@server_running = true
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
def responsive?
|
65
|
-
res = Net::HTTP.start("127.0.0.1", @port) { |http| http.get('/__identify__') }
|
66
|
-
|
67
|
-
if res.is_a?(Net::HTTPSuccess) or res.is_a?(Net::HTTPRedirection)
|
68
|
-
return res.body == @app.object_id.to_s
|
69
|
-
end
|
70
|
-
rescue Errno::ECONNREFUSED, Errno::EBADF
|
71
|
-
return false
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
1
|
+
require 'rspec/core'
|
2
|
+
require 'uri'
|
3
|
+
require 'net/http'
|
4
|
+
|
5
|
+
module WatirWebdriverRails
|
6
|
+
|
7
|
+
class Identify
|
8
|
+
def initialize(app)
|
9
|
+
@app = app
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(env)
|
13
|
+
if env["PATH_INFO"] == "/__identify__"
|
14
|
+
[200, {}, [@app.object_id.to_s]]
|
15
|
+
else
|
16
|
+
@app.call(env)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
attr_accessor :host, :port, :server_boot_timeout, :app, :server_running, :close_browser_after_finish
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
def run_server
|
27
|
+
return if @server_running == true
|
28
|
+
|
29
|
+
@app = Rack::Builder.new {
|
30
|
+
map "/" do
|
31
|
+
if Rails.version.to_f >= 3.0
|
32
|
+
run Rails.application
|
33
|
+
else # Rails 2
|
34
|
+
use Rails::Rack::Static
|
35
|
+
run ActionController::Dispatcher.new
|
36
|
+
end
|
37
|
+
end
|
38
|
+
}.to_app
|
39
|
+
|
40
|
+
Thread.new do
|
41
|
+
begin
|
42
|
+
require 'rack/handler/thin'
|
43
|
+
Thin::Logging.silent = true
|
44
|
+
Rack::Handler::Thin.run(Identify.new(app), :Port => @port)
|
45
|
+
rescue LoadError
|
46
|
+
require 'rack/handler/webrick'
|
47
|
+
Rack::Handler::WEBrick.run(Identify.new(app), :Port => @port, :AccessLog => [], :Logger => WEBrick::Log::new(nil, 0))
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
timeout(@server_boot_timeout) do
|
52
|
+
if responsive?
|
53
|
+
true
|
54
|
+
else
|
55
|
+
sleep(0.5)
|
56
|
+
false
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
@server_running = true
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
def responsive?
|
65
|
+
res = Net::HTTP.start("127.0.0.1", @port) { |http| http.get('/__identify__') }
|
66
|
+
|
67
|
+
if res.is_a?(Net::HTTPSuccess) or res.is_a?(Net::HTTPRedirection)
|
68
|
+
return res.body == @app.object_id.to_s
|
69
|
+
end
|
70
|
+
rescue Errno::ECONNREFUSED, Errno::EBADF
|
71
|
+
return false
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
75
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
module WatirWebdriverRails
|
2
|
-
module RSpec
|
3
|
-
|
4
|
-
def browser
|
5
|
-
return WatirWebdriverRails.browser
|
6
|
-
end
|
7
|
-
|
8
|
-
end
|
1
|
+
module WatirWebdriverRails
|
2
|
+
module RSpec
|
3
|
+
|
4
|
+
def browser
|
5
|
+
return WatirWebdriverRails.browser
|
6
|
+
end
|
7
|
+
|
8
|
+
end
|
9
9
|
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
module WatirWebdriverRails
|
2
|
-
class << self
|
3
|
-
|
4
|
-
# Copied from Capybara
|
5
|
-
def timeout(seconds = 1, driver = nil, error_message = nil, &block)
|
6
|
-
start_time = Time.now
|
7
|
-
|
8
|
-
result = nil
|
9
|
-
|
10
|
-
until result
|
11
|
-
return result if result = yield
|
12
|
-
|
13
|
-
delay = seconds - (Time.now - start_time)
|
14
|
-
if delay <= 0
|
15
|
-
raise TimeoutError, error_message || "timed out"
|
16
|
-
end
|
17
|
-
|
18
|
-
driver && driver.wait_until(delay)
|
19
|
-
|
20
|
-
sleep(0.05)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
1
|
+
module WatirWebdriverRails
|
2
|
+
class << self
|
3
|
+
|
4
|
+
# Copied from Capybara
|
5
|
+
def timeout(seconds = 1, driver = nil, error_message = nil, &block)
|
6
|
+
start_time = Time.now
|
7
|
+
|
8
|
+
result = nil
|
9
|
+
|
10
|
+
until result
|
11
|
+
return result if result = yield
|
12
|
+
|
13
|
+
delay = seconds - (Time.now - start_time)
|
14
|
+
if delay <= 0
|
15
|
+
raise TimeoutError, error_message || "timed out"
|
16
|
+
end
|
17
|
+
|
18
|
+
driver && driver.wait_until(delay)
|
19
|
+
|
20
|
+
sleep(0.05)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
24
|
end
|
@@ -1,37 +1,42 @@
|
|
1
|
-
require 'watir-webdriver'
|
2
|
-
|
3
|
-
module WatirWebdriverRails
|
4
|
-
class WatirWebdriverRailsError < StandardError; end
|
5
|
-
class TimeoutError < WatirWebdriverRailsError; end
|
6
|
-
|
7
|
-
end
|
8
|
-
|
9
|
-
require 'watir-webdriver-rails/rails'
|
10
|
-
require 'watir-webdriver-rails/driver'
|
11
|
-
require 'watir-webdriver-rails/browser'
|
12
|
-
require 'watir-webdriver-rails/rspec'
|
13
|
-
|
14
|
-
# start server
|
15
|
-
RSpec.configure do |config|
|
16
|
-
|
17
|
-
config.include WatirWebdriverRails::RSpec, :example_group=>{:file_path=>/spec[\\\/](requests|integration)/}
|
18
|
-
|
19
|
-
config.after(:each) do
|
20
|
-
if self.class.include?(WatirWebdriverRails::RSpec)
|
21
|
-
browser.clear_cookies
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
#
|
37
|
-
|
1
|
+
require 'watir-webdriver'
|
2
|
+
|
3
|
+
module WatirWebdriverRails
|
4
|
+
class WatirWebdriverRailsError < StandardError; end
|
5
|
+
class TimeoutError < WatirWebdriverRailsError; end
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
require 'watir-webdriver-rails/rails'
|
10
|
+
require 'watir-webdriver-rails/driver'
|
11
|
+
require 'watir-webdriver-rails/browser'
|
12
|
+
require 'watir-webdriver-rails/rspec'
|
13
|
+
|
14
|
+
# start server
|
15
|
+
RSpec.configure do |config|
|
16
|
+
|
17
|
+
config.include WatirWebdriverRails::RSpec, :example_group=>{:file_path=>/spec[\\\/](requests|integration)/}
|
18
|
+
|
19
|
+
config.after(:each) do
|
20
|
+
if self.class.include?(WatirWebdriverRails::RSpec)
|
21
|
+
browser.clear_cookies
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
config.after(:suite) do
|
26
|
+
WatirWebdriverRails.close_browser if WatirWebdriverRails.close_browser_after_finish == true
|
27
|
+
end
|
28
|
+
|
29
|
+
config.before do
|
30
|
+
if self.class.include?(WatirWebdriverRails::RSpec)
|
31
|
+
WatirWebdriverRails.run_server
|
32
|
+
WatirWebdriverRails.initialize_browser
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# I would really love to add this hook, but it complains that URL is not valid.
|
37
|
+
# config.before(:each) do
|
38
|
+
# if self.class.include?(WatirWebdriverRails::RSpec)
|
39
|
+
# browser.goto 'about:blank'
|
40
|
+
# end
|
41
|
+
# end
|
42
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe HomeController do
|
4
|
-
it "do nothing" do
|
5
|
-
post :index
|
6
|
-
|
7
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HomeController do
|
4
|
+
it "do nothing" do
|
5
|
+
post :index
|
6
|
+
|
7
|
+
end
|
8
8
|
end
|
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe "Rails startup process" do
|
4
|
-
it "should fill textbox" do
|
5
|
-
browser.goto "/"
|
6
|
-
browser.text_field(:id=>"test_textbox").set("Hello")
|
7
|
-
browser.text_field(:id=>"test_textbox").value.should == "Hello"
|
8
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Rails startup process" do
|
4
|
+
it "should fill textbox" do
|
5
|
+
browser.goto "/"
|
6
|
+
browser.text_field(:id=>"test_textbox").set("Hello")
|
7
|
+
browser.text_field(:id=>"test_textbox").value.should == "Hello"
|
8
|
+
end
|
9
9
|
end
|
data/spec/rails/Gemfile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
source 'http://rubygems.org'
|
2
|
-
gem 'rails', '3.0.9'
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
gem 'rails', '3.0.9'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
class HomeController < ActionController::Base
|
2
|
-
|
3
|
-
layout "main"
|
4
|
-
|
1
|
+
class HomeController < ActionController::Base
|
2
|
+
|
3
|
+
layout "main"
|
4
|
+
|
5
5
|
end
|
@@ -1 +1 @@
|
|
1
|
-
<input type="text" id="test_textbox">
|
1
|
+
<input type="text" id="test_textbox">
|
@@ -1,10 +1,10 @@
|
|
1
|
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
-
<title>Rails testing for Watir Webdriver</title>
|
6
|
-
</head>
|
7
|
-
<body>
|
8
|
-
<%=yield%>
|
9
|
-
</body>
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
5
|
+
<title>Rails testing for Watir Webdriver</title>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<%=yield%>
|
9
|
+
</body>
|
10
10
|
</html>
|
@@ -1,23 +1,23 @@
|
|
1
|
-
|
2
|
-
require File.expand_path('../boot', __FILE__)
|
3
|
-
|
4
|
-
# Pick the frameworks you want:
|
5
|
-
# require "active_record/railtie"
|
6
|
-
require "action_controller/railtie"
|
7
|
-
#require "action_mailer/railtie"
|
8
|
-
#require "active_resource/railtie"
|
9
|
-
#require "rails/test_unit/railtie"
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
# If you have a Gemfile, require the gems listed there, including any gems
|
14
|
-
# you've limited to :test, :development, or :production.
|
15
|
-
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
16
|
-
|
17
|
-
module WatirRails
|
18
|
-
class Application < Rails::Application
|
19
|
-
config.encoding = "utf-8"
|
20
|
-
config.filter_parameters += [:password]
|
21
|
-
config.active_support.deprecation = :stderr
|
22
|
-
end
|
23
|
-
end
|
1
|
+
|
2
|
+
require File.expand_path('../boot', __FILE__)
|
3
|
+
|
4
|
+
# Pick the frameworks you want:
|
5
|
+
# require "active_record/railtie"
|
6
|
+
require "action_controller/railtie"
|
7
|
+
#require "action_mailer/railtie"
|
8
|
+
#require "active_resource/railtie"
|
9
|
+
#require "rails/test_unit/railtie"
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
# If you have a Gemfile, require the gems listed there, including any gems
|
14
|
+
# you've limited to :test, :development, or :production.
|
15
|
+
Bundler.require(:default, Rails.env) if defined?(Bundler)
|
16
|
+
|
17
|
+
module WatirRails
|
18
|
+
class Application < Rails::Application
|
19
|
+
config.encoding = "utf-8"
|
20
|
+
config.filter_parameters += [:password]
|
21
|
+
config.active_support.deprecation = :stderr
|
22
|
+
end
|
23
|
+
end
|
data/spec/rails/config/boot.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
|
3
|
-
# Set up gems listed in the Gemfile.
|
4
|
-
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
5
|
-
|
6
|
-
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
1
|
+
require 'rubygems'
|
2
|
+
|
3
|
+
# Set up gems listed in the Gemfile.
|
4
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
5
|
+
|
6
|
+
require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# Load the rails application
|
2
|
-
require File.expand_path('../application', __FILE__)
|
3
|
-
|
4
|
-
# Initialize the rails application
|
5
|
-
WatirRails::Application.initialize!
|
6
|
-
|
7
|
-
WatirRails::Application.config.secret_token = '81d5a4d251df513e47294d8ca73770dd43039b821f06e0a6161f93f1cbdfecd1d7e57f20ceeb6c2ce7e12e5b595c55808a403859cc4b0c324c4760bac9645bb9'
|
8
|
-
|
9
|
-
Rails.logger = Logger.new(STDOUT)
|
10
|
-
|
1
|
+
# Load the rails application
|
2
|
+
require File.expand_path('../application', __FILE__)
|
3
|
+
|
4
|
+
# Initialize the rails application
|
5
|
+
WatirRails::Application.initialize!
|
6
|
+
|
7
|
+
WatirRails::Application.config.secret_token = '81d5a4d251df513e47294d8ca73770dd43039b821f06e0a6161f93f1cbdfecd1d7e57f20ceeb6c2ce7e12e5b595c55808a403859cc4b0c324c4760bac9645bb9'
|
8
|
+
|
9
|
+
Rails.logger = Logger.new(STDOUT)
|
10
|
+
|
data/spec/rails/config/routes.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
WatirRails::Application.routes.draw do
|
2
|
-
root :to => "home#index"
|
3
|
-
match ':controller(/:action(/:id(.:format)))'
|
4
|
-
end
|
1
|
+
WatirRails::Application.routes.draw do
|
2
|
+
root :to => "home#index"
|
3
|
+
match ':controller(/:action(/:id(.:format)))'
|
4
|
+
end
|
data/spec/rails/config.ru
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# This file is used by Rack-based servers to start the application.
|
2
|
-
|
3
|
-
require ::File.expand_path('../config/environment', __FILE__)
|
4
|
-
run WatirRails::Application
|
1
|
+
# This file is used by Rack-based servers to start the application.
|
2
|
+
|
3
|
+
require ::File.expand_path('../config/environment', __FILE__)
|
4
|
+
run WatirRails::Application
|
data/spec/rails/script/rails
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
#!/usr/bin/env ruby.exe
|
2
|
-
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
-
|
4
|
-
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
-
require File.expand_path('../../config/boot', __FILE__)
|
6
|
-
require 'rails/commands'
|
1
|
+
#!/usr/bin/env ruby.exe
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
|
3
|
+
|
4
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
5
|
+
require File.expand_path('../../config/boot', __FILE__)
|
6
|
+
require 'rails/commands'
|
data/spec/spec_helper.rb
CHANGED
@@ -1,23 +1,24 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require 'rubygems'
|
3
|
-
|
4
|
-
ENV["RAILS_ENV"] ||= 'test'
|
5
|
-
|
6
|
-
require File.expand_path("../rails/config/environment", __FILE__)
|
7
|
-
|
8
|
-
require 'rspec/rails'
|
9
|
-
#require 'watir-webdriver-rails'
|
10
|
-
require File.expand_path("../../watir-webdriver-rails", __FILE__)
|
11
|
-
|
12
|
-
WatirWebdriverRails.host = "localhost"
|
13
|
-
WatirWebdriverRails.port = 57124
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
ENV["RAILS_ENV"] ||= 'test'
|
5
|
+
|
6
|
+
require File.expand_path("../rails/config/environment", __FILE__)
|
7
|
+
|
8
|
+
require 'rspec/rails'
|
9
|
+
#require 'watir-webdriver-rails'
|
10
|
+
require File.expand_path("../../lib/watir-webdriver-rails", __FILE__)
|
11
|
+
|
12
|
+
WatirWebdriverRails.host = "localhost"
|
13
|
+
WatirWebdriverRails.port = 57124
|
14
|
+
WatirWebdriverRails.close_browser_after_finish = true
|
15
|
+
|
16
|
+
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
17
|
+
|
18
|
+
|
19
|
+
RSpec.configure do |config|
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
|
@@ -1,23 +1,23 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "watir-webdriver-rails/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "watir-webdriver-rails"
|
7
|
-
s.version = WatirWebdriverRails::VERSION
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["Tanin Na Nakorn"]
|
10
|
-
s.email = ["tanin47@gmail.com"]
|
11
|
-
s.homepage = "http://github.com/tanin47/watir-webdriver-rails"
|
12
|
-
s.summary = %q{Watir on WebDriver for Rails}
|
13
|
-
s.description = %q{WebDriver-backed Watir for Rails}
|
14
|
-
|
15
|
-
s.rubyforge_project = "watir-webdriver-rails"
|
16
|
-
|
17
|
-
s.files = `git ls-files`.split("\n")
|
18
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
-
s.require_paths = ["lib"]
|
21
|
-
|
22
|
-
s.add_dependency "watir-webdriver"
|
23
|
-
end
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "watir-webdriver-rails/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "watir-webdriver-rails"
|
7
|
+
s.version = WatirWebdriverRails::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Tanin Na Nakorn"]
|
10
|
+
s.email = ["tanin47@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/tanin47/watir-webdriver-rails"
|
12
|
+
s.summary = %q{Watir on WebDriver for Rails}
|
13
|
+
s.description = %q{WebDriver-backed Watir for Rails}
|
14
|
+
|
15
|
+
s.rubyforge_project = "watir-webdriver-rails"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_dependency "watir-webdriver"
|
23
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watir-webdriver-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-01 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: watir-webdriver
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152327620 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152327620
|
25
25
|
description: WebDriver-backed Watir for Rails
|
26
26
|
email:
|
27
27
|
- tanin47@gmail.com
|
@@ -86,4 +86,20 @@ rubygems_version: 1.8.10
|
|
86
86
|
signing_key:
|
87
87
|
specification_version: 3
|
88
88
|
summary: Watir on WebDriver for Rails
|
89
|
-
test_files:
|
89
|
+
test_files:
|
90
|
+
- spec/controllers/home_controller_spec.rb
|
91
|
+
- spec/integration/rails_spec.rb
|
92
|
+
- spec/rails/Gemfile
|
93
|
+
- spec/rails/Gemfile.lock
|
94
|
+
- spec/rails/app/controllers/home_controller.rb
|
95
|
+
- spec/rails/app/views/home/index.html.erb
|
96
|
+
- spec/rails/app/views/layouts/main.html.erb
|
97
|
+
- spec/rails/config.ru
|
98
|
+
- spec/rails/config/application.rb
|
99
|
+
- spec/rails/config/boot.rb
|
100
|
+
- spec/rails/config/environment.rb
|
101
|
+
- spec/rails/config/routes.rb
|
102
|
+
- spec/rails/log/test.log
|
103
|
+
- spec/rails/script/cucumber
|
104
|
+
- spec/rails/script/rails
|
105
|
+
- spec/spec_helper.rb
|