railsware / rack_session_access

Rack middleware that provides access to rack.session environment
MIT License
257 stars 29 forks source link

Capybara::ElementNotFound: Unable to find field "data" while testing Rails Engines #21

Closed onomated closed 9 years ago

onomated commented 9 years ago

I'm having problems getting this to work with Rails Engines even after cross referencing several different resources. I'm getting the following error after making calls to set the rack session like so:

page.set_rack_session('warden.user.user.key' => User.serialize_into_session(user).unshift('User'))

Capybara::ElementNotFound: Unable to find field "data"

This is raised on calling fill_in "data", :with => data

I've confirmed that my dummy engine loads and uses the required middleware:

$ rake RAILS_ENV=test middleware
...
use Rack::ConditionalGet
use Rack::ETag
use Warden::Manager
use RackSessionAccess::Middleware
run TestApp::Application.routes

Anything else I may be missing? Here's my spec software stack:

rails (4.2.3)
rspec-rails (3.3.3)
capybara (2.4.4)
rack_session_access (0.1.1)
ayanko commented 9 years ago

What is your actual full spec example?

onomated commented 9 years ago

Just figured out the issue. I was hardcoding the Capybara app to the Rails engine I was testing so it wasn't targeting the dummy app that had the middleware included. Works like a charm now. Thanks a lot for an awesome gem!