Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

undefined method `script_name' for nil:NilClass #19

Closed
yuta17 opened this issue Feb 11, 2021 · 2 comments
Closed

undefined method `script_name' for nil:NilClass #19

yuta17 opened this issue Feb 11, 2021 · 2 comments

Comments

@yuta17
Copy link

yuta17 commented Feb 11, 2021

Hi. When I type RAILS_ENV=test OPENAPI=1 bundle exec rspec [spec file path] the following error happens.

  NoMethodError:
    undefined method `script_name' for nil:NilClass
  # /usr/local/bundle/gems/rspec-openapi-0.3.12/lib/rspec/openapi/record_builder.rb:64:in `find_rails_route'
  # /usr/local/bundle/gems/rspec-openapi-0.3.12/lib/rspec/openapi/record_builder.rb:19:in `build'
  # /usr/local/bundle/gems/rspec-openapi-0.3.12/lib/rspec/openapi/hooks.rb:12:in `block in <top (required)>'

The following is the content of the target test file.

require 'rails_helper'

RSpec.describe V2::Admin::NotificationsController, type: :request do
  describe 'GET /v2/admin/notifications' do
    subject { get v2_admin_notifications_url, params: params }
    let!(:users) { create_list(:user) }
    let(:params) { nil }

    it { is_expected.to be 200 }
  end
end

I found that if I do not use create_list, no error occurs.

gem version: 0.3.12

@k0kubun
Copy link
Collaborator

k0kubun commented Feb 12, 2021

What is create_list? I don't think it's a part of rspec-openapi. Could you prepare a repository that reproduces your issue?

@k0kubun
Copy link
Collaborator

k0kubun commented Feb 12, 2021

Although I couldn't test your create_list case, I could figure out a case where the same backtrace happens. I'll release the fix as v0.3.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants