webrat 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/History.txt +11 -0
  2. data/Rakefile +18 -2
  3. data/VERSION +1 -1
  4. data/lib/webrat.rb +1 -0
  5. data/lib/webrat/core/configuration.rb +1 -1
  6. data/lib/webrat/core/elements/field.rb +2 -0
  7. data/lib/webrat/core/methods.rb +5 -5
  8. data/lib/webrat/core/mime.rb +11 -22
  9. data/lib/webrat/core/session.rb +19 -13
  10. data/lib/webrat/mechanize.rb +5 -1
  11. data/lib/webrat/{merb_session.rb → merb_adapter.rb} +2 -2
  12. data/lib/webrat/rack.rb +1 -1
  13. data/lib/webrat/rails.rb +1 -1
  14. data/lib/webrat/sinatra.rb +1 -1
  15. data/spec/fakes/{test_session.rb → test_adapter.rb} +6 -3
  16. data/spec/integration/mechanize/Rakefile +7 -0
  17. data/spec/integration/mechanize/config.ru +2 -0
  18. data/spec/integration/mechanize/sample_app.rb +20 -0
  19. data/spec/integration/mechanize/spec/mechanize_spec.rb +22 -0
  20. data/spec/integration/mechanize/spec/spec_helper.rb +27 -0
  21. data/spec/integration/merb/spec/spec_helper.rb +2 -0
  22. data/spec/integration/rack/app.rb +16 -0
  23. data/spec/integration/rack/test/helper.rb +2 -1
  24. data/spec/integration/rack/test/webrat_rack_test.rb +12 -1
  25. data/spec/integration/rails/test/test_helper.rb +2 -1
  26. data/spec/integration/sinatra/test/test_helper.rb +2 -1
  27. data/spec/private/core/configuration_spec.rb +2 -2
  28. data/spec/private/core/link_spec.rb +1 -1
  29. data/spec/private/core/session_spec.rb +5 -0
  30. data/spec/private/mechanize/{mechanize_session_spec.rb → mechanize_adapter_spec.rb} +4 -10
  31. data/spec/private/merb/{merb_session_spec.rb → merb_adapter_spec.rb} +5 -5
  32. data/spec/private/rails/{rails_session_spec.rb → rails_adapter_spec.rb} +14 -14
  33. data/spec/spec_helper.rb +1 -1
  34. data/webrat.gemspec +28 -11
  35. metadata +36 -12
data/History.txt CHANGED
@@ -1,3 +1,14 @@
1
+ == 0.5.1 / 2009-08-18
2
+
3
+ * Minor enhancements
4
+
5
+ * Base Webrat::MIME on Rack::Mime (Simon Rozet)
6
+ * Support file uploads in Rack mode (Simon Rozet)
7
+
8
+ * Bug fixes
9
+
10
+ * Fix bug in Webrat::Methods preventing Selenium mode from working [#277]
11
+
1
12
  == 0.5.0 / 2009-08-12
2
13
 
3
14
  * Major enhancements
data/Rakefile CHANGED
@@ -7,13 +7,21 @@ begin
7
7
  s.email = "bryan" + "@" + "brynary.com"
8
8
  s.homepage = "http://github.com/brynary/webrat"
9
9
  s.summary = "Ruby Acceptance Testing for Web applications"
10
- # s.description = "TODO"
10
+ s.description = <<-EOS.strip
11
+ Webrat lets you quickly write expressive and robust acceptance tests
12
+ for a Ruby web application. It supports simulating a browser inside
13
+ a Ruby process to avoid the performance hit and browser dependency of
14
+ Selenium or Watir, but the same API can also be used to drive real
15
+ Selenium tests when necessary (eg. for testing AJAX interactions).
16
+ Most Ruby web frameworks and testing frameworks are supported.
17
+ EOS
11
18
 
12
19
  s.rubyforge_project = "webrat"
13
20
  s.extra_rdoc_files = %w[README.rdoc MIT-LICENSE.txt History.txt]
14
21
 
15
22
  # Dependencies
16
23
  s.add_dependency "nokogiri", ">= 1.2.0"
24
+ s.add_dependency "rack", ">= 1.0"
17
25
 
18
26
  # TODO: Add development dependencies
19
27
  end
@@ -105,7 +113,7 @@ end
105
113
 
106
114
  namespace :spec do
107
115
  desc "Run the integration specs"
108
- task :integration => ["integration:rails", "integration:merb", "integration:sinatra", "integration:rack"]
116
+ task :integration => ["integration:rails", "integration:merb", "integration:sinatra", "integration:rack", "integration:mechanize"]
109
117
 
110
118
  namespace :integration do
111
119
  desc "Run the Rails integration specs"
@@ -150,6 +158,14 @@ namespace :spec do
150
158
  raise "Rack integration tests failed" unless result
151
159
  end
152
160
  end
161
+
162
+ desc "Run the Mechanize integration specs"
163
+ task :mechanize do
164
+ Dir.chdir "spec/integration/mechanize" do
165
+ result = system "rake spec"
166
+ raise "Mechanize integration tests failed" unless result
167
+ end
168
+ end
153
169
  end
154
170
  end
155
171
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.0
1
+ 0.5.1
data/lib/webrat.rb CHANGED
@@ -4,6 +4,7 @@ module Webrat
4
4
  end
5
5
  end
6
6
 
7
+ require "rack"
7
8
  require "nokogiri"
8
9
  require "webrat/core/xml/nokogiri"
9
10
  require "webrat/core"
@@ -91,7 +91,7 @@ module Webrat
91
91
  # with Merb 1.0.8 until it's updated to use the new Webrat.configure
92
92
  # syntax
93
93
  if @mode == :merb
94
- require("webrat/merb_session")
94
+ require("webrat/merb_adapter")
95
95
  else
96
96
  require("webrat/#{mode}")
97
97
  end
@@ -366,6 +366,8 @@ module Webrat
366
366
  when :merb
367
367
  # TODO: support content_type
368
368
  File.new(@value)
369
+ when :rack
370
+ Rack::Test::UploadedFile.new(@value, content_type)
369
371
  end
370
372
  end
371
373
 
@@ -16,11 +16,11 @@ module Webrat
16
16
  end
17
17
 
18
18
  def webrat_session
19
- @_webrat_session ||= ::Webrat::Session.new(webrat_adapter)
20
- end
21
-
22
- def webrat_adapter
23
- @_webrat_adapter ||= Webrat.session_class.new(self)
19
+ @_webrat_session ||= begin
20
+ session = Webrat.session_class.new
21
+ session.adapter = Webrat.adapter_class.new(self) if session.respond_to?(:adapter=)
22
+ session
23
+ end
24
24
  end
25
25
 
26
26
  # all of these methods delegate to the @session, which should
@@ -1,29 +1,18 @@
1
1
  module Webrat #:nodoc:
2
2
  module MIME #:nodoc:
3
+ MIME_TYPES = Rack::Mime::MIME_TYPES.dup.merge(
4
+ ".multipart_form" => "multipart/form-data",
5
+ ".url_encoded_form" => "application/x-www-form-urlencoded"
6
+ ).freeze
3
7
 
4
- def self.mime_type(string_or_symbol) #:nodoc:
5
- if string_or_symbol.is_a?(String)
6
- string_or_symbol
7
- else
8
- case string_or_symbol
9
- when :text then "text/plain"
10
- when :html then "text/html"
11
- when :js then "text/javascript"
12
- when :css then "text/css"
13
- when :ics then "text/calendar"
14
- when :csv then "text/csv"
15
- when :xml then "application/xml"
16
- when :rss then "application/rss+xml"
17
- when :atom then "application/atom+xml"
18
- when :yaml then "application/x-yaml"
19
- when :multipart_form then "multipart/form-data"
20
- when :url_encoded_form then "application/x-www-form-urlencoded"
21
- when :json then "application/json"
22
- else
23
- raise ArgumentError.new("Invalid Mime type: #{string_or_symbol.inspect}")
24
- end
25
- end
8
+ def mime_type(type)
9
+ return type if type.nil? || type.to_s.include?("/")
10
+ type = ".#{type}" unless type.to_s[0] == ?.
11
+ MIME_TYPES.fetch(type) { |type|
12
+ raise ArgumentError.new("Invalid Mime type: #{type}")
13
+ }
26
14
  end
27
15
 
16
+ module_function :mime_type
28
17
  end
29
18
  end
@@ -13,26 +13,30 @@ module Webrat
13
13
  end
14
14
 
15
15
  def self.session_class
16
+ if Webrat.configuration.mode == :selenium
17
+ SeleniumSession
18
+ else
19
+ Session
20
+ end
21
+ end
22
+
23
+ def self.adapter_class
16
24
  case Webrat.configuration.mode
17
25
  when :rails
18
- RailsSession
26
+ RailsAdapter
19
27
  when :merb
20
- MerbSession
28
+ MerbAdapter
21
29
  when :rack
22
- RackSession
30
+ RackAdapter
23
31
  when :rack_test
24
32
  warn("The :rack_test mode is deprecated. Please use :rack instead")
25
33
  require "webrat/rack"
26
- RackSession
34
+ RackAdapter
27
35
  when :sinatra
28
36
  warn("The :sinatra mode is deprecated. Please use :rack instead")
29
- SinatraSession
30
- when :selenium
31
- SeleniumSession
32
- when :sinatra
33
- SinatraSession
37
+ SinatraAdapter
34
38
  when :mechanize
35
- MechanizeSession
39
+ MechanizeAdapter
36
40
  else
37
41
  raise WebratError.new(<<-STR)
38
42
  Unknown Webrat mode: #{Webrat.configuration.mode.inspect}
@@ -55,6 +59,9 @@ For example:
55
59
  extend Forwardable
56
60
  include Logging
57
61
  include SaveAndOpenPage
62
+
63
+ attr_accessor :adapter
64
+
58
65
  attr_reader :current_url
59
66
  attr_reader :elements
60
67
 
@@ -62,13 +69,12 @@ For example:
62
69
  :response_body=, :response_code=,
63
70
  :get, :post, :put, :delete
64
71
 
65
- def initialize(adapter=nil)
72
+ def initialize(adapter = nil)
73
+ @adapter = adapter
66
74
  @http_method = :get
67
75
  @data = {}
68
76
  @default_headers = {}
69
77
  @custom_headers = {}
70
- @adapter = adapter
71
-
72
78
  reset
73
79
  end
74
80
 
@@ -1,11 +1,15 @@
1
1
  require "mechanize"
2
2
 
3
3
  module Webrat #:nodoc:
4
- class MechanizeSession < Session #:nodoc:
4
+ class MechanizeAdapter #:nodoc:
5
+ extend Forwardable
5
6
 
6
7
  attr_accessor :response
7
8
  alias :page :response
8
9
 
10
+ def initialize(*args)
11
+ end
12
+
9
13
  def request_page(url, http_method, data) #:nodoc:
10
14
  super(absolute_url(url), http_method, data)
11
15
  end
@@ -3,7 +3,7 @@ require "merb-core"
3
3
  require "webrat/merb_multipart_support"
4
4
 
5
5
  module Webrat
6
- class MerbSession #:nodoc:
6
+ class MerbAdapter #:nodoc:
7
7
  include Merb::Test::MakeRequest
8
8
 
9
9
  # Include Webrat's own version of multipart_post/put because the officially
@@ -74,7 +74,7 @@ module Merb #:nodoc:
74
74
  module Test #:nodoc:
75
75
  module RequestHelper #:nodoc:
76
76
  def request(uri, env = {})
77
- @_webrat_session ||= Webrat::MerbSession.new
77
+ @_webrat_session ||= Webrat::MerbAdapter.new
78
78
  @_webrat_session.response = @_webrat_session.request(uri, env)
79
79
  end
80
80
  end
data/lib/webrat/rack.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require "rack/test"
2
2
 
3
3
  module Webrat
4
- class RackSession
4
+ class RackAdapter
5
5
  extend Forwardable
6
6
 
7
7
  def_delegators :@session, :get, :post, :put, :delete
data/lib/webrat/rails.rb CHANGED
@@ -5,7 +5,7 @@ require "action_controller/integration"
5
5
  require "action_controller/record_identifier"
6
6
 
7
7
  module Webrat
8
- class RailsSession #:nodoc:
8
+ class RailsAdapter #:nodoc:
9
9
  include ActionController::RecordIdentifier
10
10
 
11
11
  attr_reader :integration_session
@@ -1,7 +1,7 @@
1
1
  require "webrat/rack"
2
2
 
3
3
  module Webrat
4
- class SinatraSession < RackSession
4
+ class SinatraAdapter < RackAdapter
5
5
  def initialize(context)
6
6
  app = context.respond_to?(:app) ? context.app : Sinatra::Application
7
7
 
@@ -1,12 +1,15 @@
1
1
  module Webrat #:nodoc:
2
- def self.session_class #:nodoc:
3
- TestSession
2
+ def self.adapter_class #:nodoc:
3
+ TestAdapter
4
4
  end
5
5
 
6
- class TestSession < Session #:nodoc:
6
+ class TestAdapter #:nodoc:
7
7
  attr_accessor :response_body
8
8
  attr_writer :response_code
9
9
 
10
+ def initialize(*args)
11
+ end
12
+
10
13
  def doc_root
11
14
  File.expand_path(File.join(".", "public"))
12
15
  end
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'spec/rake/spectask'
3
+
4
+ Spec::Rake::SpecTask.new do |t|
5
+ t.spec_opts = ['--color']
6
+ t.spec_files = FileList['spec/**/*_spec.rb']
7
+ end
@@ -0,0 +1,2 @@
1
+ require "sample_app"
2
+ run SampleApp
@@ -0,0 +1,20 @@
1
+ require "rubygems"
2
+ require "sinatra/base"
3
+
4
+ class SampleApp < Sinatra::Default
5
+ get "/" do
6
+ "Hello World"
7
+ end
8
+
9
+ get "/internal_redirect" do
10
+ redirect URI.join(request.url, "redirected").to_s
11
+ end
12
+
13
+ get "/external_redirect" do
14
+ redirect "http://example.tst/"
15
+ end
16
+
17
+ get "/redirected" do
18
+ "Redirected"
19
+ end
20
+ end
@@ -0,0 +1,22 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ describe "Webrat's Mechanize mode" do
4
+ it "should work" do
5
+ response = visit("http://localhost:9292/")
6
+ response.should contain("Hello World")
7
+ end
8
+
9
+ it "should follow redirects" do
10
+ response = visit("http://localhost:9292/internal_redirect")
11
+ response.should contain("Redirected")
12
+ end
13
+
14
+ it "should follow links"
15
+ it "should submit forms"
16
+ it "should not follow external redirects" do
17
+ pending do
18
+ response = visit("http://localhost:9292/external_redirect")
19
+ response.should contain("Foo")
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,27 @@
1
+ require "rubygems"
2
+ require "spec"
3
+
4
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/../../../../lib"
5
+ require "webrat"
6
+
7
+ Webrat.configure do |config|
8
+ config.mode = :mechanize
9
+ end
10
+
11
+ Spec::Runner.configure do |config|
12
+ config.include Webrat::Methods
13
+ config.include Webrat::Matchers
14
+
15
+ config.before :suite do
16
+ if File.exists?("rack.pid")
17
+ Process.kill("TERM", File.read("rack.pid").to_i)
18
+ end
19
+
20
+ system "rackup --daemonize --pid rack.pid config.ru"
21
+ end
22
+
23
+ config.after :suite do
24
+ Process.kill("TERM", File.read("rack.pid").to_i)
25
+ end
26
+ end
27
+
@@ -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?
@@ -33,6 +33,14 @@ class RackApp < Sinatra::Base
33
33
  @email = params[:email]
34
34
  erb :hello
35
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
36
44
  end
37
45
 
38
46
  __END__
@@ -71,3 +79,11 @@ __END__
71
79
  @@ hello
72
80
  <p>Hello, <%= @user %></p>
73
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>
@@ -3,7 +3,8 @@ require "test/unit"
3
3
  require "rack/test"
4
4
  # require "redgreen"
5
5
 
6
- require File.dirname(__FILE__) + "/../../../../lib/webrat"
6
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/../../../../lib"
7
+ require "webrat"
7
8
  require File.dirname(__FILE__) + "/../app"
8
9
 
9
10
  Webrat.configure do |config|
@@ -46,12 +46,23 @@ class WebratRackTest < Test::Unit::TestCase
46
46
  visit "/absolute_redirect"
47
47
  assert_contain "spam"
48
48
  end
49
+
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
49
60
  end
50
61
 
51
62
  class WebratRackSetupTest < Test::Unit::TestCase
52
63
  def test_usable_without_mixin
53
64
  rack_test_session = Rack::Test::Session.new(Rack::MockSession.new(app))
54
- adapter = Webrat::RackSession.new(rack_test_session)
65
+ adapter = Webrat::RackAdapter.new(rack_test_session)
55
66
  session = Webrat::Session.new(adapter)
56
67
 
57
68
  session.visit "/foo"
@@ -7,7 +7,8 @@ require 'test_help'
7
7
  # rescue MissingSourceFile
8
8
  # end
9
9
 
10
- require File.dirname(__FILE__) + "/../../../../lib/webrat"
10
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/../../../../lib"
11
+ require "webrat"
11
12
 
12
13
  Webrat.configure do |config|
13
14
  config.mode = ENV['WEBRAT_INTEGRATION_MODE'].to_sym
@@ -2,7 +2,8 @@ require "rubygems"
2
2
  require "test/unit"
3
3
  # require "redgreen"
4
4
 
5
- require File.dirname(__FILE__) + "/../../../../lib/webrat"
5
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/../../../../lib"
6
+ require "webrat"
6
7
 
7
8
  Webrat.configure do |config|
8
9
  config.mode = :sinatra
@@ -68,9 +68,9 @@ describe Webrat::Configuration do
68
68
  end
69
69
  end
70
70
 
71
- it "should require merb_session when in merb mode" do
71
+ it "should require merb_adapter when in merb mode" do
72
72
  config = Webrat::Configuration.new
73
- config.should_receive(:require).with("webrat/merb_session")
73
+ config.should_receive(:require).with("webrat/merb_adapter")
74
74
  config.mode = :merb
75
75
  end
76
76
 
@@ -4,7 +4,7 @@ describe Webrat::Link do
4
4
  # include Webrat::Link
5
5
 
6
6
  before do
7
- webrat_session = mock(Webrat::TestSession)
7
+ webrat_session = mock(Webrat::TestAdapter)
8
8
  @link_text_with_nbsp = 'Link' + [0xA0].pack("U") + 'Text'
9
9
  end
10
10
 
@@ -62,6 +62,11 @@ describe Webrat::Session do
62
62
  it "should raise an error if a symbol Mime type is passed that does not exist" do
63
63
  lambda { webrat_session.http_accept(:oogabooga) }.should raise_error(ArgumentError)
64
64
  end
65
+
66
+ it "should recognize a couple of webrat-specific formats" do
67
+ webrat_session.http_accept(:multipart_form).should == "multipart/form-data"
68
+ webrat_session.http_accept(:url_encoded_form).should == "application/x-www-form-urlencoded"
69
+ end
65
70
  end
66
71
 
67
72
  describe "#request_page" do
@@ -2,19 +2,13 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  require "webrat/mechanize"
4
4
 
5
- describe Webrat::MechanizeSession do
5
+ describe Webrat::MechanizeAdapter do
6
6
  before :each do
7
7
  Webrat.configuration.mode = :mechanize
8
8
  end
9
9
 
10
10
  before(:each) do
11
- @mech = Webrat::MechanizeSession.new
12
- end
13
-
14
- describe "headers method" do
15
- it "should return empty headers for a newly initialized session" do
16
- @mech.headers.should == {}
17
- end
11
+ @mech = Webrat::MechanizeAdapter.new
18
12
  end
19
13
 
20
14
  describe "post" do
@@ -34,13 +28,13 @@ describe Webrat::MechanizeSession do
34
28
  mechanize = mock(:mechanize)
35
29
  WWW::Mechanize.stub!(:new => mechanize)
36
30
  mechanize.should_receive(:post).with(url, flattened_data)
37
- Webrat::MechanizeSession.new.post(url, data)
31
+ Webrat::MechanizeAdapter.new.post(url, data)
38
32
  end
39
33
  end
40
34
 
41
35
  describe "#absolute_url" do
42
36
  before(:each) do
43
- @session = Webrat::MechanizeSession.new
37
+ @session = Webrat::MechanizeAdapter.new
44
38
  @session.stub!(:current_url).and_return(absolute_url)
45
39
  end
46
40
 
@@ -2,9 +2,9 @@ require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper")
2
2
 
3
3
  require "webrat/merb"
4
4
 
5
- describe Webrat::MerbSession do
5
+ describe Webrat::MerbAdapter do
6
6
  it "should not pass empty params if data is and empty hash" do
7
- session = Webrat::MerbSession.new
7
+ session = Webrat::MerbAdapter.new
8
8
  response = OpenStruct.new
9
9
  response.status = 200
10
10
  session.should_receive(:request).with('url', {:params=> nil, :method=>"GET", :headers=>nil}).and_return(response)
@@ -13,7 +13,7 @@ describe Webrat::MerbSession do
13
13
 
14
14
  %w{post put delete}.each do |request_method|
15
15
  it "should call do request with method #{request_method.upcase} for a #{request_method} call" do
16
- session = Webrat::MerbSession.new
16
+ session = Webrat::MerbAdapter.new
17
17
  response = OpenStruct.new
18
18
  response.status = 200
19
19
 
@@ -24,7 +24,7 @@ describe Webrat::MerbSession do
24
24
 
25
25
  %w{post put}.each do |request_method|
26
26
  it "should call do request with method #{request_method.upcase} with a file attachment" do
27
- session = Webrat::MerbSession.new
27
+ session = Webrat::MerbAdapter.new
28
28
  response = OpenStruct.new
29
29
  response.status = 200
30
30
 
@@ -43,7 +43,7 @@ describe Webrat::MerbSession do
43
43
 
44
44
  context "a session with a response" do
45
45
  before do
46
- @session = Webrat::MerbSession.new
46
+ @session = Webrat::MerbAdapter.new
47
47
  @response = OpenStruct.new
48
48
  @response.status = 200
49
49
  @response.body = 'test response'
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
2
2
 
3
3
  require "webrat/rails"
4
4
 
5
- describe Webrat::RailsSession do
5
+ describe Webrat::RailsAdapter do
6
6
  before :each do
7
7
  Webrat.configuration.mode = :rails
8
8
  @integration_session = mock("integration_session")
@@ -10,35 +10,35 @@ describe Webrat::RailsSession do
10
10
 
11
11
  it "should delegate response_body to the session response body" do
12
12
  @integration_session.stub!(:response => mock("response", :body => "<html>"))
13
- Webrat::RailsSession.new(@integration_session).response_body.should == "<html>"
13
+ Webrat::RailsAdapter.new(@integration_session).response_body.should == "<html>"
14
14
  end
15
15
 
16
16
  it "should delegate response_code to the session response code" do
17
17
  @integration_session.stub!(:response => mock("response", :code => "42"))
18
- Webrat::RailsSession.new(@integration_session).response_code.should == 42
18
+ Webrat::RailsAdapter.new(@integration_session).response_code.should == 42
19
19
  end
20
20
 
21
21
  it "should delegate get to the integration session" do
22
22
  @integration_session.should_receive(:get).with("url", "data", "headers")
23
- rails_session = Webrat::RailsSession.new(@integration_session)
23
+ rails_session = Webrat::RailsAdapter.new(@integration_session)
24
24
  rails_session.get("url", "data", "headers")
25
25
  end
26
26
 
27
27
  it "should delegate post to the integration session" do
28
28
  @integration_session.should_receive(:post).with("url", "data", "headers")
29
- rails_session = Webrat::RailsSession.new(@integration_session)
29
+ rails_session = Webrat::RailsAdapter.new(@integration_session)
30
30
  rails_session.post("url", "data", "headers")
31
31
  end
32
32
 
33
33
  it "should delegate put to the integration session" do
34
34
  @integration_session.should_receive(:put).with("url", "data", "headers")
35
- rails_session = Webrat::RailsSession.new(@integration_session)
35
+ rails_session = Webrat::RailsAdapter.new(@integration_session)
36
36
  rails_session.put("url", "data", "headers")
37
37
  end
38
38
 
39
39
  it "should delegate delete to the integration session" do
40
40
  @integration_session.should_receive(:delete).with("url", "data", "headers")
41
- rails_session = Webrat::RailsSession.new(@integration_session)
41
+ rails_session = Webrat::RailsAdapter.new(@integration_session)
42
42
  rails_session.delete("url", "data", "headers")
43
43
  end
44
44
 
@@ -46,7 +46,7 @@ describe Webrat::RailsSession do
46
46
  it "should pass the full url" do
47
47
  @integration_session.stub!(:https!)
48
48
  @integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers")
49
- rails_session = Webrat::RailsSession.new(@integration_session)
49
+ rails_session = Webrat::RailsAdapter.new(@integration_session)
50
50
  rails_session.get("http://www.example.com/url", "data", "headers")
51
51
  end
52
52
  end
@@ -55,7 +55,7 @@ describe Webrat::RailsSession do
55
55
  it "should call #https! with true before the request before passing along the full url" do
56
56
  @integration_session.should_receive(:https!).with(true)
57
57
  @integration_session.should_receive(:get).with("https://www.example.com/url", "data", "headers")
58
- rails_session = Webrat::RailsSession.new(@integration_session)
58
+ rails_session = Webrat::RailsAdapter.new(@integration_session)
59
59
  rails_session.get("https://www.example.com/url", "data", "headers")
60
60
  end
61
61
  end
@@ -64,7 +64,7 @@ describe Webrat::RailsSession do
64
64
  it "should call #https! with true before the request" do
65
65
  @integration_session.stub!(:get)
66
66
  @integration_session.should_receive(:https!).with(false)
67
- rails_session = Webrat::RailsSession.new(@integration_session)
67
+ rails_session = Webrat::RailsAdapter.new(@integration_session)
68
68
  rails_session.get("http://www.example.com/url", "data", "headers")
69
69
  end
70
70
  end
@@ -73,17 +73,17 @@ describe Webrat::RailsSession do
73
73
  it "should strip out the anchor" do
74
74
  @integration_session.should_receive(:https!).with(false)
75
75
  @integration_session.should_receive(:get).with("http://www.example.com/url", "data", "headers")
76
- rails_session = Webrat::RailsSession.new(@integration_session)
76
+ rails_session = Webrat::RailsAdapter.new(@integration_session)
77
77
  rails_session.get("http://www.example.com/url#foo", "data", "headers")
78
78
  end
79
79
  end
80
80
 
81
81
  it "should provide a saved_page_dir" do
82
- Webrat::RailsSession.new(mock("integration session")).should respond_to(:saved_page_dir)
82
+ Webrat::RailsAdapter.new(mock("integration session")).should respond_to(:saved_page_dir)
83
83
  end
84
84
 
85
85
  it "should provide a doc_root" do
86
- Webrat::RailsSession.new(mock("integration session")).should respond_to(:doc_root)
86
+ Webrat::RailsAdapter.new(mock("integration session")).should respond_to(:doc_root)
87
87
  end
88
88
 
89
89
  it "should accept an ActiveRecord argument to #within and translate to a selector using dom_id" do
@@ -100,7 +100,7 @@ describe Webrat::RailsSession do
100
100
  @integration_session.stub!(:response => response)
101
101
  @integration_session.should_receive(:get).with("/page2", {}, nil)
102
102
 
103
- rails_session = Webrat::RailsSession.new(@integration_session)
103
+ rails_session = Webrat::RailsAdapter.new(@integration_session)
104
104
 
105
105
  object = Object.new
106
106
  object.stub!(:id => nil)
data/spec/spec_helper.rb CHANGED
@@ -11,7 +11,7 @@ $LOAD_PATH.unshift(webrat_path) unless $LOAD_PATH.include?(webrat_path)
11
11
  AssertionFailedError = Test::Unit::AssertionFailedError rescue MiniTest::Assertion # ruby1.9 compat
12
12
 
13
13
  require "webrat"
14
- require File.expand_path(File.dirname(__FILE__) + "/fakes/test_session")
14
+ require File.expand_path(File.dirname(__FILE__) + "/fakes/test_adapter")
15
15
 
16
16
  module Webrat
17
17
  @@previous_config = nil
data/webrat.gemspec CHANGED
@@ -5,11 +5,17 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{webrat}
8
- s.version = "0.5.0"
8
+ s.version = "0.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bryan Helmkamp"]
12
- s.date = %q{2009-08-12}
12
+ s.date = %q{2009-08-18}
13
+ s.description = %q{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.}
13
19
  s.email = %q{bryan@brynary.com}
14
20
  s.extra_rdoc_files = [
15
21
  "History.txt",
@@ -70,8 +76,8 @@ Gem::Specification.new do |s|
70
76
  "lib/webrat/core_extensions/tcp_socket.rb",
71
77
  "lib/webrat/mechanize.rb",
72
78
  "lib/webrat/merb.rb",
79
+ "lib/webrat/merb_adapter.rb",
73
80
  "lib/webrat/merb_multipart_support.rb",
74
- "lib/webrat/merb_session.rb",
75
81
  "lib/webrat/rack.rb",
76
82
  "lib/webrat/rails.rb",
77
83
  "lib/webrat/rspec-rails.rb",
@@ -99,7 +105,12 @@ Gem::Specification.new do |s|
99
105
  "lib/webrat/selenium/selenium_session.rb",
100
106
  "lib/webrat/selenium/silence_stream.rb",
101
107
  "lib/webrat/sinatra.rb",
102
- "spec/fakes/test_session.rb",
108
+ "spec/fakes/test_adapter.rb",
109
+ "spec/integration/mechanize/Rakefile",
110
+ "spec/integration/mechanize/config.ru",
111
+ "spec/integration/mechanize/sample_app.rb",
112
+ "spec/integration/mechanize/spec/mechanize_spec.rb",
113
+ "spec/integration/mechanize/spec/spec_helper.rb",
103
114
  "spec/integration/merb/.gitignore",
104
115
  "spec/integration/merb/Rakefile",
105
116
  "spec/integration/merb/app/controllers/application.rb",
@@ -188,12 +199,12 @@ Gem::Specification.new do |s|
188
199
  "spec/private/core/link_spec.rb",
189
200
  "spec/private/core/logging_spec.rb",
190
201
  "spec/private/core/session_spec.rb",
191
- "spec/private/mechanize/mechanize_session_spec.rb",
202
+ "spec/private/mechanize/mechanize_adapter_spec.rb",
192
203
  "spec/private/merb/attaches_file_spec.rb",
193
- "spec/private/merb/merb_session_spec.rb",
204
+ "spec/private/merb/merb_adapter_spec.rb",
194
205
  "spec/private/nokogiri_spec.rb",
195
206
  "spec/private/rails/attaches_file_spec.rb",
196
- "spec/private/rails/rails_session_spec.rb",
207
+ "spec/private/rails/rails_adapter_spec.rb",
197
208
  "spec/private/selenium/application_servers/rails_spec.rb",
198
209
  "spec/public/basic_auth_spec.rb",
199
210
  "spec/public/check_spec.rb",
@@ -235,7 +246,10 @@ Gem::Specification.new do |s|
235
246
  s.rubygems_version = %q{1.3.4}
236
247
  s.summary = %q{Ruby Acceptance Testing for Web applications}
237
248
  s.test_files = [
238
- "spec/fakes/test_session.rb",
249
+ "spec/fakes/test_adapter.rb",
250
+ "spec/integration/mechanize/sample_app.rb",
251
+ "spec/integration/mechanize/spec/mechanize_spec.rb",
252
+ "spec/integration/mechanize/spec/spec_helper.rb",
239
253
  "spec/integration/merb/app/controllers/application.rb",
240
254
  "spec/integration/merb/app/controllers/exceptions.rb",
241
255
  "spec/integration/merb/app/controllers/testing.rb",
@@ -287,12 +301,12 @@ Gem::Specification.new do |s|
287
301
  "spec/private/core/link_spec.rb",
288
302
  "spec/private/core/logging_spec.rb",
289
303
  "spec/private/core/session_spec.rb",
290
- "spec/private/mechanize/mechanize_session_spec.rb",
304
+ "spec/private/mechanize/mechanize_adapter_spec.rb",
291
305
  "spec/private/merb/attaches_file_spec.rb",
292
- "spec/private/merb/merb_session_spec.rb",
306
+ "spec/private/merb/merb_adapter_spec.rb",
293
307
  "spec/private/nokogiri_spec.rb",
294
308
  "spec/private/rails/attaches_file_spec.rb",
295
- "spec/private/rails/rails_session_spec.rb",
309
+ "spec/private/rails/rails_adapter_spec.rb",
296
310
  "spec/private/selenium/application_servers/rails_spec.rb",
297
311
  "spec/public/basic_auth_spec.rb",
298
312
  "spec/public/check_spec.rb",
@@ -330,10 +344,13 @@ Gem::Specification.new do |s|
330
344
 
331
345
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
332
346
  s.add_runtime_dependency(%q<nokogiri>, [">= 1.2.0"])
347
+ s.add_runtime_dependency(%q<rack>, [">= 1.0"])
333
348
  else
334
349
  s.add_dependency(%q<nokogiri>, [">= 1.2.0"])
350
+ s.add_dependency(%q<rack>, [">= 1.0"])
335
351
  end
336
352
  else
337
353
  s.add_dependency(%q<nokogiri>, [">= 1.2.0"])
354
+ s.add_dependency(%q<rack>, [">= 1.0"])
338
355
  end
339
356
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webrat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Helmkamp
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-12 00:00:00 -04:00
12
+ date: 2009-08-18 00:00:00 -04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -22,7 +22,23 @@ dependencies:
22
22
  - !ruby/object:Gem::Version
23
23
  version: 1.2.0
24
24
  version:
25
- description:
25
+ - !ruby/object:Gem::Dependency
26
+ name: rack
27
+ type: :runtime
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "1.0"
34
+ version:
35
+ description: |-
36
+ Webrat lets you quickly write expressive and robust acceptance tests
37
+ for a Ruby web application. It supports simulating a browser inside
38
+ a Ruby process to avoid the performance hit and browser dependency of
39
+ Selenium or Watir, but the same API can also be used to drive real
40
+ Selenium tests when necessary (eg. for testing AJAX interactions).
41
+ Most Ruby web frameworks and testing frameworks are supported.
26
42
  email: bryan@brynary.com
27
43
  executables: []
28
44
 
@@ -86,8 +102,8 @@ files:
86
102
  - lib/webrat/core_extensions/tcp_socket.rb
87
103
  - lib/webrat/mechanize.rb
88
104
  - lib/webrat/merb.rb
105
+ - lib/webrat/merb_adapter.rb
89
106
  - lib/webrat/merb_multipart_support.rb
90
- - lib/webrat/merb_session.rb
91
107
  - lib/webrat/rack.rb
92
108
  - lib/webrat/rails.rb
93
109
  - lib/webrat/rspec-rails.rb
@@ -115,7 +131,12 @@ files:
115
131
  - lib/webrat/selenium/selenium_session.rb
116
132
  - lib/webrat/selenium/silence_stream.rb
117
133
  - lib/webrat/sinatra.rb
118
- - spec/fakes/test_session.rb
134
+ - spec/fakes/test_adapter.rb
135
+ - spec/integration/mechanize/Rakefile
136
+ - spec/integration/mechanize/config.ru
137
+ - spec/integration/mechanize/sample_app.rb
138
+ - spec/integration/mechanize/spec/mechanize_spec.rb
139
+ - spec/integration/mechanize/spec/spec_helper.rb
119
140
  - spec/integration/merb/.gitignore
120
141
  - spec/integration/merb/Rakefile
121
142
  - spec/integration/merb/app/controllers/application.rb
@@ -204,12 +225,12 @@ files:
204
225
  - spec/private/core/link_spec.rb
205
226
  - spec/private/core/logging_spec.rb
206
227
  - spec/private/core/session_spec.rb
207
- - spec/private/mechanize/mechanize_session_spec.rb
228
+ - spec/private/mechanize/mechanize_adapter_spec.rb
208
229
  - spec/private/merb/attaches_file_spec.rb
209
- - spec/private/merb/merb_session_spec.rb
230
+ - spec/private/merb/merb_adapter_spec.rb
210
231
  - spec/private/nokogiri_spec.rb
211
232
  - spec/private/rails/attaches_file_spec.rb
212
- - spec/private/rails/rails_session_spec.rb
233
+ - spec/private/rails/rails_adapter_spec.rb
213
234
  - spec/private/selenium/application_servers/rails_spec.rb
214
235
  - spec/public/basic_auth_spec.rb
215
236
  - spec/public/check_spec.rb
@@ -272,7 +293,10 @@ signing_key:
272
293
  specification_version: 3
273
294
  summary: Ruby Acceptance Testing for Web applications
274
295
  test_files:
275
- - spec/fakes/test_session.rb
296
+ - spec/fakes/test_adapter.rb
297
+ - spec/integration/mechanize/sample_app.rb
298
+ - spec/integration/mechanize/spec/mechanize_spec.rb
299
+ - spec/integration/mechanize/spec/spec_helper.rb
276
300
  - spec/integration/merb/app/controllers/application.rb
277
301
  - spec/integration/merb/app/controllers/exceptions.rb
278
302
  - spec/integration/merb/app/controllers/testing.rb
@@ -324,12 +348,12 @@ test_files:
324
348
  - spec/private/core/link_spec.rb
325
349
  - spec/private/core/logging_spec.rb
326
350
  - spec/private/core/session_spec.rb
327
- - spec/private/mechanize/mechanize_session_spec.rb
351
+ - spec/private/mechanize/mechanize_adapter_spec.rb
328
352
  - spec/private/merb/attaches_file_spec.rb
329
- - spec/private/merb/merb_session_spec.rb
353
+ - spec/private/merb/merb_adapter_spec.rb
330
354
  - spec/private/nokogiri_spec.rb
331
355
  - spec/private/rails/attaches_file_spec.rb
332
- - spec/private/rails/rails_session_spec.rb
356
+ - spec/private/rails/rails_adapter_spec.rb
333
357
  - spec/private/selenium/application_servers/rails_spec.rb
334
358
  - spec/public/basic_auth_spec.rb
335
359
  - spec/public/check_spec.rb