diabolo-webrat 0.4.4.2 → 0.5.1

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 (148) hide show
  1. data/.document +4 -0
  2. data/.gitignore +15 -0
  3. data/History.txt +60 -9
  4. data/Rakefile +90 -75
  5. data/VERSION +1 -0
  6. data/lib/webrat.rb +8 -23
  7. data/lib/webrat/{mechanize.rb → adapters/mechanize.rb} +6 -2
  8. data/lib/webrat/adapters/merb.rb +11 -0
  9. data/lib/webrat/adapters/rack.rb +25 -0
  10. data/lib/webrat/{rails.rb → adapters/rails.rb} +9 -18
  11. data/lib/webrat/adapters/sinatra.rb +9 -0
  12. data/lib/webrat/core.rb +0 -1
  13. data/lib/webrat/core/configuration.rb +7 -17
  14. data/lib/webrat/core/elements/area.rb +2 -2
  15. data/lib/webrat/core/elements/element.rb +3 -3
  16. data/lib/webrat/core/elements/field.rb +33 -30
  17. data/lib/webrat/core/elements/form.rb +4 -4
  18. data/lib/webrat/core/elements/label.rb +4 -4
  19. data/lib/webrat/core/elements/link.rb +7 -6
  20. data/lib/webrat/core/elements/select_option.rb +2 -2
  21. data/lib/webrat/core/locators.rb +1 -1
  22. data/lib/webrat/core/locators/area_locator.rb +3 -3
  23. data/lib/webrat/core/locators/button_locator.rb +6 -6
  24. data/lib/webrat/core/locators/field_by_id_locator.rb +3 -3
  25. data/lib/webrat/core/locators/field_labeled_locator.rb +2 -2
  26. data/lib/webrat/core/locators/field_named_locator.rb +3 -3
  27. data/lib/webrat/core/locators/form_locator.rb +1 -1
  28. data/lib/webrat/core/locators/label_locator.rb +2 -2
  29. data/lib/webrat/core/locators/link_locator.rb +20 -12
  30. data/lib/webrat/core/locators/select_option_locator.rb +5 -5
  31. data/lib/webrat/core/logging.rb +1 -1
  32. data/lib/webrat/core/matchers/have_content.rb +2 -7
  33. data/lib/webrat/core/matchers/have_xpath.rb +2 -27
  34. data/lib/webrat/core/methods.rb +4 -4
  35. data/lib/webrat/core/mime.rb +11 -22
  36. data/lib/webrat/core/save_and_open_page.rb +5 -7
  37. data/lib/webrat/core/scope.rb +2 -2
  38. data/lib/webrat/core/session.rb +30 -14
  39. data/lib/webrat/core/xml.rb +41 -84
  40. data/lib/webrat/integrations/merb.rb +10 -0
  41. data/lib/webrat/integrations/rails.rb +9 -0
  42. data/lib/webrat/integrations/rspec-rails.rb +10 -0
  43. data/lib/webrat/integrations/selenium.rb +11 -0
  44. data/lib/webrat/rspec-rails.rb +2 -13
  45. data/lib/webrat/selenium.rb +0 -11
  46. data/lib/webrat/selenium/application_server_factory.rb +40 -0
  47. data/lib/webrat/selenium/application_servers.rb +5 -0
  48. data/lib/webrat/selenium/application_servers/base.rb +46 -0
  49. data/lib/webrat/selenium/application_servers/external.rb +26 -0
  50. data/lib/webrat/selenium/application_servers/merb.rb +50 -0
  51. data/lib/webrat/selenium/application_servers/rails.rb +44 -0
  52. data/lib/webrat/selenium/application_servers/sinatra.rb +37 -0
  53. data/lib/webrat/selenium/location_strategy_javascript/label.js +2 -1
  54. data/lib/webrat/selenium/selenium_rc_server.rb +7 -5
  55. data/lib/webrat/selenium/selenium_session.rb +20 -7
  56. data/lib/webrat/selenium/silence_stream.rb +1 -1
  57. data/spec/fakes/{test_session.rb → test_adapter.rb} +6 -3
  58. data/spec/integration/mechanize/Rakefile +7 -0
  59. data/spec/integration/mechanize/config.ru +2 -0
  60. data/spec/integration/mechanize/sample_app.rb +20 -0
  61. data/spec/integration/mechanize/spec/mechanize_spec.rb +22 -0
  62. data/spec/integration/mechanize/spec/spec_helper.rb +27 -0
  63. data/spec/integration/merb/.gitignore +21 -0
  64. data/spec/integration/merb/Rakefile +35 -0
  65. data/spec/integration/merb/app/controllers/testing.rb +9 -0
  66. data/spec/integration/merb/app/views/exceptions/not_acceptable.html.erb +63 -0
  67. data/spec/integration/merb/app/views/exceptions/not_found.html.erb +47 -0
  68. data/spec/integration/merb/app/views/layout/application.html.erb +12 -0
  69. data/spec/integration/merb/app/views/testing/show_form.html.erb +27 -0
  70. data/spec/integration/merb/app/views/testing/upload.html.erb +9 -0
  71. data/spec/integration/merb/config/router.rb +1 -0
  72. data/spec/integration/merb/spec/spec.opts +1 -0
  73. data/spec/integration/merb/spec/spec_helper.rb +2 -0
  74. data/spec/integration/merb/spec/webrat_spec.rb +7 -0
  75. data/spec/integration/merb/tasks/merb.thor/main.thor +150 -0
  76. data/spec/integration/rack/Rakefile +5 -0
  77. data/spec/integration/rack/app.rb +89 -0
  78. data/spec/integration/rack/test/helper.rb +21 -0
  79. data/spec/integration/rack/test/webrat_rack_test.rb +57 -51
  80. data/spec/integration/rails/.gitignore +3 -0
  81. data/spec/integration/rails/Rakefile +30 -0
  82. data/spec/integration/rails/app/controllers/webrat_controller.rb +13 -9
  83. data/spec/integration/rails/app/views/buttons/show.html.erb +11 -0
  84. data/spec/integration/rails/app/views/fields/show.html.erb +9 -0
  85. data/spec/integration/rails/app/views/links/show.html.erb +5 -0
  86. data/spec/integration/rails/app/views/webrat/before_redirect_form.html.erb +4 -0
  87. data/spec/integration/rails/app/views/webrat/buttons.html.erb +11 -0
  88. data/spec/integration/rails/app/views/webrat/form.html.erb +28 -0
  89. data/spec/integration/rails/config/locales/en.yml +5 -0
  90. data/spec/integration/rails/config/routes.rb +1 -0
  91. data/spec/integration/rails/public/404.html +30 -0
  92. data/spec/integration/rails/public/422.html +30 -0
  93. data/spec/integration/rails/public/500.html +33 -0
  94. data/spec/integration/rails/script/about +4 -0
  95. data/spec/integration/rails/script/console +3 -0
  96. data/spec/integration/rails/script/dbconsole +3 -0
  97. data/spec/integration/rails/script/destroy +3 -0
  98. data/spec/integration/rails/script/generate +3 -0
  99. data/spec/integration/rails/script/performance/benchmarker +3 -0
  100. data/spec/integration/rails/script/performance/profiler +3 -0
  101. data/spec/integration/rails/script/performance/request +3 -0
  102. data/spec/integration/rails/script/plugin +3 -0
  103. data/spec/integration/rails/script/process/inspector +3 -0
  104. data/spec/integration/rails/script/process/reaper +3 -0
  105. data/spec/integration/rails/script/process/spawner +3 -0
  106. data/spec/integration/rails/script/runner +3 -0
  107. data/spec/integration/rails/script/server +3 -0
  108. data/spec/integration/rails/test/integration/button_click_test.rb +2 -2
  109. data/spec/integration/rails/test/integration/link_click_test.rb +7 -1
  110. data/spec/integration/rails/test/integration/webrat_test.rb +22 -0
  111. data/spec/integration/rails/test/test_helper.rb +6 -5
  112. data/spec/integration/sinatra/Rakefile +5 -0
  113. data/spec/integration/sinatra/test/test_helper.rb +3 -2
  114. data/spec/private/core/configuration_spec.rb +8 -27
  115. data/spec/private/core/field_spec.rb +7 -7
  116. data/spec/private/core/link_spec.rb +1 -1
  117. data/spec/private/core/session_spec.rb +23 -21
  118. data/spec/private/mechanize/{mechanize_session_spec.rb → mechanize_adapter_spec.rb} +4 -12
  119. data/spec/private/nokogiri_spec.rb +2 -2
  120. data/spec/private/rails/{rails_session_spec.rb → rails_adapter_spec.rb} +16 -16
  121. data/spec/private/selenium/application_servers/rails_spec.rb +26 -0
  122. data/spec/public/matchers/contain_spec.rb +4 -4
  123. data/spec/public/matchers/have_selector_spec.rb +2 -2
  124. data/spec/public/matchers/have_xpath_spec.rb +3 -3
  125. data/spec/public/save_and_open_spec.rb +25 -6
  126. data/spec/public/selenium/application_server_factory_spec.rb +49 -0
  127. data/spec/public/selenium/application_servers/external_spec.rb +12 -0
  128. data/spec/public/selenium/selenium_session_spec.rb +37 -0
  129. data/spec/rcov.opts +1 -0
  130. data/spec/spec.opts +2 -0
  131. data/spec/spec_helper.rb +5 -1
  132. data/vendor/selenium-server.jar +0 -0
  133. data/webrat.gemspec +348 -0
  134. metadata +176 -23
  135. data/lib/webrat/core/xml/hpricot.rb +0 -19
  136. data/lib/webrat/core/xml/nokogiri.rb +0 -76
  137. data/lib/webrat/core/xml/rexml.rb +0 -24
  138. data/lib/webrat/merb_session.rb +0 -65
  139. data/lib/webrat/rack.rb +0 -24
  140. data/lib/webrat/rack_test.rb +0 -32
  141. data/lib/webrat/selenium/application_server.rb +0 -73
  142. data/lib/webrat/selenium/merb_application_server.rb +0 -48
  143. data/lib/webrat/selenium/rails_application_server.rb +0 -42
  144. data/lib/webrat/selenium/sinatra_application_server.rb +0 -35
  145. data/lib/webrat/sinatra.rb +0 -44
  146. data/spec/integration/rack/rack_app.rb +0 -16
  147. data/spec/integration/rack/test/test_helper.rb +0 -20
  148. data/spec/private/merb/merb_session_spec.rb +0 -42
@@ -0,0 +1,12 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
3
+ <head>
4
+ <title>Fresh Merb App</title>
5
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
6
+ <link rel="stylesheet" href="/stylesheets/master.css" type="text/css" media="screen" charset="utf-8" />
7
+ </head>
8
+ <body>
9
+ <%#= message[:notice] %>
10
+ <%= catch_content :for_layout %>
11
+ </body>
12
+ </html>
@@ -0,0 +1,27 @@
1
+ <h1>Webrat Form</h1>
2
+
3
+ <form action="/testing/submit_form" method="post">
4
+ <label>
5
+ Text field
6
+ <input type="text" name="text_field" />
7
+ </label>
8
+
9
+ <label>
10
+ TOS <input type="checkbox" name="tos" />
11
+ </label>
12
+
13
+ <label>
14
+ Prefilled
15
+ <input type="text" name="prefilled" value="text" />
16
+ </label>
17
+
18
+ <label>
19
+ Month
20
+ <select name="month">
21
+ <option>None</option>
22
+ <option>January</option>
23
+ </select>
24
+ </label>
25
+
26
+ <input type="submit" value="Test">
27
+ </form>
@@ -0,0 +1,9 @@
1
+ <h1>Webrat Form</h1>
2
+
3
+ <form action="/upload" method="post">
4
+ <label>
5
+ File
6
+ <input type="file" name="uploaded_file" />
7
+ </label>
8
+ <input type="submit" value="Upload">
9
+ </form>
@@ -28,6 +28,7 @@
28
28
  Merb.logger.info("Compiling routes...")
29
29
  Merb::Router.prepare do
30
30
  match("/").to(:controller => "testing", :action => "show_form")
31
+ match("/upload").to(:controller => "testing", :action => "upload")
31
32
  match("/internal_redirect").to(:controller => "testing", :action => "internal_redirect")
32
33
  match("/external_redirect").to(:controller => "testing", :action => "external_redirect")
33
34
  end
@@ -0,0 +1 @@
1
+ --color
@@ -1,5 +1,7 @@
1
1
  require "rubygems"
2
2
 
3
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/../../../../lib"
4
+
3
5
  # Add the local gems dir if found within the app root; any dependencies loaded
4
6
  # hereafter will try to load from the local gems before loading system gems.
5
7
  if (local_gem_dir = File.join(File.dirname(__FILE__), '..', 'gems')) && $BUNDLE.nil?
@@ -29,4 +29,11 @@ describe "Webrat" do
29
29
  response = visit "/external_redirect"
30
30
  response.status.should == 302
31
31
  end
32
+
33
+ it "should upload files" do
34
+ visit "/upload"
35
+ attach_file "File", __FILE__
36
+ response = click_button "Upload"
37
+ response.should contain(%(["webrat_spec.rb", "Tempfile"]))
38
+ end
32
39
  end
@@ -0,0 +1,150 @@
1
+ require "rubygems"
2
+ require "rubygems/source_index"
3
+ require "rubygems/dependency_installer"
4
+ require "rubygems/uninstaller"
5
+ require "fileutils"
6
+ require File.join(File.dirname(__FILE__), "utils")
7
+ require File.join(File.dirname(__FILE__), "gem_ext")
8
+ require File.join(File.dirname(__FILE__), "ops")
9
+
10
+ $INSTALLING = []
11
+
12
+ module Merb
13
+
14
+ class Gem < Thor
15
+ extend ColorfulMessages
16
+
17
+ def initialize
18
+ dirs = [Dir.pwd, File.dirname(__FILE__) / ".."]
19
+ root = dirs.find {|d| File.file?(d / "config" / "dependencies.rb")}
20
+
21
+ if root
22
+ @depsrb = root / "config" / "dependencies.rb"
23
+ else
24
+ self.class.error "dependencies.rb was not found"
25
+ exit!
26
+ end
27
+
28
+ FileUtils.mkdir_p(Dir.pwd / "gems")
29
+
30
+ @list = Collector.collect(File.read(@depsrb))
31
+ @idx = ::Gem::SourceIndex.new.load_gems_in("gems/specifications")
32
+ end
33
+
34
+ def list
35
+ require "pp"
36
+ pp @list
37
+ end
38
+
39
+ desc "redeploy", "Syncs up gems/cache with gems/gems. All gems in the cache " \
40
+ "that are not already installed will be installed from the " \
41
+ "cache. All installed gems that are not in the cache will " \
42
+ "be uninstalled."
43
+ def redeploy
44
+ gem_dir = Dir.pwd / "gems" / "gems"
45
+ cache_dir = Dir.pwd / "gems" / "cache"
46
+
47
+ gems = Dir[gem_dir / "*"].map! {|n| File.basename(n)}
48
+ cache = Dir[cache_dir / "*.gem"].map! {|n| File.basename(n, ".gem")}
49
+ new_gems = cache - gems
50
+ outdated = gems - cache
51
+ idx = ::Gem::SourceIndex.new
52
+ idx.load_gems_in(Dir.pwd / "gems" / "specifications")
53
+
54
+ new_gems.each do |g|
55
+ installer = ::Gem::Installer.new(cache_dir / "#{g}.gem",
56
+ :bin_dir => Dir.pwd / "bin",
57
+ :install_dir => Dir.pwd / "gems",
58
+ :ignore_dependencies => true,
59
+ :user_install => false,
60
+ :wrappers => true,
61
+ :source_index => idx)
62
+
63
+ installer.install
64
+ end
65
+
66
+ outdated.each do |g|
67
+ /(.*)\-(.*)/ =~ g
68
+ name, version = $1, $2
69
+ uninstaller = ::Gem::Uninstaller.new(name,
70
+ :version => version,
71
+ :bin_dir => Dir.pwd / "bin",
72
+ :install_dir => Dir.pwd / "gems",
73
+ :ignore => true,
74
+ :executables => true
75
+ )
76
+ uninstaller.uninstall
77
+ end
78
+ end
79
+
80
+ desc "confirm", "Confirm the current setup. merb:gem:install will " \
81
+ "automatically run this task before committing the " \
82
+ "changes it makes."
83
+ def confirm(gems = @list)
84
+ ::Gem.path.replace([Dir.pwd / "gems"])
85
+ ::Gem.source_index.load_gems_in(Dir.pwd / "gems" / "specifications")
86
+
87
+ self.class.info "Confirming configuration..."
88
+
89
+ ::Gem.loaded_specs.clear
90
+
91
+ begin
92
+ gems.each do |name, versions|
93
+ versions ||= []
94
+ ::Gem.activate name, *versions
95
+ end
96
+ rescue ::Gem::LoadError => e
97
+ self.class.error "Configuration could not be confirmed: #{e.message}"
98
+ self.class.rollback_trans
99
+ end
100
+ self.class.info "Confirmed"
101
+ end
102
+
103
+ desc 'install', 'Sync up your bundled gems with the list in config/dependencies.rb'
104
+ def install(*gems)
105
+ if gems.empty?
106
+ gems = @list
107
+ else
108
+ gems = gems.map {|desc| name, *versions = desc.split(" ") }
109
+ end
110
+
111
+ $GEMS = gems
112
+
113
+ self.class.begin_trans
114
+
115
+ gems.each do |name, versions|
116
+ dep = ::Gem::Dependency.new(name, versions || [])
117
+ unless @idx.search(dep).empty?
118
+ next
119
+ end
120
+
121
+ rescue_failures do
122
+ $INSTALLING = []
123
+ _install(dep)
124
+ end
125
+ end
126
+
127
+ gem_dir = Dir.pwd / "gems" / "gems"
128
+ installed_gems = Dir[gem_dir / "*"].map! {|n| File.basename(n)}
129
+
130
+ list = full_list.map {|x| x.full_name}.compact
131
+
132
+ (installed_gems - list).each do |g|
133
+ /^(.*)\-(.*)$/ =~ g
134
+ name, version = $1, $2
135
+ uninstaller = ::Gem::Uninstaller.new(name,
136
+ :version => version,
137
+ :bin_dir => (Dir.pwd / "bin").to_s,
138
+ :install_dir => (Dir.pwd / "gems").to_s,
139
+ :ignore => true,
140
+ :executables => true
141
+ )
142
+ uninstaller.uninstall
143
+ end
144
+
145
+ confirm(gems)
146
+
147
+ self.class.commit_trans
148
+ end
149
+ end
150
+ end
@@ -0,0 +1,5 @@
1
+ require "rake/testtask"
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.test_files = FileList["test/*_test.rb"]
5
+ end
@@ -0,0 +1,89 @@
1
+ require "rubygems"
2
+ require "sinatra/base"
3
+
4
+ class RackApp < Sinatra::Base
5
+ use_in_file_templates!
6
+
7
+ get "/" do
8
+ erb :home
9
+ end
10
+
11
+ get "/go" do
12
+ erb :go
13
+ end
14
+
15
+ get "/internal_redirect" do
16
+ redirect "/"
17
+ end
18
+
19
+ get "/external_redirect" do
20
+ redirect "http://google.com"
21
+ end
22
+
23
+ get "/absolute_redirect" do
24
+ redirect URI.join(request.url, "foo").to_s
25
+ end
26
+
27
+ get "/foo" do
28
+ "spam"
29
+ end
30
+
31
+ post "/go" do
32
+ @user = params[:name]
33
+ @email = params[:email]
34
+ erb :hello
35
+ end
36
+
37
+ get "/upload" do
38
+ erb :uploader
39
+ end
40
+
41
+ post "/upload" do
42
+ params[:uploaded_file].to_yaml
43
+ end
44
+ end
45
+
46
+ __END__
47
+ @@ layout
48
+ <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
49
+ <html>
50
+ <title>sinatra testing with webrat</title>
51
+ <body>
52
+ <%= yield %>
53
+ </body>
54
+ </html>
55
+
56
+ @@ home
57
+ <p> visit <a href="/go">there</a></p>
58
+
59
+ <form>
60
+ <label>
61
+ Prefilled
62
+ <input type="text" name="prefilled" value="text" />
63
+ </label>
64
+ </form>
65
+
66
+ @@ go
67
+ <form method="post" action="/go">
68
+ <div>
69
+ <label for="name">Name</label>
70
+ <input type="text" name="name" id="name">
71
+ </div>
72
+ <div>
73
+ <label for="email">Email</label>
74
+ <input type="text" name="email" id="email">
75
+ </div>
76
+ <input type="submit" value="Submit" />
77
+ </form>
78
+
79
+ @@ hello
80
+ <p>Hello, <%= @user %></p>
81
+ <p>Your email is: <%= @email %></p>
82
+
83
+ @@ uploader
84
+ <form action="/upload" method="post">
85
+ <label>
86
+ File <input type="file" name="uploaded_file" />
87
+ </label>
88
+ <input type="submit" value="Upload">
89
+ </form>
@@ -0,0 +1,21 @@
1
+ require "rubygems"
2
+ require "test/unit"
3
+ require "rack/test"
4
+ # require "redgreen"
5
+
6
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/../../../../lib"
7
+ require "webrat"
8
+ require File.dirname(__FILE__) + "/../app"
9
+
10
+ Webrat.configure do |config|
11
+ config.mode = :rack
12
+ end
13
+
14
+ class Test::Unit::TestCase
15
+ def app
16
+ Rack::Builder.new {
17
+ use Rack::Lint
18
+ run RackApp.new
19
+ }
20
+ end
21
+ end
@@ -1,67 +1,73 @@
1
- require File.dirname(__FILE__) + "/test_helper"
2
- require File.dirname(__FILE__) + "/../rack_app"
1
+ require File.dirname(__FILE__) + "/helper"
3
2
 
4
3
  class WebratRackTest < Test::Unit::TestCase
5
- def test_visit_returns_response
6
- response = visit "/"
7
- assert response.ok?
4
+ include Rack::Test::Methods
5
+ include Webrat::Methods
6
+ include Webrat::Matchers
7
+ include Webrat::HaveTagMatcher
8
+
9
+ def build_rack_mock_session
10
+ Rack::MockSession.new(app, "www.example.com")
8
11
  end
9
12
 
10
- def test_last_response_is_available
11
- visit "/"
12
- assert last_response.ok?
13
+ def test_visits_pages
14
+ visit "/"
15
+ click_link "there"
16
+
17
+ assert_have_tag("form[@method='post'][@action='/go']")
13
18
  end
14
19
 
15
- def test_last_request_is_available
20
+ def test_submits_form
21
+ visit "/go"
22
+ fill_in "Name", :with => "World"
23
+ fill_in "Email", :with => "world@example.org"
24
+ click_button "Submit"
25
+
26
+ assert_contain "Hello, World"
27
+ assert_contain "Your email is: world@example.org"
28
+ end
29
+
30
+ def test_check_value_of_field
16
31
  visit "/"
17
- assert_equal "/", last_request.env["PATH_INFO"]
32
+ assert_equal field_labeled("Prefilled").value, "text"
18
33
  end
19
34
 
20
- def test_redirects
21
- visit "/redirect_absolute_url"
22
- assert_equal "spam", response_body
35
+ def test_follows_internal_redirects
36
+ visit "/internal_redirect"
37
+ assert_contain "visit"
23
38
  end
24
39
 
25
- def test_assertions_after_visit
26
- visit "/"
27
- assert_contain "Hello World"
40
+ def test_does_not_follow_external_redirects
41
+ visit "/external_redirect"
42
+ assert last_response.redirect?
28
43
  end
29
44
 
30
- def test_assertions_after_visit
31
- get "/"
32
- assert_contain "Hello World"
45
+ def test_absolute_url_redirect
46
+ visit "/absolute_redirect"
47
+ assert_contain "spam"
33
48
  end
34
49
 
35
- # def test_visits_pages
36
- # visit "/"
37
- # assert response_body.include?("visit")
38
- #
39
- # click_link "there"
40
- # assert response_body.include?('<form method="post" action="/go">')
41
- # end
42
- #
43
- # def test_submits_form
44
- # visit "/go"
45
- # fill_in "Name", :with => "World"
46
- # fill_in "Email", :with => "world@example.org"
47
- # click_button "Submit"
48
- #
49
- # assert response_body.include?("Hello, World")
50
- # assert response_body.include?("Your email is: world@example.org")
51
- # end
52
- #
53
- # def test_check_value_of_field
54
- # visit "/"
55
- # assert field_labeled("Prefilled").value, "text"
56
- # end
57
- #
58
- # def test_follows_internal_redirects
59
- # visit "/internal_redirect"
60
- # assert response_body.include?("visit")
61
- # end
62
- #
63
- # def test_does_not_follow_external_redirects
64
- # visit "/external_redirect"
65
- # assert response_code == 302
66
- # end
50
+ def test_upload_file
51
+ visit "/upload"
52
+ attach_file "File", __FILE__, "text/ruby"
53
+ click_button "Upload"
54
+
55
+ upload = YAML.load(response_body)
56
+ assert_equal "text/ruby", upload[:type]
57
+ assert_equal "webrat_rack_test.rb", upload[:filename]
58
+ assert upload[:tempfile].respond_to?(:read)
59
+ end
60
+ end
61
+
62
+ class WebratRackSetupTest < Test::Unit::TestCase
63
+ def test_usable_without_mixin
64
+ rack_test_session = Rack::Test::Session.new(Rack::MockSession.new(app))
65
+ adapter = Webrat::RackAdapter.new(rack_test_session)
66
+ session = Webrat::Session.new(adapter)
67
+
68
+ session.visit "/foo"
69
+
70
+ assert_equal "spam", session.response_body
71
+ assert_equal "spam", rack_test_session.last_response.body
72
+ end
67
73
  end