Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print a usable re-run command for specs defined in external files.
Fixes #793.
- Loading branch information
1 parent
2470f99
commit cc865dc
Showing
8 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
require 'support/aruba_support' | ||
|
||
RSpec.describe 'Shared Example Rerun Commands' do | ||
include_context "aruba support" | ||
before { clean_current_dir } | ||
|
||
it 'prints a rerun command for shared examples in external files that works to rerun' do | ||
write_file "spec/support/shared_examples.rb", """ | ||
RSpec.shared_examples 'a failing example' do | ||
example { expect(1).to eq(2) } | ||
end | ||
""" | ||
|
||
write_file "spec/host_group_spec.rb", """ | ||
load File.expand_path('../support/shared_examples.rb', __FILE__) | ||
RSpec.describe 'A group with shared examples' do | ||
include_examples 'a failing example' | ||
end | ||
RSpec.describe 'A group with a passing example' do | ||
example { expect(1).to eq(1) } | ||
end | ||
""" | ||
|
||
run_command "" | ||
expect(last_cmd_stdout).to include("2 examples, 1 failure") | ||
run_rerun_command_for_failing_spec | ||
expect(last_cmd_stdout).to include("1 example, 1 failure") | ||
# There was originally a bug when doing it again... | ||
run_rerun_command_for_failing_spec | ||
expect(last_cmd_stdout).to include("1 example, 1 failure") | ||
end | ||
|
||
def run_rerun_command_for_failing_spec | ||
command = last_cmd_stdout[/Failed examples:\s+rspec (\S+) #/, 1] | ||
run_command command | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters