remi-rackbox 0.0.6 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. data/README.markdown +0 -2
  2. data/VERSION.yml +4 -0
  3. data/lib/rackbox.rb +11 -94
  4. data/lib/rackbox/matchers.rb +17 -0
  5. data/lib/rackbox/{rack_content_length_fix.rb → rack/content_length_fix.rb} +0 -0
  6. data/lib/rackbox/rack/extensions_for_rspec.rb +31 -0
  7. data/lib/rackbox/rack/sticky_sessions.rb +54 -0
  8. data/lib/rackbox/rackbox.rb +35 -0
  9. data/lib/rackbox/spec/configuration.rb +63 -0
  10. data/lib/rackbox/spec/helpers.rb +34 -0
  11. data/lib/rspec/custom_matcher.rb +52 -0
  12. metadata +18 -86
  13. data/examples/rack/config.ru +0 -4
  14. data/examples/rack/run-specs +0 -2
  15. data/examples/rack/spec/blackbox/home_page_spec.rb +0 -14
  16. data/examples/rack/spec/rcov.opts +0 -2
  17. data/examples/rack/spec/spec.opts +0 -4
  18. data/examples/rack/spec/spec_helper.rb +0 -6
  19. data/examples/rails/README +0 -256
  20. data/examples/rails/Rakefile +0 -10
  21. data/examples/rails/app/controllers/application.rb +0 -15
  22. data/examples/rails/app/controllers/welcome_controller.rb +0 -5
  23. data/examples/rails/app/helpers/application_helper.rb +0 -3
  24. data/examples/rails/app/helpers/welcome_helper.rb +0 -2
  25. data/examples/rails/config/boot.rb +0 -109
  26. data/examples/rails/config/environment.rb +0 -75
  27. data/examples/rails/config/environments/development.rb +0 -17
  28. data/examples/rails/config/environments/production.rb +0 -24
  29. data/examples/rails/config/environments/test.rb +0 -22
  30. data/examples/rails/config/initializers/inflections.rb +0 -10
  31. data/examples/rails/config/initializers/mime_types.rb +0 -5
  32. data/examples/rails/config/initializers/new_rails_defaults.rb +0 -17
  33. data/examples/rails/config/locales/en.yml +0 -5
  34. data/examples/rails/config/routes.rb +0 -43
  35. data/examples/rails/db/development.sqlite3 +0 -0
  36. data/examples/rails/db/schema.rb +0 -14
  37. data/examples/rails/db/test.sqlite3 +0 -0
  38. data/examples/rails/doc/README_FOR_APP +0 -5
  39. data/examples/rails/lib/tasks/rspec.rake +0 -158
  40. data/examples/rails/public/404.html +0 -30
  41. data/examples/rails/public/422.html +0 -30
  42. data/examples/rails/public/500.html +0 -33
  43. data/examples/rails/public/dispatch.cgi +0 -10
  44. data/examples/rails/public/dispatch.fcgi +0 -24
  45. data/examples/rails/public/dispatch.rb +0 -10
  46. data/examples/rails/public/favicon.ico +0 -0
  47. data/examples/rails/public/images/rails.png +0 -0
  48. data/examples/rails/public/javascripts/application.js +0 -2
  49. data/examples/rails/public/javascripts/controls.js +0 -963
  50. data/examples/rails/public/javascripts/dragdrop.js +0 -973
  51. data/examples/rails/public/javascripts/effects.js +0 -1128
  52. data/examples/rails/public/javascripts/prototype.js +0 -4320
  53. data/examples/rails/public/robots.txt +0 -5
  54. data/examples/rails/run-specs +0 -2
  55. data/examples/rails/script/about +0 -4
  56. data/examples/rails/script/autospec +0 -5
  57. data/examples/rails/script/console +0 -3
  58. data/examples/rails/script/dbconsole +0 -3
  59. data/examples/rails/script/destroy +0 -3
  60. data/examples/rails/script/generate +0 -3
  61. data/examples/rails/script/performance/benchmarker +0 -3
  62. data/examples/rails/script/performance/profiler +0 -3
  63. data/examples/rails/script/performance/request +0 -3
  64. data/examples/rails/script/plugin +0 -3
  65. data/examples/rails/script/process/inspector +0 -3
  66. data/examples/rails/script/process/reaper +0 -3
  67. data/examples/rails/script/process/spawner +0 -3
  68. data/examples/rails/script/runner +0 -3
  69. data/examples/rails/script/server +0 -3
  70. data/examples/rails/script/spec +0 -5
  71. data/examples/rails/script/spec_server +0 -125
  72. data/examples/rails/spec/blackbox/home_page_spec.rb +0 -21
  73. data/examples/rails/spec/rcov.opts +0 -2
  74. data/examples/rails/spec/spec.opts +0 -4
  75. data/examples/rails/spec/spec_helper.rb +0 -11
  76. data/examples/rails/test/functional/welcome_controller_test.rb +0 -8
  77. data/examples/rails/test/performance/browsing_test.rb +0 -9
  78. data/examples/rails/test/test_helper.rb +0 -38
  79. data/rackbox.gemspec +0 -17
  80. data/run-specs +0 -11
@@ -1,5 +0,0 @@
1
- # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
- #
3
- # To ban all spiders from the entire site uncomment the next two lines:
4
- # User-Agent: *
5
- # Disallow: /
@@ -1,2 +0,0 @@
1
- #! /bin/bash
2
- rake spec
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
4
- require 'commands/about'
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['RSPEC'] = 'true' # allows autotest to discover rspec
3
- ENV['AUTOTEST'] = 'true' # allows autotest to run w/ color on linux
4
- system((RUBY_PLATFORM =~ /mswin|mingw/ ? 'autotest.bat' : 'autotest'), *ARGV) ||
5
- $stderr.puts("Unable to find autotest. Please install ZenTest or fix your PATH")
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/console'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/dbconsole'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/destroy'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/generate'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/benchmarker'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/profiler'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/performance/request'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/plugin'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/inspector'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/reaper'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../../config/boot'
3
- require 'commands/process/spawner'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/runner'
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require File.dirname(__FILE__) + '/../config/boot'
3
- require 'commands/server'
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib"))
3
- require 'rubygems'
4
- require 'spec'
5
- exit ::Spec::Runner::CommandLine.run(::Spec::Runner::OptionParser.parse(ARGV, STDERR, STDOUT))
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env ruby
2
- $LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin
3
- require 'rubygems'
4
- require 'drb/drb'
5
- require 'rbconfig'
6
- require 'spec'
7
- require 'optparse'
8
-
9
- # This is based on Florian Weber's TDDMate
10
- module Spec
11
- module Runner
12
- class RailsSpecServer
13
- def run(argv, stderr, stdout)
14
- $stdout = stdout
15
- $stderr = stderr
16
-
17
- unless ActiveRecord::Base.respond_to?(:clear_reloadable_connections!)
18
- base = ActiveRecord::Base
19
- def base.clear_reloadable_connections!
20
- active_connections.each do |name, conn|
21
- if conn.requires_reloading?
22
- conn.disconnect!
23
- active_connections.delete(name)
24
- end
25
- end
26
- end
27
- end
28
-
29
- ActiveRecord::Base.clear_reloadable_connections!
30
-
31
- if ActionController.const_defined?(:Dispatcher)
32
- dispatcher = ::ActionController::Dispatcher.new($stdout)
33
- dispatcher.cleanup_application
34
- elsif ::Dispatcher.respond_to?(:reset_application!)
35
- ::Dispatcher.reset_application!
36
- else
37
- raise "Application reloading failed"
38
- end
39
- if Object.const_defined?(:Fixtures) && Fixtures.respond_to?(:reset_cache)
40
- Fixtures.reset_cache
41
- end
42
-
43
- if ::ActiveSupport.const_defined?(:Dependencies)
44
- ::ActiveSupport::Dependencies.mechanism = :load
45
- else
46
- ::Dependencies.mechanism = :load
47
- end
48
-
49
- require_dependency('application.rb') unless Object.const_defined?(:ApplicationController)
50
- load File.dirname(__FILE__) + '/../spec/spec_helper.rb'
51
-
52
- if in_memory_database?
53
- load "#{RAILS_ROOT}/db/schema.rb" # use db agnostic schema by default
54
- ActiveRecord::Migrator.up('db/migrate') # use migrations
55
- end
56
-
57
- ::Spec::Runner::CommandLine.run(
58
- ::Spec::Runner::OptionParser.parse(
59
- argv,
60
- $stderr,
61
- $stdout
62
- )
63
- )
64
- end
65
-
66
- def in_memory_database?
67
- ENV["RAILS_ENV"] == "test" and
68
- ::ActiveRecord::Base.connection.class.to_s == "ActiveRecord::ConnectionAdapters::SQLite3Adapter" and
69
- ::Rails::Configuration.new.database_configuration['test']['database'] == ':memory:'
70
- end
71
- end
72
- end
73
- end
74
- puts "Loading Rails environment"
75
-
76
- ENV["RAILS_ENV"] = "test"
77
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
78
- require 'dispatcher'
79
-
80
- def restart_test_server
81
- puts "restarting"
82
- config = ::Config::CONFIG
83
- ruby = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT']
84
- command_line = [ruby, $0, ARGV].flatten.join(' ')
85
- exec(command_line)
86
- end
87
-
88
- def daemonize(pid_file = nil)
89
- return yield if $DEBUG
90
- pid = Process.fork{
91
- Process.setsid
92
- Dir.chdir(RAILS_ROOT)
93
- trap("SIGINT"){ exit! 0 }
94
- trap("SIGTERM"){ exit! 0 }
95
- trap("SIGHUP"){ restart_test_server }
96
- File.open("/dev/null"){|f|
97
- STDERR.reopen f
98
- STDIN.reopen f
99
- STDOUT.reopen f
100
- }
101
- yield
102
- }
103
- puts "spec_server launched. (PID: %d)" % pid
104
- File.open(pid_file,"w"){|f| f.puts pid } if pid_file
105
- exit! 0
106
- end
107
-
108
- options = Hash.new
109
- opts = OptionParser.new
110
- opts.on("-d", "--daemon"){|v| options[:daemon] = true }
111
- opts.on("-p", "--pid PIDFILE"){|v| options[:pid] = v }
112
- opts.parse!(ARGV)
113
-
114
- puts "Ready"
115
- exec_server = lambda {
116
- trap("USR2") { restart_test_server } if Signal.list.has_key?("USR2")
117
- DRb.start_service("druby://127.0.0.1:8989", Spec::Runner::RailsSpecServer.new)
118
- DRb.thread.join
119
- }
120
-
121
- if options[:daemon]
122
- daemonize(options[:pid], &exec_server)
123
- else
124
- exec_server.call
125
- end
@@ -1,21 +0,0 @@
1
- require File.dirname(__FILE__) + '/../spec_helper'
2
-
3
- describe 'Home Page' do
4
-
5
- it 'should say something by itself' do
6
- req( '/' ).body.should include('You said nothing')
7
-
8
- # this works, but you should probably be careful using
9
- # 'request' and 'response' in Rails specs ... ?
10
-
11
- request( '/' ).body.should include('You said nothing')
12
-
13
- response = req( '/' )
14
- response.body.should include('You said nothing')
15
- end
16
-
17
- it 'should say whatever I tell it to' do
18
- req( '/', :method => :post, :params => { :say => 'hello' } ).body.should include('You said hello')
19
- end
20
-
21
- end
@@ -1,2 +0,0 @@
1
- --exclude "spec/*,gems/*"
2
- --rails
@@ -1,4 +0,0 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse
@@ -1,11 +0,0 @@
1
- # This file is copied to ~/spec when you run 'ruby script/generate rspec'
2
- # from the project root directory.
3
- ENV["RAILS_ENV"] = "test"
4
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
5
- require 'spec'
6
- require 'spec/rails'
7
- require File.expand_path(File.dirname(__FILE__) + "/../../../lib/rackbox")
8
-
9
- Spec::Runner.configure do |config|
10
- config.use_blackbox = true
11
- end
@@ -1,8 +0,0 @@
1
- require 'test_helper'
2
-
3
- class WelcomeControllerTest < ActionController::TestCase
4
- # Replace this with your real tests.
5
- test "the truth" do
6
- assert true
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- require 'test_helper'
2
- require 'performance_test_help'
3
-
4
- # Profiling results for each test method are written to tmp/performance.
5
- class BrowsingTest < ActionController::PerformanceTest
6
- def test_homepage
7
- get '/'
8
- end
9
- end
@@ -1,38 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
3
- require 'test_help'
4
-
5
- class Test::Unit::TestCase
6
- # Transactional fixtures accelerate your tests by wrapping each test method
7
- # in a transaction that's rolled back on completion. This ensures that the
8
- # test database remains unchanged so your fixtures don't have to be reloaded
9
- # between every test method. Fewer database queries means faster tests.
10
- #
11
- # Read Mike Clark's excellent walkthrough at
12
- # http://clarkware.com/cgi/blosxom/2005/10/24#Rails10FastTesting
13
- #
14
- # Every Active Record database supports transactions except MyISAM tables
15
- # in MySQL. Turn off transactional fixtures in this case; however, if you
16
- # don't care one way or the other, switching from MyISAM to InnoDB tables
17
- # is recommended.
18
- #
19
- # The only drawback to using transactional fixtures is when you actually
20
- # need to test transactions. Since your test is bracketed by a transaction,
21
- # any transactions started in your code will be automatically rolled back.
22
- self.use_transactional_fixtures = true
23
-
24
- # Instantiated fixtures are slow, but give you @david where otherwise you
25
- # would need people(:david). If you don't want to migrate your existing
26
- # test cases which use the @david style and don't mind the speed hit (each
27
- # instantiated fixtures translates to a database query per test method),
28
- # then set this back to true.
29
- self.use_instantiated_fixtures = false
30
-
31
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
32
- #
33
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
34
- # -- they do not yet inherit this setting
35
- fixtures :all
36
-
37
- # Add more helper methods to be used by all tests here...
38
- end
@@ -1,17 +0,0 @@
1
- Gem::Specification.new do |s|
2
-
3
- s.name = "rackbox"
4
- s.version = "0.0.6"
5
- s.date = "2009-01-21"
6
- s.summary = "Merb-like BlackBox testing for Rack apps, including Rails"
7
- s.email = "remi@remitaylor.com"
8
- s.homepage = "http://github.com/remi/rackbox"
9
- s.description = "Merb-like BlackBox testing for Rack apps, including Rails"
10
- s.has_rdoc = true
11
- s.rdoc_options = ["--quiet", "--title", "RackBox - Merb-like BlackBox testing for Rack apps", "--opname", "index.html", "--line-numbers", "--main", "RackBox", "--inline-source"]
12
- s.authors = ["remi Taylor"]
13
-
14
- # generate using: $ ruby -e "puts Dir['**/**'].select{|x| File.file?x}.inspect" ... remember to set paste!
15
- s.files = ["examples/rack/config.ru", "examples/rack/run-specs", "examples/rack/spec/spec.opts", "examples/rack/spec/spec_helper.rb", "examples/rack/spec/blackbox/home_page_spec.rb", "examples/rack/spec/rcov.opts", "examples/rails/app/controllers/application.rb", "examples/rails/app/controllers/welcome_controller.rb", "examples/rails/app/helpers/application_helper.rb", "examples/rails/app/helpers/welcome_helper.rb", "examples/rails/lib/tasks/rspec.rake", "examples/rails/db/test.sqlite3", "examples/rails/db/development.sqlite3", "examples/rails/db/schema.rb", "examples/rails/log/test.log", "examples/rails/log/development.log", "examples/rails/log/production.log", "examples/rails/log/server.log", "examples/rails/run-specs", "examples/rails/spec/spec.opts", "examples/rails/spec/spec_helper.rb", "examples/rails/spec/blackbox/home_page_spec.rb", "examples/rails/spec/rcov.opts", "examples/rails/doc/README_FOR_APP", "examples/rails/public/dispatch.cgi", "examples/rails/public/dispatch.rb", "examples/rails/public/422.html", "examples/rails/public/images/rails.png", "examples/rails/public/404.html", "examples/rails/public/500.html", "examples/rails/public/robots.txt", "examples/rails/public/favicon.ico", "examples/rails/public/javascripts/prototype.js", "examples/rails/public/javascripts/application.js", "examples/rails/public/javascripts/dragdrop.js", "examples/rails/public/javascripts/controls.js", "examples/rails/public/javascripts/effects.js", "examples/rails/public/dispatch.fcgi", "examples/rails/test/test_helper.rb", "examples/rails/test/functional/welcome_controller_test.rb", "examples/rails/test/performance/browsing_test.rb", "examples/rails/Rakefile", "examples/rails/script/spec_server", "examples/rails/script/autospec", "examples/rails/script/destroy", "examples/rails/script/dbconsole", "examples/rails/script/performance/profiler", "examples/rails/script/performance/request", "examples/rails/script/performance/benchmarker", "examples/rails/script/generate", "examples/rails/script/process/reaper", "examples/rails/script/process/inspector", "examples/rails/script/process/spawner", "examples/rails/script/spec", "examples/rails/script/console", "examples/rails/script/runner", "examples/rails/script/server", "examples/rails/script/plugin", "examples/rails/script/about", "examples/rails/README", "examples/rails/config/boot.rb", "examples/rails/config/locales/en.yml", "examples/rails/config/environments/development.rb", "examples/rails/config/environments/test.rb", "examples/rails/config/environments/production.rb", "examples/rails/config/routes.rb", "examples/rails/config/database.yml", "examples/rails/config/environment.rb", "examples/rails/config/initializers/new_rails_defaults.rb", "examples/rails/config/initializers/mime_types.rb", "examples/rails/config/initializers/inflections.rb", "lib/rackbox/rack_content_length_fix.rb", "lib/rackbox.rb", "README.markdown", "run-specs", "rackbox.gemspec"]
16
-
17
- end
data/run-specs DELETED
@@ -1,11 +0,0 @@
1
- #! /bin/bash
2
- ROOT=$PWD
3
- echo ""
4
- for example in examples/*; do
5
- cd $ROOT
6
- cd $example
7
- echo -e "Running Example: [\e[34m$example\e[37m]... "
8
- echo ""
9
- ./run-specs
10
- echo ""
11
- done