I'm trying to define a test environment to make request programmatically to my Grape API.
I have the main API file into /app/api/services/v1.rb and i created a folder called requests into the spec path that have a file with this content for testing:
describe Services::V1 do
describe "GET /v1/users/:id" do
it "returns a user by id" do
user = User.create!
get "/api/users/#{user.id}"
expect(response.body).to eq user.to_json
end
end
end
The API have a path defined for the users resource but i have an error meaning that the Servicesnamespace is "uninitialized constant Services (NameError)"
I've added config.include RSpec::Rails::RequestExampleGroup, type: :request, file_path: /spec/api/ into the spec_helper but i think that i'm misunderstanding the Grape doc related with that.
"You may want your API code to go into app/api - you can match that layout under spec by adding the following in spec/spec_helper.rb.
RSpec.configure do |config| config.include RSpec::Rails::RequestExampleGroup, type: :request, file_path: /spec/api/ end"
Any help to make things work is appreciated. I'm a newbie with this technologies setup.