pat / combustion

Simple, elegant testing for Rails Engines
MIT License
708 stars 51 forks source link

Rack linting failure #59

Closed seanlinsley closed 8 years ago

seanlinsley commented 10 years ago

With this added configuration:

class Combustion::Application
  config.middleware.use 'Rack::Lint'
end

We're getting this error: (ref https://github.com/gregbell/arbre/issues/20)

session #<ActionDispatch::Request::Session:0x7fb8fc52cd00 not yet loaded> must respond to store and []=

Rails.root: /Users/seanlinsley/codez/_/gems/arbre/spec/rails/stub_app

rack (1.5.2) lib/rack/lint.rb:20:in `assert'
rack (1.5.2) lib/rack/lint.rb:141:in `check_env'
rack (1.5.2) lib/rack/lint.rb:43:in `_call'
rack (1.5.2) lib/rack/lint.rb:37:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/flash.rb:254:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/cookies.rb:560:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.1.4) lib/active_support/callbacks.rb:82:in `run_callbacks'
actionpack (4.1.4) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.1.4) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.1.4) lib/rails/rack/logger.rb:20:in `block in call'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `block in tagged'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (4.1.4) lib/active_support/tagged_logging.rb:68:in `tagged'
railties (4.1.4) lib/rails/rack/logger.rb:20:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.1.4) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
actionpack (4.1.4) lib/action_dispatch/middleware/static.rb:64:in `call'
rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
railties (4.1.4) lib/rails/engine.rb:514:in `call'
railties (4.1.4) lib/rails/application.rb:144:in `call'
rack-test (0.6.2) lib/rack/mock_session.rb:30:in `request'
rack-test (0.6.2) lib/rack/test.rb:230:in `process_request'
rack-test (0.6.2) lib/rack/test.rb:123:in `request'
actionpack (4.1.4) lib/action_dispatch/testing/integration.rb:309:in `process'
actionpack (4.1.4) lib/action_dispatch/testing/integration.rb:32:in `get'
actionpack (4.1.4) lib/action_dispatch/testing/integration.rb:343:in `block (2 levels) in <module:Runner>'
/Users/seanlinsley/codez/_/gems/arbre/spec/rails/integration/rendering_spec.rb:40:in `block (2 levels) in <top (required)>'
rspec-core (3.0.3) lib/rspec/core/example.rb:148:in `instance_exec'
rspec-core (3.0.3) lib/rspec/core/example.rb:148:in `block in run'
rspec-core (3.0.3) lib/rspec/core/example.rb:210:in `call'
rspec-core (3.0.3) lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
rspec-rails (3.0.2) lib/rspec/rails/adapters.rb:72:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
rspec-core (3.0.3) lib/rspec/core/example.rb:294:in `instance_exec'
rspec-core (3.0.3) lib/rspec/core/example.rb:294:in `instance_exec'
rspec-core (3.0.3) lib/rspec/core/hooks.rb:430:in `block (2 levels) in run'
rspec-core (3.0.3) lib/rspec/core/example.rb:210:in `call'
rspec-core (3.0.3) lib/rspec/core/example.rb:210:in `block (2 levels) in <class:Procsy>'
rspec-core (3.0.3) lib/rspec/core/hooks.rb:432:in `run'
rspec-core (3.0.3) lib/rspec/core/hooks.rb:485:in `run'
rspec-core (3.0.3) lib/rspec/core/example.rb:303:in `with_around_example_hooks'
rspec-core (3.0.3) lib/rspec/core/example.rb:145:in `run'
rspec-core (3.0.3) lib/rspec/core/example_group.rb:494:in `block in run_examples'
rspec-core (3.0.3) lib/rspec/core/example_group.rb:490:in `map'
rspec-core (3.0.3) lib/rspec/core/example_group.rb:490:in `run_examples'
rspec-core (3.0.3) lib/rspec/core/example_group.rb:457:in `run'
rspec-core (3.0.3) lib/rspec/core/runner.rb:112:in `block (2 levels) in run_specs'
rspec-core (3.0.3) lib/rspec/core/runner.rb:112:in `map'
rspec-core (3.0.3) lib/rspec/core/runner.rb:112:in `block in run_specs'
rspec-core (3.0.3) lib/rspec/core/reporter.rb:54:in `report'
rspec-core (3.0.3) lib/rspec/core/runner.rb:108:in `run_specs'
rspec-core (3.0.3) lib/rspec/core/runner.rb:86:in `run'
rspec-core (3.0.3) lib/rspec/core/runner.rb:70:in `run'
rspec-core (3.0.3) lib/rspec/core/runner.rb:38:in `invoke'
rspec-core (3.0.3) exe/rspec:4:in `<top (required)>'

Any idea what the problem is?

pat commented 9 years ago

Sorry, I realise this is months late... I'm not sure what's causing this.

Rack::Lint is expecting rack.session in the request env (which in this case is an instance of ActionDispatch::Request::Session) to respond to store - and it doesn't. I've not yet found where rack.session is actually being set though! No clues in the Rails code from a quick search... hoping someone who understands the internals of Rails a bit better can chime in here.

joost commented 9 years ago

Late to the party, but @pat is right. You could try monkey patching with something like:

class ActionDispatch::Request::Session
  def store(name, value)
    self[name] = value
  end
end