watir-webdriver-rails 0.0.2 → 0.0.3

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/README.md CHANGED
@@ -1,92 +1,98 @@
1
- watir-webdriver-rails
2
- ===============
3
-
4
- watir-webdriver-rails provides a dead-simple integration test of Watir with Rails 3.
5
-
6
- Installation
7
- --------
8
-
9
- In your Gemfile, drop the below line
10
-
11
- ``
12
- gem 'watir-webdriver-rails'
13
- ``
14
-
15
- and type:
16
-
17
- ``
18
- bundle install
19
- ``
20
-
21
- from your command line and Rails's root folder
22
-
23
- How to use
24
- -------
25
-
26
- In your spec_helper.rb, please place the below lines:
27
- (watir-webdriver-rails uses RSpec as the testing framework)
28
-
29
- ```ruby
30
-
31
- require 'rspec/rails'
32
- require 'watir-webdriver-rails'
33
-
34
- WatirWebdriverRails.host = "localhost"
35
- WatirWebdriverRails.port = 57124
36
-
37
- ```
38
-
39
- In your integration test file, it should look something like this:
40
-
41
- ```ruby
42
-
43
- require 'spec_helper'
44
-
45
- describe "Test something" do
46
-
47
- it "should go to some page and fill textbox" do
48
-
49
- browser.goto "/member"
50
-
51
- browser.text_field(:id=>"first_name").set "Tanin"
52
- browser.text_field(:id=>"last_name").set "Na Nakorn"
53
-
54
- browser.text_field(:id=>"first_name").value.should == "Tanin"
55
- end
56
- end
57
-
58
- ```
59
-
60
- browser is of type Watir::Browser. You may interact with it freely.
61
- See http://rubydoc.info/gems/watir-webdriver/0.3.2/Watir/Browser
62
-
63
- Dependencies
64
- ------------
65
-
66
- * watir-webdriver
67
- * rspec
68
-
69
- Development
70
- -----------------------------
71
-
72
- * Fork the project.
73
- * Add features or fix bugs
74
- * Add test cases for it
75
- * Send me a pull request
76
-
77
- Please try running all the test cases first by going to the root folder and type:
78
-
79
- ``
80
- bundle exec rspec spec/*
81
- ``
82
-
83
-
84
- License
85
- ---------
86
-
87
- There are parts which are copied from capybara and capybara-firebug gems. Please also be aware of their licenses.
88
- Other than that, you can do anything with it.
89
-
90
- Author
91
- ---------
92
- Tanin Na Nakorn
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.2
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
+ In your integration test file, it should look something like this:
46
+
47
+ ```ruby
48
+
49
+ require 'spec_helper'
50
+
51
+ describe "Test something" do
52
+
53
+ it "should go to some page and fill textbox" do
54
+
55
+ browser.goto "/member"
56
+
57
+ browser.text_field(:id=>"first_name").set "Tanin"
58
+ browser.text_field(:id=>"last_name").set "Na Nakorn"
59
+
60
+ browser.text_field(:id=>"first_name").value.should == "Tanin"
61
+ end
62
+ end
63
+
64
+ ```
65
+
66
+ browser is of type Watir::Browser. You may interact with it freely.
67
+ See http://rubydoc.info/gems/watir-webdriver/0.3.2/Watir/Browser
68
+
69
+ Dependencies
70
+ ------------
71
+
72
+ * watir-webdriver
73
+ * rspec
74
+
75
+ Development
76
+ -----------------------------
77
+
78
+ * Fork the project.
79
+ * Add features or fix bugs
80
+ * Add test cases for it
81
+ * Send me a pull request
82
+
83
+ Please try running all the test cases first by going to the root folder and type:
84
+
85
+ ``
86
+ bundle exec rspec spec/*
87
+ ``
88
+
89
+
90
+ License
91
+ ---------
92
+
93
+ There are parts which are copied from capybara and capybara-firebug gems. Please also be aware of their licenses.
94
+ Other than that, you can do anything with it.
95
+
96
+ Author
97
+ ---------
98
+ Tanin Na Nakorn
@@ -14,23 +14,17 @@ require 'watir-webdriver-rails/rspec'
14
14
  # start server
15
15
  RSpec.configure do |config|
16
16
 
17
- config.include WatirWebdriverRails::RSpec
17
+ config.include WatirWebdriverRails::RSpec, :example_group=>{:file_path=>/spec[\\\/](requests|integration)/}
18
18
 
19
- config.before(:suite) do
20
- WatirWebdriverRails.run_server
21
- WatirWebdriverRails.initialize_browser
22
-
23
- WatirWebdriverRails.browser.class_eval do
24
- alias_method :old_goto,:goto
25
-
26
- def goto(*args)
27
-
28
- if !args[0].match(/^https?:/)
29
- args[0] = "http://#{WatirWebdriverRails.host}:#{WatirWebdriverRails.port}#{args[0]}"
30
- end
31
-
32
- old_goto(*args)
33
- end
34
- end
19
+ config.after do
20
+ if self.class.include?(WatirWebdriverRails::RSpec)
21
+ browser.clear_cookies
22
+ end
23
+ end
24
+ config.before do
25
+ if self.class.include?(WatirWebdriverRails::RSpec)
26
+ WatirWebdriverRails.run_server
27
+ WatirWebdriverRails.initialize_browser
28
+ end
35
29
  end
36
30
  end
@@ -1,9 +1,27 @@
1
1
  module WatirWebdriverRails
2
2
  class << self
3
- attr_accessor :browser
3
+ attr_accessor :browser,:browser_initialized
4
4
 
5
5
  def initialize_browser
6
+
7
+ return if @browser_initialized == true
8
+
6
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
7
25
  end
8
26
 
9
27
  end
@@ -19,11 +19,12 @@ module WatirWebdriverRails
19
19
  end
20
20
 
21
21
  class << self
22
- attr_accessor :host, :port, :server_boot_timeout, :app
22
+ attr_accessor :host, :port, :server_boot_timeout, :app, :server_running
23
23
 
24
24
 
25
25
 
26
26
  def run_server
27
+ return if @server_running == true
27
28
 
28
29
  @app = Rack::Builder.new {
29
30
  map "/" do
@@ -55,6 +56,8 @@ module WatirWebdriverRails
55
56
  false
56
57
  end
57
58
  end
59
+
60
+ @server_running = true
58
61
  end
59
62
 
60
63
 
@@ -1,3 +1,3 @@
1
1
  module WatirWebdriverRails
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe HomeController do
4
+ it "do nothing" do
5
+ post :index
6
+
7
+ end
8
+ end
@@ -5,7 +5,7 @@ require File.expand_path('../boot', __FILE__)
5
5
  # require "active_record/railtie"
6
6
  require "action_controller/railtie"
7
7
  #require "action_mailer/railtie"
8
- require "active_resource/railtie"
8
+ #require "active_resource/railtie"
9
9
  #require "rails/test_unit/railtie"
10
10
 
11
11
 
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
4
+ if vendored_cucumber_bin
5
+ load File.expand_path(vendored_cucumber_bin)
6
+ else
7
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
8
+ require 'cucumber'
9
+ load Cucumber::BINARY
10
+ end
@@ -0,0 +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'
data/spec/spec_helper.rb CHANGED
@@ -6,7 +6,8 @@ ENV["RAILS_ENV"] ||= 'test'
6
6
  require File.expand_path("../rails/config/environment", __FILE__)
7
7
 
8
8
  require 'rspec/rails'
9
- require 'watir-webdriver-rails'
9
+ #require 'watir-webdriver-rails'
10
+ File.expand_path("../../watir-webdriver-rails", __FILE__)
10
11
 
11
12
  WatirWebdriverRails.host = "localhost"
12
13
  WatirWebdriverRails.port = 57124
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.2
4
+ version: 0.0.3
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-09-06 00:00:00.000000000Z
12
+ date: 2011-09-07 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
16
- requirement: &19865820 !ruby/object:Gem::Requirement
16
+ requirement: &19468908 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 0.3.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *19865820
24
+ version_requirements: *19468908
25
25
  description: WebDriver-backed Watir for Rails
26
26
  email:
27
27
  - tanin47@gmail.com
@@ -45,6 +45,7 @@ files:
45
45
  - lib/watir-webdriver-rails/rspec.rb
46
46
  - lib/watir-webdriver-rails/util/timeout.rb
47
47
  - lib/watir-webdriver-rails/version.rb
48
+ - spec/controllers/home_controller_spec.rb
48
49
  - spec/integration/rails_spec.rb
49
50
  - spec/rails/Gemfile
50
51
  - spec/rails/Gemfile.lock
@@ -57,6 +58,8 @@ files:
57
58
  - spec/rails/config/environment.rb
58
59
  - spec/rails/config/routes.rb
59
60
  - spec/rails/log/test.log
61
+ - spec/rails/script/cucumber
62
+ - spec/rails/script/rails
60
63
  - spec/spec_helper.rb
61
64
  - watir-webdriver-rails.gemspec
62
65
  homepage: http://github.com/tanin47/watir-webdriver-rails