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

Add the ability to configure a host #74

Closed
kevinthompson opened this issue Jun 1, 2013 · 3 comments
Closed

Add the ability to configure a host #74

kevinthompson opened this issue Jun 1, 2013 · 3 comments

Comments

@kevinthompson
Copy link

When an API only responds to calls on a given subdomain, it seems the full url must be specified in the example group. It would be preferable to specify the api host in the configuration instead.

@oestrich
Copy link
Contributor

oestrich commented Jun 4, 2013

Could you give an example of how you're currently using it, then how you would like to to be? I'm not sure I entirely understand.

@kevinthompson
Copy link
Author

In the example block below, in my get method call, I have to define the full url and I believe that's because my application has a few subdomain constraints. Without the full host specified, the specs fail.

require 'spec_helper'
require 'rspec_api_documentation/dsl'

resource 'Albums' do
  parameter :auth_token, 'Authentication token'

  let(:user){ create(:user) }
  let(:photo){ create(:photo, user: user) }
  let(:auth_token){ user.authentication_token }

  get 'https://app.example.com/api/v1/albums.json' do

    before do
      create(:album, user: user)
    end

    example_request 'List Albums' do
      status.should == 200
      response_json = JSON.parse(response_body)
      response_json['errors'].should be_empty
      albums = response_json['data']
      albums.any?{ |album| album['name'] == 'Example Album' }.should be_true
    end
  end
end

@oestrich
Copy link
Contributor

I'm not entirely sure how to get around this. I think we have to mess with the env["HOST"] which we can't get to from the DSL level and is client specific (rack, oauth). Issue #50 seems to be pretty similar. We can possibly add a new DSL to make the client change the host properly. Seems like it might be a good way around this.

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