Rspec Failing Because Session Is Not Present


first of all, let me congrat for the very cool idea Jets is.

After that, I would like to present an issue here that I am facing when trying to test my “hello-jets” app.
I did non want to open an issue on the Github page because I want not sure that was the right place.

I just want to set up a posts#index route:

jets generate controller posts index --no-helper

Then I add the controller spec:

# spec/controllers/posts_controller_spec.rb

describe PostsController, type: :controller do
  it "index returns a success response" do
    get '/posts'
    expect(response.status).to eq 200

Then I just run:

bundle exec rspec

Here the error:

1) PostsController index returns a success response
     Failure/Error: <%= csrf_meta_tags %>

       undefined method `[]=' for nil:NilClass

It turns out that the issue is session beeing nil in the url_helper.rb


def masked_authenticity_token
  @masked_authenticity_token ||= SecureRandom.hex(32)
  # session is nil !!!!
  session[:authenticity_token] = @masked_authenticity_token

The nice thing is that when running jets server the issue is not present and the index route renders successfuly.

This makes me thing that the issue is somewhere in how the spec set up the request, response.
Indeed the request is not having any session instantiated.

Can anyone replicate the issue ?

Fixed in #331 Released in v2.0.3


I checked your changes.
To be honest i am not sure i get how they fix the issue, but they fix it !!