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

Adds a pass-thru arg for Mocha grep support #181

Closed
wants to merge 3 commits into from

Conversation

tim-pg
Copy link

@tim-pg tim-pg commented Aug 12, 2014

Adds a pass-thru arg for Mocha grep support when running from the command line.

when running from the command line.
@tim-pg
Copy link
Author

tim-pg commented Aug 13, 2014

@jfirebaugh Hi John -- does this seem ok?

@jfirebaugh
Copy link
Owner

Hi @tim-pg, and thanks for the contribution. I'm leaning towards "no" on this. I realize there's a precedent here with SPEC and FORMAT, but think it was a mistake to introduce the use of environment variables to control what would more conveniently be specified via command line arguments. Rather than expanding the use of environment variables, I would prefer to introduce a real CLI interface (#149).

@tim-pg
Copy link
Author

tim-pg commented Aug 14, 2014

Sure I feel the same way. Do you have a preference on how you'd like that done (there are of course various options)? Anyway yeah I can switch this to use an arg, then followup to make the other extant env vars work via args instead.

Also, that aside, are you OK with the basic idea of appending the grep query parameter and letting Mocha pick it up from there?

@jfirebaugh
Copy link
Owner

Let's start simple, just using the stdlib OptionParser.

Also, that aside, are you OK with the basic idea of appending the grep query parameter and letting Mocha pick it up from there?

👍

@tim-pg
Copy link
Author

tim-pg commented Aug 18, 2014

@jfirebaugh Ok this has been updated.

Note that ENV support is completely replaced, which may be a back-compat issue... or maybe not, your call.

@tim-pg
Copy link
Author

tim-pg commented Aug 24, 2014

@jfirebaugh Hi John, how's this looking? Anything you'd like tweaked? Thanks--

@jfirebaugh
Copy link
Owner

What I had in mind was actually moving the existing env var support out to the rake tasks (we do need to keep supporting that), and providing a standalone konacha binary.

konacha serve
konacha run
konacha run foo_spec bar_spec
konacha run --grep "reticulates splines"
konacha run --formatter CI::Reporter::RSpec

The binary has to load up the Rails environment somehow -- I guess look at what rake environment does for that.

@Mange
Copy link
Collaborator

Mange commented Aug 26, 2014

You require config/boot.rb or config/environment.rb (can't remember
which).
Den 26 aug 2014 18:05 skrev "John Firebaugh" notifications@github.com:

What I had in mind was actually moving the existing env var support out to
the rake tasks (we do need to keep supporting that), and providing a
standalone konacha binary.

konacha serve
konacha run
konacha run foo_spec bar_spec
konacha run --grep "reticulates splines"
konacha run --formatter CI::Reporter::RSpec

The binary has to load up the Rails environment somehow -- I guess look at
what rake environment does for that.


Reply to this email directly or view it on GitHub
#181 (comment).

@tim-pg
Copy link
Author

tim-pg commented Aug 26, 2014

Ok-- I misunderstood what you meant by "real CLI interface", sorry about that. Ok, I'll take a stab at a standalone binary.

  1. Let me make sure I understand what this part means: "moving the existing env var support out to the rake tasks". I am assuming you mean read the env vars in the rake task but then use them as though they had been specified on the command line, i.e., don't directly refer to ENV anymore in the actual code. Is that right?

  2. Also -- you said "out to the rake tasks" (plural) -- but just to clarify, you only mean one task (singular). I.e., these options aren't meant affect the way serve works, only run, yes (?)

@jfirebaugh
Copy link
Owner

Yes, right, just konacha:run. Something like:

  task :run => :environment do
    if ENV['FORMAT']
      Konacha.config.formatters = ENV['FORMAT'].split(',').map do |string|
        eval(string).new(STDOUT)
      end
    end

    if ENV["SPEC"]
      Konacha.config.spec = ENV["SPEC"].split(",")
    end

    passed = Konacha.run
    # Apparently there is no canonical way to fail a rake task other than
    # throwing an exception or exiting.
    # http://stackoverflow.com/a/5117457/525872
    exit 1 unless passed
  end

@jfirebaugh jfirebaugh closed this Mar 30, 2015
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

Successfully merging this pull request may close these issues.

3 participants