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

Allow dredd command customization #25

Closed
gottfrois opened this issue Jun 1, 2016 · 4 comments
Closed

Allow dredd command customization #25

gottfrois opened this issue Jun 1, 2016 · 4 comments

Comments

@gottfrois
Copy link

Would be great to be able to override default dredd command. Since I launch dredd in a dockerized application, the way to go is to not install npm packages globaly but locally in the project directory.

I currently had to monkey patch dredd-rack with the following code to be able to change dredd's command:

module Dredd
  module Rack
    class Runner
      def initialize(api_endpoint=nil)
        @dredd_command = '$(npm bin)/dredd'
        @paths_to_blueprints = 'doc/*.apib doc/*.apib.md'
        @api_endpoint = api_endpoint || ''
        @command_parts = []

        yield self if block_given?
      end
    end
  end
end

module Dredd
  module Rack
    class RakeTask
      def dredd_available?
        true
      end
    end
  end
end
@gonzalo-bulnes
Copy link
Owner

Hi @gottfrois,

It makes a lot of sense. I'm thinking aloud, but I believe that could be a configuration option, something like:

Dredd::Rack.configure do |config|
  config.app = Example::Application
  config.dredd_executable = 'dredd' # or whatever String makes sense in your context
end

What do you think? Any better idea for the dredd_executable option name?
The Dredd::Rack::RakeTask#dredd_available method could be adapted to use the same configuration option.

I'm currently focused on adding support for hooks (using DreddHooks), but if you help me defining a reasonable API for this feature, I think the change is useful and small enough to be worth sneaking it in.

@gottfrois
Copy link
Author

Looks great or simply config.dredd_command.

+1 for dredd hooks. I tried to figure out how to use them but no luck :( Ideally I would like to be able to use my factories (factory girl) inside dredd hooks, not sure "how" dredd can load the hooks + the rails env though :-/

@gonzalo-bulnes
Copy link
Owner

Oh, of course, config.dredd_command would be just fine.

The primary goal of Dredd::Rack is allowing Dredd to be used with the usual Ruby testing tools (Factory Girl in the first place). We're not there yet, but integrating the Dredd hooks support is the first concrete step towards that goal. As I see it, once that done, integrating with Factory Girl & Co should be relatively straightforward. (We can discuss about that in an independent issue.)

Back to the topic: I'll try to implement this feature as soon as I can - I'll stick to the API we defined - meanwhile, if you want to give ot a try, feel welcome to PR (no pressure) : )

@gonzalo-bulnes
Copy link
Owner

Hi @gottfrois,

The v0.9.0 release ships the new dredd_command option. : )

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

No branches or pull requests

2 participants