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

added --dry-run option #1028

Merged
merged 6 commits into from Aug 22, 2013
Merged

added --dry-run option #1028

merged 6 commits into from Aug 22, 2013

Conversation

@schnittchen
Copy link
Contributor

schnittchen commented Jul 29, 2013

This adds --dry-run support as requested in #1022.

I would need some help as to where to test this feature...

@coveralls
Copy link

coveralls commented Jul 29, 2013

Coverage Status

Coverage increased (+0%) when pulling 9582260 on schnittchen:dry-run into a04fb17 on rspec:master.

@@ -107,7 +107,7 @@ def run(example_group_instance, reporter)
start(reporter)

begin
unless pending
unless pending or RSpec.configuration.dry_run

This comment has been minimized.

Copy link
@penelopezone

penelopezone Jul 29, 2013

Member

This is very strongly opinionated so feel free to disagree with me better, but as conditionals get more complex I like turn them into ifs instead of unlesses. What do you think?

This comment has been minimized.

Copy link
@schnittchen

schnittchen Jul 29, 2013

Author Contributor

I am totally ok with changing this to "if". I realize that coming from a mathematics background, DeMorgan's rules are pretty hard-wired into my brain...

This comment has been minimized.

Copy link
@schnittchen

schnittchen Jul 29, 2013

Author Contributor

Or extract the condition out into a will_execute? method?

This comment has been minimized.

Copy link
@JonRowe

JonRowe Jul 30, 2013

Member

Normally I would agree with you @samphippen, especially if there's an else but I try to stick to the cleaner version and

unless pending or RSpec.configuration.dry_run

reads better than

if !(pending or RSpec.configuration.dry_run)
if !pending and !RSpec.configuration.dry_run
@JonRowe
Copy link
Member

JonRowe commented Jul 30, 2013

You can add specs to this in spec/rspec/core/configuration_options_spec.rb for checking the option is parsed correctly, and spec/rspec/core/example_spec.rb to check that an example group won't run if dry run is enabled.

You will also need to add a .feature to document the feature and will serve as an integration test to assert that everything works together.

@myronmarston
Copy link
Member

myronmarston commented Jul 30, 2013

I think this implementation will still run before(:all) and after(:all) hooks, which it shouldn't.

@schnittchen
Copy link
Contributor Author

schnittchen commented Jul 30, 2013

Correct. Argh. More research.

@schnittchen
Copy link
Contributor Author

schnittchen commented Jul 30, 2013

I think I got it. Should probably move tests around after I realized before/after(:all) block execution is a group thing. And please nitpick if you see things you don't like.


Scenario: Using --dry-run
When I run `rspec . --dry-run`
Then the examples should all pass

This comment has been minimized.

Copy link
@JonRowe

JonRowe Jul 30, 2013

Member

I think it would be better to assert on the output here, to give an example of what to expect, and I'm not sure we should be considering the tests as "passing" here. They're closer to being pending.

This comment has been minimized.

Copy link
@schnittchen

schnittchen Jul 31, 2013

Author Contributor

I would rather write something like "Then it looks like the tests are all passing" with the same assertion underneath.

This comment has been minimized.

Copy link
@JonRowe

JonRowe Jul 31, 2013

Member

The test's don't pass though, they don't even run, so to describe it as such is misleading in my opinion

This comment has been minimized.

Copy link
@schnittchen

schnittchen Jul 31, 2013

Author Contributor

I see. Would "Then it looks like the tests are all passing" solve that? Do you have a better suggestion?

This comment has been minimized.

Copy link
@JonRowe

JonRowe Jul 31, 2013

Member

Actually showing the output you expect, similar to how pending does it /features/pending/pending_examples.feature#L17

Edit (is what I suggest :) )

This comment has been minimized.

Copy link
@schnittchen

schnittchen Jul 31, 2013

Author Contributor

Updated.

end
it "passing test" do; end
end
end

This comment has been minimized.

Copy link
@JonRowe

JonRowe Jul 30, 2013

Member

You could probably collapse this, as none of the fails should ever be executed.

This comment has been minimized.

Copy link
@schnittchen

schnittchen Jul 31, 2013

Author Contributor

I don't know what you mean by collapse here.

This comment has been minimized.

Copy link
@JonRowe

JonRowe Aug 1, 2013

Member

A .feature file should describe the behaviour of the feature it's describing, having a large empty spec file is slightly unnecessary to that aim, you only really need to prove none of the hooks run and an example doesn't run. A more compact file would just have the hooks and a single example.

This comment has been minimized.

Copy link
@schnittchen

schnittchen Aug 1, 2013

Author Contributor

Pushed terser version.

@coveralls
Copy link

coveralls commented Aug 1, 2013

Coverage Status

Coverage increased (+0%) when pulling cdd06b0 on schnittchen:dry-run into a04fb17 on rspec:master.


Scenario: Using --dry-run
When I run `rspec . --dry-run`
Then the output should contain "5 examples, 0 failures"

This comment has been minimized.

Copy link
@JonRowe

JonRowe Aug 1, 2013

Member

Nice work on the compacting, although I'd be tempted to use one liners for the hooks; Also this should now be "1 example"

This comment has been minimized.

Copy link
@schnittchen

schnittchen Aug 1, 2013

Author Contributor

Oh my. Blanked on that. Will fix it tonight.

@coveralls
Copy link

coveralls commented Aug 1, 2013

Coverage Status

Coverage increased (+0%) when pulling 8ac274e on schnittchen:dry-run into 505939b on rspec:master.

@JonRowe
Copy link
Member

JonRowe commented Aug 2, 2013

LGTM, but we'll wait until @myronmarston returns to merge this I think

@schnittchen
Copy link
Contributor Author

schnittchen commented Aug 2, 2013

Cool! Let me know if you want me to squash the commits.

myronmarston added a commit that referenced this pull request Aug 22, 2013
added --dry-run option
@myronmarston myronmarston merged commit 32ec674 into rspec:master Aug 22, 2013
1 check passed
1 check passed
default The Travis CI build passed
Details
@myronmarston
Copy link
Member

myronmarston commented Aug 22, 2013

Thanks for your contribution, @schnittchen!

I merged it, and then built off of this to add a few further improvements: #1056.

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

Successfully merging this pull request may close these issues.

None yet

5 participants
You can’t perform that action at this time.