Guest User

Untitled

a guest
Feb 21st, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. diff --git a/merb-core/lib/merb-core/test/helpers/request_helper.rb b/merb-core/lib/merb-core/test/helpers/request_helper.rb
  2. index 7ab15f5..8d00ce3 100644
  3. --- a/merb-core/lib/merb-core/test/helpers/request_helper.rb
  4. +++ b/merb-core/lib/merb-core/test/helpers/request_helper.rb
  5. @@ -37,7 +37,7 @@ module Merb
  6. env["HTTP_COOKIE"] = @__cookie_jar__.for(jar, uri)
  7. end
  8.  
  9. - app = Merb::Rack::Application.new
  10. + app = Merb::Config[:app]
  11. rack = app.call(::Rack::MockRequest.env_for(uri.to_s, env))
  12.  
  13. rack = Struct.new(:status, :headers, :body, :url, :original_env).
  14. diff --git a/merb-core/spec/public/webrat/test_app/config/rack.rb b/merb-core/spec/public/webrat/test_app/config/rack.rb
  15. index 494c687..c7e69fc 100644
  16. --- a/merb-core/spec/public/webrat/test_app/config/rack.rb
  17. +++ b/merb-core/spec/public/webrat/test_app/config/rack.rb
  18. @@ -1,3 +1,20 @@
  19. +# Add an addition Rack middleware for testing whether the Webrat steps go through this.
  20. +module Merb
  21. + module Rack
  22. +
  23. + class DummyWare < Merb::Rack::Middleware
  24. +
  25. + def call(env)
  26. + if env["PATH_INFO"] =~ /^\/dummy/
  27. + [200, "", "This is a dummy content"]
  28. + else
  29. + @app.call(env)
  30. + end
  31. + end
  32. + end
  33. + end
  34. +end
  35. +
  36. # use PathPrefix Middleware if :path_prefix is set in Merb::Config
  37. if prefix = ::Merb::Config[:path_prefix]
  38. use Merb::Rack::PathPrefix, prefix
  39. @@ -6,6 +23,7 @@ end
  40. # comment this out if you are running merb behind a load balancer
  41. # that serves static files
  42. use Merb::Rack::Static, Merb.dir_for(:public)
  43. +use Merb::Rack::DummyWare
  44.  
  45. # this is our main merb application
  46. run Merb::Rack::Application.new
  47. \ No newline at end of file
  48. diff --git a/merb-core/spec/public/webrat/webrat_spec.rb b/merb-core/spec/public/webrat/webrat_spec.rb
  49. index 35e0620..52e4bae 100644
  50. --- a/merb-core/spec/public/webrat/webrat_spec.rb
  51. +++ b/merb-core/spec/public/webrat/webrat_spec.rb
  52. @@ -71,5 +71,12 @@ describe "an app tested using the webrat proxies" do
  53. resp.should have_xpath("//p[contains(., 'truez: 1')]")
  54. end
  55. end
  56. -
  57. +
  58. + describe "runs through defined Rack middle ware" do
  59. + it "returns the response in the rack middleware" do
  60. + resp = visit "/dummy"
  61. + resp.body.should == "This is a dummy content"
  62. + end
  63. + end
  64. +
  65. end
  66. \ No newline at end of file
Add Comment
Please, Sign In to add comment