kbaum-webrat 0.5.1 → 0.6.1.pre

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.
Files changed (45) hide show
  1. data/.gitignore +4 -1
  2. data/Gemfile +19 -0
  3. data/History.txt +11 -1
  4. data/Rakefile +25 -66
  5. data/Thorfile +117 -0
  6. data/lib/webrat/adapters/rails.rb +1 -16
  7. data/lib/webrat/core/elements/link.rb +1 -1
  8. data/lib/webrat/core/session.rb +1 -1
  9. data/lib/webrat/integrations/merb.rb +1 -1
  10. data/lib/webrat/integrations/rails.rb +16 -0
  11. data/lib/webrat/integrations/rspec-rails.rb +2 -1
  12. data/lib/webrat/integrations/selenium.rb +1 -1
  13. data/lib/webrat/rspec-rails.rb +1 -1
  14. data/lib/webrat/selenium/application_servers/external.rb +1 -1
  15. data/lib/webrat/selenium/application_servers.rb +1 -1
  16. data/lib/webrat/selenium/location_strategy_javascript/label.js +31 -13
  17. data/lib/webrat/selenium/location_strategy_javascript/webrat.js +1 -0
  18. data/lib/webrat/selenium/location_strategy_javascript/webratlink.js +24 -4
  19. data/lib/webrat/selenium/selenium_rc_server.rb +2 -2
  20. data/lib/webrat/selenium/selenium_session.rb +19 -2
  21. data/lib/webrat/selenium/silence_stream.rb +1 -1
  22. data/lib/webrat.rb +1 -1
  23. data/spec/integration/mechanize/spec/spec_helper.rb +3 -1
  24. data/spec/integration/rails/app/controllers/{application.rb → application_controller.rb} +0 -0
  25. data/spec/integration/rails/app/controllers/webrat_controller.rb +3 -0
  26. data/spec/integration/rails/app/views/buttons/show.html.erb +0 -2
  27. data/spec/integration/rails/app/views/webrat/buttons.html.erb +0 -2
  28. data/spec/integration/rails/app/views/webrat/within.html.erb +3 -0
  29. data/spec/integration/rails/config/environment.rb +1 -1
  30. data/spec/integration/rails/config/routes.rb +1 -0
  31. data/spec/integration/rails/test/integration/button_click_test.rb +12 -26
  32. data/spec/integration/rails/test/integration/fill_in_test.rb +1 -1
  33. data/spec/integration/rails/test/integration/link_click_test.rb +1 -1
  34. data/spec/integration/rails/test/integration/webrat_test.rb +35 -9
  35. data/spec/integration/rails/test/test_helper.rb +1 -0
  36. data/spec/private/core/field_spec.rb +9 -11
  37. data/spec/private/rails/rails_adapter_spec.rb +0 -24
  38. data/spec/public/basic_auth_spec.rb +13 -2
  39. data/spec/public/click_link_spec.rb +21 -0
  40. data/spec/public/fill_in_spec.rb +1 -1
  41. data/spec/public/matchers/have_selector_spec.rb +1 -1
  42. data/webrat.gemspec +307 -315
  43. metadata +13 -42
  44. data/VERSION +0 -1
  45. data/selenium_rc_server.patch +0 -20
data/.gitignore CHANGED
@@ -12,4 +12,7 @@ log
12
12
  results
13
13
  test_apps
14
14
  *.tmproj
15
- *.log
15
+ *.log
16
+ *.pid
17
+ bin
18
+ vendor/gems
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ clear_sources
2
+ source 'http://gemcutter.org'
3
+
4
+ disable_system_gems
5
+
6
+ gem "git", "1.2.5"
7
+ gem "rake", "0.8.7"
8
+ gem "rspec", "1.2.9"
9
+ gem "diff-lcs", "1.1.2"
10
+ gem "rack", "1.0.1"
11
+ gem "nokogiri", "1.4.0"
12
+ gem "merb-core", "1.0.15"
13
+ gem "selenium-client", "1.2.17"
14
+ gem "mechanize", "0.9.3"
15
+ gem "rails", "2.3.4"
16
+ gem "launchy", "0.3.3"
17
+ gem "rack-test", "0.5.2"
18
+ gem "sinatra", "0.9.4"
19
+ gem "mongrel", "1.1.5"
data/History.txt CHANGED
@@ -1,4 +1,4 @@
1
- == Git
1
+ == 0.6.0 / 2009-11-28
2
2
 
3
3
  REMOVED: Support for Hpricot + REXML as an alternative to Nokogiri.
4
4
 
@@ -12,17 +12,27 @@ CHANGED: Due to a reorganization, if you're currently requiring "webrat/rspec-ra
12
12
 
13
13
  * Minor enhancements
14
14
 
15
+ * Support Rails 2.3.4 JavaScript form authenticity tokens in simulated mode (Jonathan Weiss)
16
+ * When a timeout occurs in wait_for, include the HTML from Selenium in the exception
15
17
  * Update the Merb support to be based directly on Rack (Simon Rozet)
16
18
  * Support multiple select fields (Kieran P)
17
19
  * When locating select options, always match against text, not HTML
18
20
 
19
21
  * Bug fixes
20
22
 
23
+ * Remove newlines from HTTP Basic authentication credentials (Michael Klett)
24
+ * Require nokogiri form rspec-rails.rb (David Chelimsky)
21
25
  * Fix logger issue when running inside Cucumber (Damian Janowski)
22
26
  * Fix various issues related to submitting values with HTML entities (Kieran P)
23
27
  * Call #to_i on the :count option in matchers (Michael Christenson II)
24
28
  * Fix bug where multiline param values were getting truncated
25
29
 
30
+ == 0.5.3 / 2009-08-27
31
+
32
+ * Minor enhancements
33
+
34
+ * Remove unnecessary requires which are to the wrong paths on Edge Rails
35
+
26
36
  == 0.5.1 / 2009-08-18
27
37
 
28
38
  * Minor enhancements
data/Rakefile CHANGED
@@ -1,62 +1,26 @@
1
1
  require "rubygems"
2
2
 
3
3
  begin
4
- require 'jeweler'
5
-
6
- Jeweler::Tasks.new do |s|
7
- s.name = "kbaum-webrat"
8
- s.author = "Bryan Helmkamp"
9
- s.email = "bryan" + "@" + "brynary.com"
10
- s.homepage = "http://github.com/brynary/webrat"
11
- s.summary = "Ruby Acceptance Testing for Web applications"
12
- s.description = <<-EOS.strip
13
- Webrat lets you quickly write expressive and robust acceptance tests
14
- for a Ruby web application. It supports simulating a browser inside
15
- a Ruby process to avoid the performance hit and browser dependency of
16
- Selenium or Watir, but the same API can also be used to drive real
17
- Selenium tests when necessary (eg. for testing AJAX interactions).
18
- Most Ruby web frameworks and testing frameworks are supported.
19
- EOS
20
-
21
- s.rubyforge_project = "webrat"
22
- s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt History.txt]
23
-
24
- # Dependencies
25
- s.add_dependency "nokogiri", ">= 1.2.0"
26
- s.add_dependency "rack", ">= 1.0"
27
-
28
- s.add_development_dependency "rails", ">= 2.3"
29
- s.add_development_dependency "merb-core", ">= 1.0"
30
- s.add_development_dependency "launchy"
31
- end
32
-
33
- Jeweler::RubyforgeTasks.new
4
+ require 'spec/rake/spectask'
34
5
  rescue LoadError
35
- puts "Jeweler not available. Install it with: gem install jeweler"
36
- end
37
-
38
- # require 'spec'
39
- require 'spec/rake/spectask'
40
- require 'spec/rake/verify_rcov'
41
-
42
- desc "Run API and Core specs"
43
- Spec::Rake::SpecTask.new do |t|
44
- t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
45
- t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
46
- end
47
-
48
- desc "Run all specs in spec directory with RCov"
49
- Spec::Rake::SpecTask.new(:rcov) do |t|
50
- t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
51
- t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
52
- t.rcov = true
53
- t.rcov_opts = lambda do
54
- IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
6
+ desc "Run specs"
7
+ task(:spec) { $stderr.puts '`gem install rspec` to run specs' }
8
+ else
9
+ desc "Run API and Core specs"
10
+ Spec::Rake::SpecTask.new do |t|
11
+ t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
12
+ t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
55
13
  end
56
- end
57
14
 
58
- RCov::VerifyTask.new(:verify_rcov => :rcov) do |t|
59
- t.threshold = 96.2 # Make sure you have rcov 0.7 or higher!
15
+ desc "Run all specs in spec directory with RCov"
16
+ Spec::Rake::SpecTask.new(:rcov) do |t|
17
+ t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
18
+ t.spec_files = FileList['spec/public/**/*_spec.rb'] + FileList['spec/private/**/*_spec.rb']
19
+ t.rcov = true
20
+ t.rcov_opts = lambda do
21
+ IO.readlines(File.dirname(__FILE__) + "/spec/rcov.opts").map {|l| l.chomp.split " "}.flatten
22
+ end
23
+ end
60
24
  end
61
25
 
62
26
  desc "Run everything against multiruby"
@@ -111,18 +75,18 @@ task :spec_deps do
111
75
  end
112
76
  end
113
77
 
114
- task :prepare do
115
- system "ln -s ../../../../.. ./spec/integration/rails/vendor/plugins/webrat"
116
- end
117
-
118
78
  namespace :spec do
119
79
  desc "Run the integration specs"
120
- task :integration => ["integration:rails", "integration:merb", "integration:sinatra", "integration:rack", "integration:mechanize"]
80
+ task :integration => [
81
+ "integration:rack",
82
+ "integration:sinatra",
83
+ "integration:merb",
84
+ "integration:mechanize",
85
+ "integration:rails:webrat",
86
+ "integration:rails:selenium",
87
+ ]
121
88
 
122
89
  namespace :integration do
123
- desc "Run the Rails integration specs"
124
- task :rails => ['rails:webrat'] #,'rails:selenium'] currently not running selenium as it doesn't pass.
125
-
126
90
  namespace :rails do
127
91
  task :selenium do
128
92
  Dir.chdir "spec/integration/rails" do
@@ -178,9 +142,4 @@ task :whitespace do
178
142
  sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
179
143
  end
180
144
 
181
- if defined?(Jeweler)
182
- task :spec => :check_dependencies
183
- task :build => :gemspec
184
- end
185
-
186
145
  task :default => :spec
data/Thorfile ADDED
@@ -0,0 +1,117 @@
1
+ module GemHelpers
2
+
3
+ def generate_gemspec
4
+ $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), "lib")))
5
+ require "webrat"
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "webrat"
9
+ s.version = Webrat::VERSION
10
+ s.author = "Bryan Helmkamp"
11
+ s.email = "bryan@brynary.com"
12
+ s.homepage = "http://github.com/brynary/webrat"
13
+ s.summary = "Ruby Acceptance Testing for Web applications"
14
+ s.description = <<-EOS.strip
15
+ Webrat lets you quickly write expressive and robust acceptance tests
16
+ for a Ruby web application. It supports simulating a browser inside
17
+ a Ruby process to avoid the performance hit and browser dependency of
18
+ Selenium or Watir, but the same API can also be used to drive real
19
+ Selenium tests when necessary (eg. for testing AJAX interactions).
20
+ Most Ruby web frameworks and testing frameworks are supported.
21
+ EOS
22
+ s.rubyforge_project = "webrat"
23
+
24
+ require "git"
25
+ repo = Git.open(".")
26
+
27
+ s.files = normalize_files(repo.ls_files.keys - repo.lib.ignored_files)
28
+ s.test_files = normalize_files(Dir['spec/**/*.rb'] - repo.lib.ignored_files)
29
+
30
+ s.has_rdoc = true
31
+ s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt History.txt]
32
+
33
+ s.add_dependency "nokogiri", ">= 1.2.0"
34
+ s.add_dependency "rack", ">= 1.0"
35
+ end
36
+ end
37
+
38
+ def normalize_files(array)
39
+ # only keep files, no directories, and sort
40
+ array.select do |path|
41
+ File.file?(path)
42
+ end.sort
43
+ end
44
+
45
+ # Adds extra space when outputting an array. This helps create better version
46
+ # control diffs, because otherwise it is all on the same line.
47
+ def prettyify_array(gemspec_ruby, array_name)
48
+ gemspec_ruby.gsub(/s\.#{array_name.to_s} = \[.+?\]/) do |match|
49
+ leadin, files = match[0..-2].split("[")
50
+ leadin + "[\n #{files.split(",").join(",\n ")}\n ]"
51
+ end
52
+ end
53
+
54
+ def read_gemspec
55
+ @read_gemspec ||= eval(File.read("webrat.gemspec"))
56
+ end
57
+
58
+ def sh(command)
59
+ puts command
60
+ system command
61
+ end
62
+ end
63
+
64
+ class Default < Thor
65
+ include GemHelpers
66
+
67
+ desc "gemspec", "Regenerate webrat.gemspec"
68
+ def gemspec
69
+ File.open("webrat.gemspec", "w") do |file|
70
+ gemspec_ruby = generate_gemspec.to_ruby
71
+ gemspec_ruby = prettyify_array(gemspec_ruby, :files)
72
+ gemspec_ruby = prettyify_array(gemspec_ruby, :test_files)
73
+ gemspec_ruby = prettyify_array(gemspec_ruby, :extra_rdoc_files)
74
+
75
+ file.write gemspec_ruby
76
+ end
77
+
78
+ puts "Wrote gemspec to webrat.gemspec"
79
+ read_gemspec.validate
80
+ end
81
+
82
+ desc "build", "Build a webrat gem"
83
+ def build
84
+ sh "gem build webrat.gemspec"
85
+ FileUtils.mkdir_p "pkg"
86
+ FileUtils.mv read_gemspec.file_name, "pkg"
87
+ end
88
+
89
+ desc "install", "Install the latest built gem"
90
+ def install
91
+ sh "gem install --local pkg/#{read_gemspec.file_name}"
92
+ end
93
+
94
+ desc "release", "Release the current branch to GitHub and Gemcutter"
95
+ def release
96
+ gemspec
97
+ build
98
+ Release.new.tag
99
+ Release.new.gem
100
+ end
101
+ end
102
+
103
+ class Release < Thor
104
+ include GemHelpers
105
+
106
+ desc "tag", "Tag the gem on the origin server"
107
+ def tag
108
+ release_tag = "v#{read_gemspec.version}"
109
+ sh "git tag -a #{release_tag} -m 'Tagging #{release_tag}'"
110
+ sh "git push origin #{release_tag}"
111
+ end
112
+
113
+ desc "gem", "Push the gem to Gemcutter"
114
+ def gem
115
+ sh "gem push pkg/#{read_gemspec.file_name}"
116
+ end
117
+ end
@@ -11,21 +11,6 @@ module Webrat
11
11
  @integration_session = session
12
12
  end
13
13
 
14
- # The Rails version of within supports passing in a model and Webrat
15
- # will apply a scope based on Rails' dom_id for that model.
16
- #
17
- # Example:
18
- # within User.last do
19
- # click_link "Delete"
20
- # end
21
- def within(selector_or_object, &block)
22
- if selector_or_object.is_a?(String)
23
- super
24
- else
25
- super('#' + dom_id(selector_or_object), &block)
26
- end
27
- end
28
-
29
14
  def doc_root
30
15
  File.expand_path(File.join(RAILS_ROOT, 'public'))
31
16
  end
@@ -93,4 +78,4 @@ module Webrat
93
78
  integration_session.response
94
79
  end
95
80
  end
96
- end
81
+ end
@@ -53,7 +53,7 @@ module Webrat
53
53
 
54
54
  def authenticity_token
55
55
  return unless onclick && onclick.include?("s.setAttribute('name', 'authenticity_token');") &&
56
- onclick =~ /s\.setAttribute\('value', '([a-f0-9]{40})'\);/
56
+ ( onclick =~ /s\.setAttribute\('value', '([a-f0-9]{40})'\);/ || onclick =~ /s\.setAttribute\('value', '(.{44})'\);/ )
57
57
  $LAST_MATCH_INFO.captures.first
58
58
  end
59
59
 
@@ -105,7 +105,7 @@ For example:
105
105
  end
106
106
 
107
107
  def basic_auth(user, pass)
108
- encoded_login = ["#{user}:#{pass}"].pack("m*")
108
+ encoded_login = ["#{user}:#{pass}"].pack("m*").gsub(/\n/, '')
109
109
  header('HTTP_AUTHORIZATION', "Basic #{encoded_login}")
110
110
  end
111
111
 
@@ -7,4 +7,4 @@ module Merb #:nodoc:
7
7
  end
8
8
  end
9
9
  end
10
- end
10
+ end
@@ -5,5 +5,21 @@ module ActionController #:nodoc:
5
5
  IntegrationTest.class_eval do
6
6
  include Webrat::Methods
7
7
  include Webrat::Matchers
8
+
9
+ # The Rails version of within supports passing in a model and Webrat
10
+ # will apply a scope based on Rails' dom_id for that model.
11
+ #
12
+ # Example:
13
+ # within User.last do
14
+ # click_link "Delete"
15
+ # end
16
+ def within(selector_or_object, &block)
17
+ if selector_or_object.is_a?(String)
18
+ super
19
+ else
20
+ super('#' + RecordIdentifier.dom_id(selector_or_object), &block)
21
+ end
22
+ end
23
+
8
24
  end
9
25
  end
@@ -1,8 +1,9 @@
1
1
  # Supports using the matchers in controller, helper, and view specs if you're
2
2
  # using rspec-rails. Just add a require statement to spec/spec_helper.rb or env.rb:
3
3
  #
4
- # require 'webrat/rspec-rails'
4
+ # require 'webrat/integrations/rspec-rails'
5
5
  #
6
+ require "nokogiri"
6
7
  require "webrat/core/matchers"
7
8
 
8
9
  Spec::Runner.configure do |config|
@@ -8,4 +8,4 @@ if defined?(ActionController::IntegrationTest)
8
8
  include Webrat::Selenium::Matchers
9
9
  end
10
10
  end
11
- end
11
+ end
@@ -1,2 +1,2 @@
1
1
  warn("Requiring 'webrat/rspec-rails' is deprecated. Please require 'webrat/integrations/rspec-rails' instead")
2
- require "webrat/integrations/rspec-rails"
2
+ require "webrat/integrations/rspec-rails"
@@ -23,4 +23,4 @@ module Webrat
23
23
  end
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -2,4 +2,4 @@ require "webrat/selenium/application_servers/base"
2
2
  require "webrat/selenium/application_servers/sinatra"
3
3
  require "webrat/selenium/application_servers/merb"
4
4
  require "webrat/selenium/application_servers/rails"
5
- require "webrat/selenium/application_servers/external"
5
+ require "webrat/selenium/application_servers/external"
@@ -1,24 +1,42 @@
1
+ // Credit to: http://simonwillison.net/2006/Jan/20/escape/
2
+ RegExp.escape = function(text) {
3
+ if (!arguments.callee.sRE) {
4
+ var specials = [
5
+ '/', '.', '*', '+', '?', '|',
6
+ '(', ')', '[', ']', '{', '}', '\\'
7
+ ];
8
+ arguments.callee.sRE = new RegExp(
9
+ '(\\' + specials.join('|\\') + ')', 'g'
10
+ );
11
+ }
12
+ return text.replace(arguments.callee.sRE, '\\$1');
13
+ }
14
+
1
15
  var allLabels = inDocument.getElementsByTagName("label");
16
+ var regExp = new RegExp('^\\W*' + RegExp.escape(locator) + '(\\b|$)', 'i');
17
+
2
18
  var candidateLabels = $A(allLabels).select(function(candidateLabel){
3
- var regExp = new RegExp('^' + locator + '\\b', 'i');
4
19
  var labelText = getText(candidateLabel).strip();
5
20
  return (labelText.search(regExp) >= 0);
6
21
  });
22
+
7
23
  if (candidateLabels.length == 0) {
8
24
  return null;
9
25
  }
10
- candidateLabels = candidateLabels.sortBy(function(s) { return s.length * -1; }); //reverse length sort
26
+
27
+ //reverse length sort
28
+ candidateLabels = candidateLabels.sortBy(function(s) {
29
+ return s.length * -1;
30
+ });
31
+
11
32
  var locatedLabel = candidateLabels.first();
12
- var labelFor = locatedLabel.getAttribute('for') || locatedLabel.getAttribute('htmlFor');
13
- if((!labelFor || labelFor == "") && (locatedLabel.hasChildNodes())) {
14
- var inputTags = locatedLabel.getElementsByTagName("input");
15
- var textAreaTags = locatedLabel.getElementsByTagName("textarea");
16
- if(inputTags.length > 0) {
17
- return inputTags[0];
18
- } else if(textAreaTags.length > 0) {
19
- return textAreaTags[0];
20
- } else {
21
- return null;
22
- }
33
+ var labelFor = locatedLabel.getAttribute('for');
34
+
35
+ if ((labelFor == null) && (locatedLabel.hasChildNodes())) {
36
+ return locatedLabel.getElementsByTagName('button')[0]
37
+ || locatedLabel.getElementsByTagName('input')[0]
38
+ || locatedLabel.getElementsByTagName('textarea')[0]
39
+ || locatedLabel.getElementsByTagName('select')[0];
23
40
  }
41
+
24
42
  return selenium.browserbot.locationStrategies['id'].call(this, labelFor, inDocument, inWindow);
@@ -1,4 +1,5 @@
1
1
  var locationStrategies = selenium.browserbot.locationStrategies;
2
+
2
3
  return locationStrategies['id'].call(this, locator, inDocument, inWindow)
3
4
  || locationStrategies['name'].call(this, locator, inDocument, inWindow)
4
5
  || locationStrategies['label'].call(this, locator, inDocument, inWindow)
@@ -1,12 +1,32 @@
1
1
  var links = inDocument.getElementsByTagName('a');
2
+
2
3
  var candidateLinks = $A(links).select(function(candidateLink) {
3
- var textMatched = PatternMatcher.matches(locator, getText(candidateLink));
4
- var idMatched = PatternMatcher.matches(locator, candidateLink.id);
5
- var titleMatched = PatternMatcher.matches(locator, candidateLink.title);
4
+ var textMatched = false;
5
+ var titleMatched = false;
6
+ var idMatched = false;
7
+
8
+ if (getText(candidateLink).toLowerCase().indexOf(locator.toLowerCase()) != -1) {
9
+ textMatched = true;
10
+ }
11
+
12
+ if (candidateLink.title.toLowerCase().indexOf(locator.toLowerCase()) != -1) {
13
+ titleMatched = true;
14
+ }
15
+
16
+ if (candidateLink.id.toLowerCase().indexOf(locator.toLowerCase()) != -1) {
17
+ idMatched = true;
18
+ }
19
+
6
20
  return textMatched || idMatched || titleMatched;
7
21
  });
22
+
8
23
  if (candidateLinks.length == 0) {
9
24
  return null;
10
25
  }
11
- candidateLinks = candidateLinks.sortBy(function(s) { return s.length * -1; }); //reverse length sort
26
+
27
+ //reverse length sort
28
+ candidateLinks = candidateLinks.sortBy(function(s) {
29
+ return s.length * -1;
30
+ });
31
+
12
32
  return candidateLinks.first();
@@ -74,8 +74,8 @@ module Webrat
74
74
 
75
75
  def stop
76
76
  silence_stream(STDOUT) do
77
- ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0",
78
- Webrat.configuration.selenium_server_port,
77
+ ::Selenium::RemoteControl::RemoteControl.new("0.0.0.0",
78
+ Webrat.configuration.selenium_server_port,
79
79
  :timeout => 5).stop
80
80
  end
81
81
  end
@@ -79,7 +79,12 @@ module Webrat
79
79
  webrat_deprecate :clicks_button, :click_button
80
80
 
81
81
  def click_link(link_text_or_regexp, options = {})
82
- pattern = adjust_if_regexp(link_text_or_regexp)
82
+ if link_text_or_regexp.is_a?(Regexp)
83
+ pattern = "evalregex:#{link_text_or_regexp.inspect}"
84
+ else
85
+ pattern = link_text_or_regexp.to_s
86
+ end
87
+
83
88
  locator = "webratlink=#{pattern}"
84
89
  selenium.wait_for_element locator, :timeout_in_seconds => Webrat.configuration.selenium_response_wait_time
85
90
  selenium.click locator
@@ -164,7 +169,19 @@ module Webrat
164
169
  sleep 0.25
165
170
  end
166
171
 
167
- raise Webrat::TimeoutError.new(message + " (after #{timeout} sec)")
172
+ error_message = "#{message} (after #{timeout} sec)"
173
+
174
+ if $browser
175
+ error_message += <<-EOS
176
+
177
+
178
+ HTML of the page was:
179
+
180
+ #{selenium.get_html_source}"
181
+ EOS
182
+ end
183
+
184
+ raise Webrat::TimeoutError.new(error_message)
168
185
  true
169
186
  end
170
187
 
@@ -15,4 +15,4 @@ module Webrat
15
15
  end
16
16
  end
17
17
  end
18
- end
18
+ end
data/lib/webrat.rb CHANGED
@@ -2,7 +2,7 @@ require "rack"
2
2
  require "nokogiri"
3
3
 
4
4
  module Webrat
5
- VERSION = "0.6pre"
5
+ VERSION = "0.6.1.pre"
6
6
 
7
7
  autoload :MechanizeAdapter, "webrat/adapters/mechanize"
8
8
  autoload :MerbAdapter, "webrat/adapters/merb"
@@ -21,7 +21,9 @@ Spec::Runner.configure do |config|
21
21
  end
22
22
 
23
23
  config.after :suite do
24
- Process.kill("TERM", File.read("rack.pid").to_i)
24
+ if File.exists?("rack.pid")
25
+ Process.kill("TERM", File.read("rack.pid").to_i)
26
+ end
25
27
  end
26
28
  end
27
29
 
@@ -40,4 +40,7 @@ class WebratController < ApplicationController
40
40
  render :text => params.to_json
41
41
  end
42
42
 
43
+ def within
44
+ end
45
+
43
46
  end
@@ -1,11 +1,9 @@
1
1
  <h1 id='form_title' class='form title'>Webrat Buttons Form</h1>
2
2
 
3
3
  <% form_tag "/buttons" do %>
4
- <input type="button" id="input_button_id" value="input_button_value" />
5
4
  <input type="submit" id="input_submit_id" value="input_submit_value" />
6
5
  <input type="image" id="input_image_id" value="input_image_value" alt="input_image_alt" src="" />
7
6
 
8
- <button type="button" id="button_button_id" value="button_button_value">button_button_text</button>
9
7
  <button type="submit" id="button_submit_id" value="button_submit_value">button_submit_text</button>
10
8
  <button type="image" id="button_image_id" value="button_image_value">button_image_text</button>
11
9
  <% end %>
@@ -1,11 +1,9 @@
1
1
  <h1 id='form_title' class='form title'>Webrat Buttons Form</h1>
2
2
 
3
3
  <% form_tag submit_path do %>
4
- <input type="button" id="input_button_id" value="input_button_value">
5
4
  <input type="submit" id="input_submit_id" value="input_submit_value">
6
5
  <input type="image" id="input_image_id" value="input_image_value" alt="input_image_alt" src="">
7
6
 
8
- <button type="button" id="button_button_id" value="button_button_value">button_button_text</button>
9
7
  <button type="submit" id="button_submit_id" value="button_submit_value">button_submit_text</button>
10
8
  <button type="image" id="button_image_id" value="button_image_value">button_image_text</button>
11
9
  <% end %>
@@ -0,0 +1,3 @@
1
+ <div id="new_object">
2
+ <a href="/">Edit Object</a>
3
+ </div>
@@ -1,4 +1,4 @@
1
- RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
1
+ # RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
2
2
 
3
3
  require File.join(File.dirname(__FILE__), 'boot')
4
4
 
@@ -12,6 +12,7 @@ ActionController::Routing::Routes.draw do |map|
12
12
  webrat.before_redirect_form "/before_redirect_form", :action => "before_redirect_form"
13
13
  webrat.redirect_to_show_params "/redirect_to_show_params", :action => "redirect_to_show_params"
14
14
  webrat.show_params "/show_params", :action => "show_params"
15
+ webrat.within "/within", :action => "within"
15
16
 
16
17
  webrat.root :action => "form"
17
18
  end