1

so I have a route api.gemstore.dev/gems (using pow) in the browser I get an empty array [] which is perfect, there isn't anything in the db yet, so I should get an empty array

in my rspec test I have

  setup do
    host! 'api.gemstore.dev'
  end

  test 'As a user, I want to get gems' do
    get '/gems', {}, { 'Accept' => Mime::JSON }
    assert_equal 200, response.status
    assert_equal Mime::JSON, response.content_type
  end

routes

  namespace :api, path: '/', constraints: { subdomain: 'api' } do
    resources :gems
  end

rake routes

   Prefix Verb   URI Pattern                 Controller#Action
   api_gems GET    /gems(.:format)          api/gems#index   {:subdomain=>"api"}
               POST   /gems(.:format)          api/gems#create {:subdomain=>"api"}
   new_api_gem GET    /gems/new(.:format)      api/gems#new {:subdomain=>"api"}
  edit_api_gem GET    /gems/:id/edit(.:format) api/gems#edit {:subdomain=>"api"}
       api_gem GET    /gems/:id(.:format)      api/gems#show {:subdomain=>"api"}
               PATCH  /gems/:id(.:format)      api/gems#update {:subdomain=>"api"}
               PUT    /gems/:id(.:format)      api/gems#update {:subdomain=>"api"}
               DELETE /gems/:id(.:format)      api/gems#destroy {:subdomain=>"api"}
              root GET    /                           static#index

but this comes back with a no route matches error

let me know if you need more info, happy to provide, just not sure what to provide

Gambai
  • 651
  • 1
  • 7
  • 25

1 Answers1

1

Probably host isn't being set up correctly.

  • host! "my.awesome.host" for integration specs (inheriting from ActionDispatch::IntegrationTest). See the docs, section 5.1 Helpers Available for Integration Tests.
  • @request.host = 'my.awesome.host' for controller specs (inheriting from ActionController::TestCase). See the docs, section 4.4 Instance Variables Available.
  • If using Capybara, check this instead
Community
  • 1
  • 1
Mario
  • 1,349
  • 11
  • 16
  • host! "my.awesome.host" this is exactly what I have! thank you for looking. but I'm afraid your just as stumped as me. I think my mac hates me. I suppose it's what I get for hating macs for so long – Gambai May 07 '15 at 06:15
  • Try the @request.host bit – Mario May 07 '15 at 06:27