added --dry-run option #1028

Merged
merged 6 commits into from Aug 22, 2013

Conversation

Projects
None yet
5 participants
@schnittchen
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

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Jul 29, 2013

Coverage Status

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

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.

@samphippen

samphippen 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?

@samphippen

samphippen 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.

@schnittchen

schnittchen Jul 29, 2013

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...

@schnittchen

schnittchen Jul 29, 2013

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.

@schnittchen

schnittchen Jul 29, 2013

Contributor

Or extract the condition out into a will_execute? method?

@schnittchen

schnittchen Jul 29, 2013

Contributor

Or extract the condition out into a will_execute? method?

This comment has been minimized.

@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

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

This comment has been minimized.

Show comment
Hide comment
@JonRowe

JonRowe Jul 30, 2013

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@myronmarston

myronmarston Jul 30, 2013

Member

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

Member

myronmarston commented Jul 30, 2013

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

@schnittchen

This comment has been minimized.

Show comment
Hide comment
@schnittchen

schnittchen Jul 30, 2013

Contributor

Correct. Argh. More research.

Contributor

schnittchen commented Jul 30, 2013

Correct. Argh. More research.

@schnittchen

This comment has been minimized.

Show comment
Hide comment
@schnittchen

schnittchen Jul 30, 2013

Contributor

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.

Contributor

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.

features/command_line/dry_run.feature
+
+ Scenario: Using --dry-run
+ When I run `rspec . --dry-run`
+ Then the examples should all pass

This comment has been minimized.

@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.

@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.

@schnittchen

schnittchen Jul 31, 2013

Contributor

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

@schnittchen

schnittchen Jul 31, 2013

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.

@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

@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.

@schnittchen

schnittchen Jul 31, 2013

Contributor

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

@schnittchen

schnittchen Jul 31, 2013

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.

@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 :) )

@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.

@schnittchen

schnittchen Jul 31, 2013

Contributor

Updated.

@schnittchen

schnittchen Jul 31, 2013

Contributor

Updated.

features/command_line/dry_run.feature
+ end
+ it "passing test" do; end
+ end
+ end

This comment has been minimized.

@JonRowe

JonRowe Jul 30, 2013

Member

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

@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.

@schnittchen

schnittchen Jul 31, 2013

Contributor

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

@schnittchen

schnittchen Jul 31, 2013

Contributor

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

This comment has been minimized.

@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.

@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.

@schnittchen

schnittchen Aug 1, 2013

Contributor

Pushed terser version.

@schnittchen

schnittchen Aug 1, 2013

Contributor

Pushed terser version.

@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Aug 1, 2013

Coverage Status

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

Coverage Status

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

features/command_line/dry_run.feature
+
+ Scenario: Using --dry-run
+ When I run `rspec . --dry-run`
+ Then the output should contain "5 examples, 0 failures"

This comment has been minimized.

@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"

@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.

@schnittchen

schnittchen Aug 1, 2013

Contributor

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

@schnittchen

schnittchen Aug 1, 2013

Contributor

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

@coveralls

This comment has been minimized.

Show comment
Hide comment
@coveralls

coveralls Aug 1, 2013

Coverage Status

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

Coverage Status

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

@JonRowe

This comment has been minimized.

Show comment
Hide comment
@JonRowe

JonRowe Aug 2, 2013

Member

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

Member

JonRowe commented Aug 2, 2013

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

@schnittchen

This comment has been minimized.

Show comment
Hide comment
@schnittchen

schnittchen Aug 2, 2013

Contributor

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

Contributor

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

@myronmarston myronmarston merged commit 32ec674 into rspec:master Aug 22, 2013

1 check passed

default The Travis CI build passed
Details

@myronmarston myronmarston referenced this pull request Aug 22, 2013

Merged

Dry run improvements #1056

@myronmarston

This comment has been minimized.

Show comment
Hide comment
@myronmarston

myronmarston Aug 22, 2013

Member

Thanks for your contribution, @schnittchen!

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

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.

@schnittchen schnittchen deleted the schnittchen:dry-run branch Aug 22, 2013

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