-
-
Notifications
You must be signed in to change notification settings - Fork 465
Open
Description
Hi,
I'm trying to use Clearance::BackDoor on my requests specs that use rswag gem.
My sample test is:
require 'swagger_helper'
RSpec.describe 'api/v1/animals', type: :request do
let!(:customer) { create(:customer) }
before do
visit session_path(as: customer)
end
path '/api/v1/animals' do
let!(:animals) { create_list(:animal, 2, customer: customer) }
get('list animals') do
security [cookies: []]
produces 'application/json'
response(200, 'successful') do
after do |example|
puts response.request.inspect
example.metadata[:response][:content] = {
'application/json' => {
example: JSON.parse(response.body, symbolize_names: true)
}
}
end
run_test! do
expect(response.body).to match_json_schema('response')
end
end
end
endI'm getting the error:
1.1) Failure/Error: visit session_path(as: customer)
NoMethodError:
undefined method `visit' for #<RSpec::ExampleGroups::ApiV1Animals::ApiV1Animals::Get::Successful:0x0000557b76384bd0>
My test.rb has:
# test.rb
Rails.application.configure do
...
config.middleware.use Clearance::BackDoor
endI tested on Clearance 2.5.0, 2.2.1 and 1.16.1
I can execute this in replacement of visit:
before do
backdoor = Clearance::BackDoor.new(ENV)
puts backdoor.inspect
endAnd I got a result. So, the backdoor was injected into my code.
Could you help me, please? Am I missing something?
Thank you!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels