honkster-webrat 0.6.0.10 → 0.7.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/Gemfile +0 -6
  2. data/History.txt +34 -0
  3. data/Rakefile +7 -8
  4. data/Thorfile +1 -0
  5. data/honkster-webrat.gemspec +9 -5
  6. data/lib/webrat.rb +1 -1
  7. data/lib/webrat/adapters/mechanize.rb +22 -6
  8. data/lib/webrat/adapters/rack.rb +4 -0
  9. data/lib/webrat/adapters/rails.rb +4 -8
  10. data/lib/webrat/core/configuration.rb +23 -4
  11. data/lib/webrat/core/elements/field.rb +40 -89
  12. data/lib/webrat/core/elements/form.rb +55 -31
  13. data/lib/webrat/core/locators/form_locator.rb +1 -1
  14. data/lib/webrat/core/locators/select_option_locator.rb +1 -1
  15. data/lib/webrat/core/matchers/have_content.rb +1 -1
  16. data/lib/webrat/core/matchers/have_xpath.rb +4 -2
  17. data/lib/webrat/core/methods.rb +1 -1
  18. data/lib/webrat/core/mime.rb +2 -2
  19. data/lib/webrat/core/save_and_open_page.rb +3 -23
  20. data/lib/webrat/core/scope.rb +1 -0
  21. data/lib/webrat/core/session.rb +4 -7
  22. data/lib/webrat/core_extensions/{nil_to_param.rb → nil_to_query_string.rb} +1 -1
  23. data/lib/webrat/selenium/location_strategy_javascript/label.js +8 -2
  24. data/lib/webrat/selenium/matchers/have_content.rb +22 -10
  25. data/lib/webrat/selenium/matchers/have_selector.rb +8 -0
  26. data/lib/webrat/selenium/matchers/have_xpath.rb +8 -0
  27. data/lib/webrat/selenium/selenium_rc_server.rb +5 -2
  28. data/lib/webrat/selenium/selenium_session.rb +12 -12
  29. data/spec/fakes/test_adapter.rb +1 -5
  30. data/spec/integration/mechanize/sample_app.rb +16 -1
  31. data/spec/integration/mechanize/spec/mechanize_spec.rb +9 -1
  32. data/spec/integration/rack/app.rb +2 -2
  33. data/spec/integration/rack/test/helper.rb +0 -1
  34. data/spec/integration/rack/test/webrat_rack_test.rb +3 -2
  35. data/spec/integration/sinatra/classic_app.rb +0 -1
  36. data/spec/integration/sinatra/modular_app.rb +0 -1
  37. data/spec/integration/sinatra/test/classic_app_test.rb +1 -0
  38. data/spec/integration/sinatra/test/test_helper.rb +0 -1
  39. data/spec/private/core/field_spec.rb +1 -1
  40. data/spec/private/core/form_spec.rb +51 -0
  41. data/spec/private/core/session_spec.rb +5 -23
  42. data/spec/private/mechanize/mechanize_adapter_spec.rb +24 -1
  43. data/spec/private/rails/attaches_file_spec.rb +33 -0
  44. data/spec/private/rails/rails_adapter_spec.rb +0 -7
  45. data/spec/public/matchers/contain_spec.rb +8 -15
  46. data/spec/public/matchers/have_xpath_spec.rb +6 -0
  47. data/spec/public/save_and_open_spec.rb +4 -25
  48. data/spec/public/select_spec.rb +19 -0
  49. data/spec/public/submit_form_spec.rb +52 -1
  50. data/spec/spec_helper.rb +0 -1
  51. data/vendor/selenium-server.jar +0 -0
  52. metadata +56 -15
  53. data/pkg/honkster-webrat-0.6.0.9.gem +0 -0
data/Gemfile CHANGED
@@ -1,9 +1,3 @@
1
- clear_sources
2
- source 'http://gemcutter.org'
3
-
4
- disable_system_gems
5
-
6
- gem "git", "1.2.5"
7
1
  gem "rake", "0.8.7"
8
2
  gem "rspec", "1.2.9"
9
3
  gem "diff-lcs", "1.1.2"
data/History.txt CHANGED
@@ -1,3 +1,37 @@
1
+ == 0.7.1 / 2010-04-26
2
+
3
+ * Minor enhancements
4
+
5
+ * Move verbose selenium output that can clutter build output behind setting
6
+ * Added application_port_for_selenium to webrat configuration. The use case is when you want to test through a web server sitting in front of your application server. (Luke Melia)
7
+ * New webrat configuration option selenium_firefox_profile which is passed to selenium server
8
+ * Allow submit_form to select by CSS too (Damian Janowski)
9
+
10
+ * Bug fixes
11
+
12
+ * Fix that current_url wasn't reflecting redirects in Mechanize [#332] (Emrys Ingersoll)
13
+ * Fix attach_file with nested params [#341] (Álvaro Gil)
14
+ * Fix that a 304 was considered a redirect (Larry Marburger)
15
+ * Fix selection of LABEL elements in Selenium mode under IE [#317] (Damian Janowski, Noah Davis)
16
+ * Fix have_xpath not matching negative expectation in the block [#182] (Luismi Cavallé)
17
+
18
+ == 0.7.0 / 2010-01-17
19
+
20
+ * Major enhancements
21
+
22
+ * Upgrade bundled Selenium server JAR to 2.0a1 (Henry Poydar and Jake Scruggs)
23
+
24
+ * Minor enhancements
25
+
26
+ * Save and open page directory specified via configuration, defaults to tmp dir otherwise current dir (Noah Davis)
27
+
28
+ * Bug fixes
29
+
30
+ * Added missing dependency "rack-test" to gemspec (LH #339) (Noah Davis)
31
+ * Removed save_and_open_page's rewriting of static asset paths before saving (was not actually working) (Noah Davis)
32
+ * Make "should contain" ignore extra whitespace when doing string comparisons (Noah Davis)
33
+ * Make selenium matchers handle negative match more consistently with positive match (Luke Melia)
34
+
1
35
  == 0.6.0 / 2009-11-28
2
36
 
3
37
  REMOVED: Support for Hpricot + REXML as an alternative to Nokogiri.
data/Rakefile CHANGED
@@ -1,5 +1,3 @@
1
- require "rubygems"
2
-
3
1
  begin
4
2
  require 'spec/rake/spectask'
5
3
  rescue LoadError
@@ -90,14 +88,14 @@ namespace :spec do
90
88
  namespace :rails do
91
89
  task :selenium do
92
90
  Dir.chdir "spec/integration/rails" do
93
- result = system "rake test_unit:selenium"
91
+ result = system "rake -rubygems test_unit:selenium"
94
92
  raise "Rails integration tests failed" unless result
95
93
  end
96
94
  end
97
95
 
98
96
  task :webrat do
99
97
  Dir.chdir "spec/integration/rails" do
100
- result = system "rake test_unit:rails"
98
+ result = system "rake -rubygems test_unit:rails"
101
99
  raise "Rails integration tests failed" unless result
102
100
  end
103
101
  end
@@ -106,7 +104,7 @@ namespace :spec do
106
104
  desc "Run the Merb integration specs"
107
105
  task :merb do
108
106
  Dir.chdir "spec/integration/merb" do
109
- result = system "rake spec"
107
+ result = system "rake -rubygems spec"
110
108
  raise "Merb integration tests failed" unless result
111
109
  end
112
110
  end
@@ -114,7 +112,7 @@ namespace :spec do
114
112
  desc "Run the Sinatra integration specs"
115
113
  task :sinatra do
116
114
  Dir.chdir "spec/integration/sinatra" do
117
- result = system "rake test"
115
+ result = system "rake -rubygems test"
118
116
  raise "Sinatra integration tests failed" unless result
119
117
  end
120
118
  end
@@ -122,7 +120,7 @@ namespace :spec do
122
120
  desc "Run the Sinatra integration specs"
123
121
  task :rack do
124
122
  Dir.chdir "spec/integration/rack" do
125
- result = system "rake test"
123
+ result = system "rake -rubygems test"
126
124
  raise "Rack integration tests failed" unless result
127
125
  end
128
126
  end
@@ -130,7 +128,7 @@ namespace :spec do
130
128
  desc "Run the Mechanize integration specs"
131
129
  task :mechanize do
132
130
  Dir.chdir "spec/integration/mechanize" do
133
- result = system "rake spec"
131
+ result = system "rake -rubygems spec"
134
132
  raise "Mechanize integration tests failed" unless result
135
133
  end
136
134
  end
@@ -141,4 +139,5 @@ desc 'Removes trailing whitespace'
141
139
  task :whitespace do
142
140
  sh %{find . -name '*.rb' -exec sed -i '' 's/ *$//g' {} \\;}
143
141
  end
142
+
144
143
  task :default => :spec
data/Thorfile CHANGED
@@ -32,6 +32,7 @@ Most Ruby web frameworks and testing frameworks are supported.
32
32
 
33
33
  s.add_dependency "nokogiri", ">= 1.2.0"
34
34
  s.add_dependency "rack", ">= 1.0"
35
+ s.add_dependency "rack-test", ">= 0.5.3"
35
36
  end
36
37
  end
37
38
 
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{honkster-webrat}
5
- s.version = "0.6.0.10"
5
+ s.version = "0.7.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Bryan Helmkamp"]
9
- s.date = %q{2009-12-22}
9
+ s.date = %q{2010-04-26}
10
10
  s.description = %q{Webrat lets you quickly write expressive and robust acceptance tests
11
11
  for a Ruby web application. It supports simulating a browser inside
12
12
  a Ruby process to avoid the performance hit and browser dependency of
@@ -73,7 +73,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
73
73
  "lib/webrat/core_extensions/deprecate.rb",
74
74
  "lib/webrat/core_extensions/detect_mapped.rb",
75
75
  "lib/webrat/core_extensions/meta_class.rb",
76
- "lib/webrat/core_extensions/nil_to_param.rb",
76
+ "lib/webrat/core_extensions/nil_to_query_string.rb",
77
77
  "lib/webrat/core_extensions/tcp_socket.rb",
78
78
  "lib/webrat/integrations/merb.rb",
79
79
  "lib/webrat/integrations/rails.rb",
@@ -104,7 +104,6 @@ Most Ruby web frameworks and testing frameworks are supported.}
104
104
  "lib/webrat/selenium/selenium_rc_server.rb",
105
105
  "lib/webrat/selenium/selenium_session.rb",
106
106
  "lib/webrat/selenium/silence_stream.rb",
107
- "pkg/honkster-webrat-0.6.0.9.gem",
108
107
  "spec/fakes/test_adapter.rb",
109
108
  "spec/integration/mechanize/Rakefile",
110
109
  "spec/integration/mechanize/config.ru",
@@ -197,6 +196,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
197
196
  "spec/integration/sinatra/test/test_helper.rb",
198
197
  "spec/private/core/configuration_spec.rb",
199
198
  "spec/private/core/field_spec.rb",
199
+ "spec/private/core/form_spec.rb",
200
200
  "spec/private/core/link_spec.rb",
201
201
  "spec/private/core/session_spec.rb",
202
202
  "spec/private/mechanize/mechanize_adapter_spec.rb",
@@ -239,7 +239,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
239
239
  s.homepage = %q{http://github.com/brynary/webrat}
240
240
  s.require_paths = ["lib"]
241
241
  s.rubyforge_project = %q{webrat}
242
- s.rubygems_version = %q{1.3.5}
242
+ s.rubygems_version = %q{1.3.6}
243
243
  s.summary = %q{Ruby Acceptance Testing for Web applications}
244
244
  s.test_files = [
245
245
  "spec/fakes/test_adapter.rb",
@@ -294,6 +294,7 @@ Most Ruby web frameworks and testing frameworks are supported.}
294
294
  "spec/integration/sinatra/test/test_helper.rb",
295
295
  "spec/private/core/configuration_spec.rb",
296
296
  "spec/private/core/field_spec.rb",
297
+ "spec/private/core/form_spec.rb",
297
298
  "spec/private/core/link_spec.rb",
298
299
  "spec/private/core/session_spec.rb",
299
300
  "spec/private/mechanize/mechanize_adapter_spec.rb",
@@ -338,12 +339,15 @@ Most Ruby web frameworks and testing frameworks are supported.}
338
339
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
339
340
  s.add_runtime_dependency(%q<nokogiri>, [">= 1.2.0"])
340
341
  s.add_runtime_dependency(%q<rack>, [">= 1.0"])
342
+ s.add_runtime_dependency(%q<rack-test>, [">= 0.5.3"])
341
343
  else
342
344
  s.add_dependency(%q<nokogiri>, [">= 1.2.0"])
343
345
  s.add_dependency(%q<rack>, [">= 1.0"])
346
+ s.add_dependency(%q<rack-test>, [">= 0.5.3"])
344
347
  end
345
348
  else
346
349
  s.add_dependency(%q<nokogiri>, [">= 1.2.0"])
347
350
  s.add_dependency(%q<rack>, [">= 1.0"])
351
+ s.add_dependency(%q<rack-test>, [">= 0.5.3"])
348
352
  end
349
353
  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.6.0.10"
5
+ VERSION = "0.7.2.pre"
6
6
 
7
7
  autoload :MechanizeAdapter, "webrat/adapters/mechanize"
8
8
  autoload :MerbAdapter, "webrat/adapters/merb"
@@ -4,6 +4,8 @@ module Webrat #:nodoc:
4
4
  class MechanizeAdapter #:nodoc:
5
5
  extend Forwardable
6
6
 
7
+ Mechanize = WWW::Mechanize if defined?(WWW::Mechanize)
8
+
7
9
  attr_accessor :response
8
10
  alias :page :response
9
11
 
@@ -20,13 +22,19 @@ module Webrat #:nodoc:
20
22
 
21
23
  def post(url, data, headers_argument_not_used = nil)
22
24
  post_data = data.inject({}) do |memo, param|
23
- case param.last
25
+ case param
24
26
  when Hash
25
- param.last.each {|attribute, value| memo["#{param.first}[#{attribute}]"] = value }
26
- else
27
- memo[param.first] = param.last
27
+ param.each {|attribute, value| memo[attribute] = value }
28
+ memo
29
+ when Array
30
+ case param.last
31
+ when Hash
32
+ param.last.each {|attribute, value| memo["#{param.first}[#{attribute}]"] = value }
33
+ else
34
+ memo[param.first] = param.last
35
+ end
36
+ memo
28
37
  end
29
- memo
30
38
  end
31
39
  @response = mechanize.post(url, post_data)
32
40
  end
@@ -39,8 +47,16 @@ module Webrat #:nodoc:
39
47
  @response.code.to_i
40
48
  end
41
49
 
50
+ def response_headers
51
+ @response.header
52
+ end
53
+
42
54
  def mechanize
43
- @mechanize ||= WWW::Mechanize.new
55
+ @mechanize ||= begin
56
+ mechanize = Mechanize.new
57
+ mechanize.redirect_ok = false
58
+ mechanize
59
+ end
44
60
  end
45
61
 
46
62
  def_delegators :mechanize, :basic_auth
@@ -18,6 +18,10 @@ module Webrat
18
18
  response.status
19
19
  end
20
20
 
21
+ def response_headers
22
+ response.headers
23
+ end
24
+
21
25
  def response
22
26
  @session.last_response
23
27
  end
@@ -11,14 +11,6 @@ module Webrat
11
11
  @integration_session = session
12
12
  end
13
13
 
14
- def doc_root
15
- File.expand_path(File.join(RAILS_ROOT, 'public'))
16
- end
17
-
18
- def saved_page_dir
19
- File.expand_path(File.join(RAILS_ROOT, "tmp"))
20
- end
21
-
22
14
  def get(url, data, headers = nil)
23
15
  do_request(:get, url, data, headers)
24
16
  end
@@ -43,6 +35,10 @@ module Webrat
43
35
  response.code.to_i
44
36
  end
45
37
 
38
+ def response_headers
39
+ response.headers
40
+ end
41
+
46
42
  def xml_content_type?
47
43
  response.headers["Content-Type"].to_s =~ /xml/
48
44
  end
@@ -1,4 +1,5 @@
1
1
  require "webrat/core_extensions/deprecate"
2
+ require "pathname"
2
3
 
3
4
  module Webrat
4
5
 
@@ -26,7 +27,10 @@ module Webrat
26
27
  # Save and open pages with error status codes (500-599) in a browser? Defualts to true.
27
28
  attr_writer :open_error_files
28
29
 
29
- # Which rails environment should the selenium tests be run in? Defaults to selenium.
30
+ # Save and open page storage directory, defaults to "tmp" under current directory if exists, otherwise current directory
31
+ attr_accessor :saved_pages_dir
32
+
33
+ # Which rails environment should the selenium tests be run in? Defaults to test.
30
34
  attr_accessor :application_environment
31
35
  webrat_deprecate :selenium_environment, :application_environment
32
36
  webrat_deprecate :selenium_environment=, :application_environment=
@@ -36,6 +40,13 @@ module Webrat
36
40
  webrat_deprecate :selenium_port, :application_port
37
41
  webrat_deprecate :selenium_port=, :application_port=
38
42
 
43
+ # Which port should selenium use to access the application. Defaults to application_port
44
+ attr_writer :application_port_for_selenium
45
+
46
+ def application_port_for_selenium
47
+ @application_port_for_selenium || self.application_port
48
+ end
49
+
39
50
  # Which underlying app framework we're testing with selenium
40
51
  attr_accessor :application_framework
41
52
 
@@ -54,12 +65,16 @@ module Webrat
54
65
  # Set the timeout for waiting for the browser process to start
55
66
  attr_accessor :selenium_browser_startup_timeout
56
67
 
68
+ # Set the firefox profile for selenium to use
69
+ attr_accessor :selenium_firefox_profile
70
+
57
71
  # How many redirects to the same URL should be halted as an infinite redirect
58
72
  # loop? Defaults to 10
59
73
  attr_accessor :infinite_redirect_limit
60
74
 
61
- # How long to wait for Selenium actions unless overridden. Defaults to 10 seconds.
62
- attr_accessor :default_timeout_in_seconds
75
+ # Print out the full HTML on wait failure
76
+ # Defaults to false
77
+ attr_accessor :selenium_verbose_output
63
78
 
64
79
  def initialize # :nodoc:
65
80
  self.open_error_files = true
@@ -72,8 +87,12 @@ module Webrat
72
87
  self.default_timeout_in_seconds = 10
73
88
  self.selenium_browser_key = '*firefox'
74
89
  self.selenium_browser_startup_timeout = 5
75
- end
90
+ self.selenium_verbose_output = false
76
91
 
92
+ tmp_dir = Pathname.new(Dir.pwd).join("tmp")
93
+ self.saved_pages_dir = tmp_dir.exist? ? tmp_dir : Dir.pwd
94
+ end
95
+
77
96
  def open_error_files? #:nodoc:
78
97
  @open_error_files ? true : false
79
98
  end
@@ -1,6 +1,7 @@
1
1
  require "cgi"
2
+ require "digest/md5"
2
3
  require "webrat/core_extensions/blank"
3
- require "webrat/core_extensions/nil_to_param"
4
+ require "webrat/core_extensions/nil_to_query_string"
4
5
 
5
6
  require "webrat/core/elements/element"
6
7
 
@@ -13,7 +14,7 @@ module Webrat
13
14
  attr_reader :value
14
15
 
15
16
  def self.xpath_search
16
- [".//button", ".//input", ".//textarea", ".//select"]
17
+ ".//button|.//input|.//textarea|.//select"
17
18
  end
18
19
 
19
20
  def self.xpath_search_excluding_hidden
@@ -84,19 +85,17 @@ module Webrat
84
85
  raise DisabledFieldError.new("Cannot interact with disabled form element (#{self})")
85
86
  end
86
87
 
87
- def to_param
88
+ def to_query_string
88
89
  return nil if disabled?
89
90
 
90
- params = case Webrat.configuration.mode
91
- when :rails
92
- parse_rails_request_params("#{name}=#{escaped_value}")
93
- when :merb
94
- ::Merb::Parse.query("#{name}=#{escaped_value}")
95
- else
96
- { name => [*@value].first.to_s }
91
+ query_string = case Webrat.configuration.mode
92
+ when :rails, :merb, :rack, :sinatra
93
+ build_query_string
94
+ when :mechanize
95
+ build_query_string(false)
97
96
  end
98
97
 
99
- unescape_params(params)
98
+ query_string
100
99
  end
101
100
 
102
101
  def set(value)
@@ -109,18 +108,6 @@ module Webrat
109
108
 
110
109
  protected
111
110
 
112
- def parse_rails_request_params(params)
113
- if defined?(ActionController::AbstractRequest)
114
- ActionController::AbstractRequest.parse_query_parameters(params)
115
- elsif defined?(ActionController::UrlEncodedPairParser)
116
- # For Rails > 2.2
117
- ActionController::UrlEncodedPairParser.parse_query_parameters(params)
118
- else
119
- # For Rails > 2.3
120
- Rack::Utils.parse_nested_query(params)
121
- end
122
- end
123
-
124
111
  def form
125
112
  Form.load(@session, form_element)
126
113
  end
@@ -138,25 +125,22 @@ module Webrat
138
125
  @element["name"]
139
126
  end
140
127
 
141
- def escaped_value
142
- CGI.escape(@value.to_s)
143
- end
144
-
145
- # Because we have to escape it before sending it to the above case statement,
146
- # we have to make sure we unescape each value when it gets back so assertions
147
- # involving characters like <, >, and & work as expected
148
- def unescape_params(params)
149
- case params.class.name
150
- when 'Hash', 'Mash'
151
- params.each { |key,value| params[key] = unescape_params(value) }
152
- params
153
- when 'Array'
154
- params.collect { |value| unescape_params(value) }
128
+ def build_query_string(escape_value=true)
129
+ if @value.is_a?(Array)
130
+ @value.collect {|value| "#{name}=#{ escape_value ? escape(value) : value }" }.join("&")
155
131
  else
156
- CGI.unescapeHTML(params)
132
+ "#{name}=#{ escape_value ? escape(value) : value }"
157
133
  end
158
134
  end
159
135
 
136
+ def escape(value)
137
+ CGI.escape(value.to_s)
138
+ end
139
+
140
+ def escaped_value
141
+ CGI.escape(@value.to_s)
142
+ end
143
+
160
144
  def labels
161
145
  @labels ||= label_elements.map do |element|
162
146
  Label.load(@session, element)
@@ -186,22 +170,6 @@ module Webrat
186
170
  def default_value
187
171
  @element["value"]
188
172
  end
189
-
190
- def replace_param_value(params, oval, nval)
191
- output = Hash.new
192
- params.each do |key, value|
193
- case value
194
- when Hash
195
- value = replace_param_value(value, oval, nval)
196
- when Array
197
- value = value.map { |o| o == oval ? nval : oval }
198
- when oval
199
- value = nval
200
- end
201
- output[key] = value
202
- end
203
- output
204
- end
205
173
  end
206
174
 
207
175
  class ButtonField < Field #:nodoc:
@@ -210,7 +178,7 @@ module Webrat
210
178
  [".//button", ".//input[@type = 'submit']", ".//input[@type = 'button']", ".//input[@type = 'image']"]
211
179
  end
212
180
 
213
- def to_param
181
+ def to_query_string
214
182
  return nil if @value.nil?
215
183
  super
216
184
  end
@@ -233,13 +201,13 @@ module Webrat
233
201
  ".//input[@type = 'hidden']"
234
202
  end
235
203
 
236
- def to_param
204
+ def to_query_string
237
205
  if collection_name?
238
206
  super
239
207
  else
240
208
  checkbox_with_same_name = form.field_named(name, CheckboxField)
241
209
 
242
- if checkbox_with_same_name.to_param.blank?
210
+ if checkbox_with_same_name.to_query_string.blank?
243
211
  super
244
212
  else
245
213
  nil
@@ -261,7 +229,7 @@ module Webrat
261
229
  ".//input[@type = 'checkbox']"
262
230
  end
263
231
 
264
- def to_param
232
+ def to_query_string
265
233
  return nil if @value.nil?
266
234
  super
267
235
  end
@@ -306,7 +274,7 @@ module Webrat
306
274
  ".//input[@type = 'radio']"
307
275
  end
308
276
 
309
- def to_param
277
+ def to_query_string
310
278
  return nil if @value.nil?
311
279
  super
312
280
  end
@@ -363,30 +331,32 @@ module Webrat
363
331
  attr_accessor :content_type
364
332
 
365
333
  def set(value, content_type = nil)
334
+ @original_value = @value
335
+ @content_type ||= content_type
366
336
  super(value)
367
- @content_type = content_type
368
337
  end
369
338
 
370
- def to_param
371
- if @value.nil?
372
- super
373
- else
374
- replace_param_value(super, @value, test_uploaded_file)
375
- end
339
+ def digest_value
340
+ @value ? Digest::MD5.hexdigest(self.object_id.to_s) : ""
376
341
  end
377
342
 
378
- protected
343
+ def to_query_string
344
+ @value.nil? ? set("") : set(digest_value)
345
+ super
346
+ end
379
347
 
380
348
  def test_uploaded_file
349
+ return "" if @original_value.blank?
350
+
381
351
  case Webrat.configuration.mode
382
352
  when :rails
383
353
  if content_type
384
- ActionController::TestUploadedFile.new(@value, content_type)
354
+ ActionController::TestUploadedFile.new(@original_value, content_type)
385
355
  else
386
- ActionController::TestUploadedFile.new(@value)
356
+ ActionController::TestUploadedFile.new(@original_value)
387
357
  end
388
358
  when :rack, :merb
389
- Rack::Test::UploadedFile.new(@value, content_type)
359
+ Rack::Test::UploadedFile.new(@original_value, content_type)
390
360
  end
391
361
  end
392
362
 
@@ -450,25 +420,6 @@ module Webrat
450
420
  @value.delete(value)
451
421
  end
452
422
 
453
- # We have to overide how the uri string is formed when dealing with multiples
454
- # Where normally a select field might produce name=value with a multiple,
455
- # we need to form something like name[]=value1&name[]=value2
456
- def to_param
457
- return nil if disabled?
458
-
459
- uri_string = @value.collect {|value| "#{name}=#{CGI.escape(value)}"}.join("&")
460
- params = case Webrat.configuration.mode
461
- when :rails
462
- parse_rails_request_params(uri_string)
463
- when :merb
464
- ::Merb::Parse.query(uri_string)
465
- else
466
- { name => @value }
467
- end
468
-
469
- unescape_params(params)
470
- end
471
-
472
423
  protected
473
424
 
474
425
  # Overwrite SelectField definition because we don't want to select the first option