rack

Rails + Rspec + Rack + Session testing

帅比萌擦擦* 提交于 2019-12-06 02:56:51
Gemfile file: 'rack', '~> 1.6.0' I am having little trouble in passing the session variables from rspec tests to the Rack middleware. I have gone through many articles on internet but there is no solution which can help me to understand. So basically i want to be able to do this in my middleware class req = Rack::Request.new(env) req.session[:token] But currently req.session[:token] comes as empty from my rspec. How can I set session in my R spec class so that i can test different scenario's ? Are there any other examples i missed? Thanks in advance.... 来源: https://stackoverflow.com/questions

What is the difference between a Cookie and Redis Session store?

北城余情 提交于 2019-12-06 00:43:52
问题 I want to share sessions among 2 applications on different nodes; however, I am confused what the difference is between Cookie and Redis session stores; e.g. a cookie session might look like this: rack.session=BAh7BkkiD3Nlc3Npb25faWQGOgZFRiJFN2YxZDMxMGE5YTNhZjc2NGM1NDBk%0AMzdiODQ0MjcyMzk5MzAxY2YyYzdhNDMwOWVkMzhiNWVlMmY2N2QwYzExNg%3D%3D%0A--ec4ec7b5a807c806e02e2811f4a11d05877a7698 In Redis, a session-store, might look like this: rack:session

Rails: losing quotes in post parameters

萝らか妹 提交于 2019-12-05 21:43:39
I'm adding full-text search to my Rails site and allowing users to enter double quotes in the search input box. The problem is that the double quotes seem to get filtered out by Mongrel and so I never receive those quotes in the values of the params hash. How do I prevent this from happening? I'm running Rails 2.3.8. [Edit: added analysis data] In Firebug I see the post parameter being posted correctly with quotes: search_criteria "great post" In the development log, however, the quotes are gone: Processing PostsController#search (for 127.0.0.1 at 2010-06-18 17:28:45) [POST] Parameters: {

rack-timeout: turn off info/active logging

扶醉桌前 提交于 2019-12-05 21:15:35
With the rack-timeout gem installed how is it possible to display ERROR only related logs? For example I would like to avoid having the below in my logs: source=rack-timeout id=8a11a8ac3dadb59a4f347d8e365faddf timeout=20000ms service=0ms state=active source=rack-timeout id=8a11a8ac3dadb59a4f347d8e365faddf timeout=20000ms service=49ms state=completed source=rack-timeout id=ee947d4a291d02821ab108c4c127f555 timeout=20000ms state=ready The following did not work: Rack::Timeout.unregister_state_change_observer(:active) The below may be on the right path but I'm having trouble testing: Rack::Timeout

What's the difference between rack app vs. rails app?

梦想与她 提交于 2019-12-05 18:03:54
问题 I uploaded my rails 2.3.8 app to DreamHost and got an error about rack version incompatibility. I issued a support ticket and the service guy recommended that I delete config.ru. That solved the problem. But I wonder what that would affect. Is it ok that a rails app goes without config.ru? 回答1: A Rack app is a web app written in Ruby that uses the Rack project. A really simple Hello World config.ru example is like so: class HelloWorld def call(env) [200, {'Content-Type' => 'text/plain'}, [

How to use Rack map to run two Thin (or other) servers on different ports?

☆樱花仙子☆ 提交于 2019-12-05 18:00:51
My aim is to do some automated testing over HTTP and HTTPS/SSL, via Rack, without recourse to a proxy server setup or anything like that. I have a gem that I want to test and I'd like for others to be able to run tests on too, so I'd like it to be as self contained as possible. The code for App runs fine when run on it's own, so it's not included here, the problem is with the Rack part. I'd like to do something like this: app = Rack::Builder.app do map "/" do Rack::Handler::WEBrick.run App, Port: 3000 end map "/ssl" do Rack::Handler::WEBrick.run App, Port: 3001 # more options for SSL here...

Alter response.body in Rack Middleware

风格不统一 提交于 2019-12-05 12:38:55
I'm trying to write some Rack Middleware for a Rails 4.2 app that alters the response body using the gsub method. I found older examples that use a pattern like this: class MyMiddleware def initialize(app) @app = app end def call(env) status, headers, response = @app.call(env) # do some stuff [status, headers, response] end end What I'm finding is that there is no setter method for response.body . Is there another pattern I can start with to go about modifying the body? The problem was that it expects an Array for the 3rd argument in the call method. This pattern got me working again. # not

How do I create a resque worker automatically at bootup?

一世执手 提交于 2019-12-05 10:52:17
Ok, I'm making my first ruby app. Who know moving everything over to 'production' is so fugging complicated. So far I've struggled my way through configuring passenger, getting it to run on startup, then getting redis to run on startup. My last task is on startup to add 1 worker. Right now, I have to ssh in and run my rake command rake workers:start . Obviously this is no good when I want to close ssh.. so I just dont really know how or what the next step is. I tried copying resque default config to config.ru and it just blows up Passenger with errors. I also looked into resque-pool which some

Rack Error — LoadError: cannot load such file

淺唱寂寞╮ 提交于 2019-12-05 05:25:42
Trying to go through the tekpub rack tutorial but run into this error. Boot Error Something went wrong while loading app.ru LoadError: cannot load such file -- haiku There is a file named haiku.rb in the same directory as the app I am trying to run but I get the above error while trying to run the program. Here is the code: class EnvironmentOutput def initialize(app=nil) @app = app end def call(env) out = "" unless(@app.nil?) response = @app.call(env)[2] out+=response end env.keys.each {|key| out+="<li>#{key}=#{env[key]}</li>"} ["200",{"Content-Type" => "text/html"},[out]] end end require

Reloading rails middleware without restarting the server in development

做~自己de王妃 提交于 2019-12-05 03:42:42
I have a rails 4 app with middleware located at lib/some/middleware.rb which is currently injected into the stack though an initializer like so: MyApp::Application.configure.do |config| config.middleware.use 'Some::Middleware' end Unfortunately, any time I change something I need to restart the server. How can I reload it on each request in development mode? I've seen similar questions about reloading lib code with either autoloading or wrapping code in a to_prepare block but I'm unsure how that could be applied in this scenario. Thanks, - FJM Update #1 If I try to delete the middleware and