summaryrefslogtreecommitdiff
path: root/features
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2017-03-29 17:07:51 -0400
committerRobert Speicher <rspeicher@gmail.com>2017-03-29 17:07:51 -0400
commit9aedf9c42c4eb2328d3ad9da671d9e05f4543326 (patch)
tree45c0427a7e8642bb327af6b21e1920ea577e3084 /features
parent4cf16426da202eb1b03197885d8437385d1e0dd0 (diff)
downloadgitlab-ce-9aedf9c42c4eb2328d3ad9da671d9e05f4543326.tar.gz
Monkey patch the Spinach StdoutReporter to show scenario locations
Before: Scenario: Viewing invitation when signed out ✔ Given "John Doe" is owner of group "Owned" # features/steps/shared/group.rb:8 After: Scenario: Viewing invitation when signed out # features/invites.feature:6 ✔ Given "John Doe" is owner of group "Owned" # features/steps/shared/group.rb:8 Now if a scenario fails we can easily rerun it with a specific line number.
Diffstat (limited to 'features')
-rw-r--r--features/support/env.rb16
1 files changed, 16 insertions, 0 deletions
diff --git a/features/support/env.rb b/features/support/env.rb
index f394c30d52f..26cdd9d746d 100644
--- a/features/support/env.rb
+++ b/features/support/env.rb
@@ -33,3 +33,19 @@ Spinach.hooks.before_run do
include FactoryGirl::Syntax::Methods
end
+
+module StdoutReporterWithScenarioLocation
+ # Override the standard reporter to show filename and line number next to each
+ # scenario for easy, focused re-runs
+ def before_scenario_run(scenario, step_definitions = nil)
+ @max_step_name_length = scenario.steps.map(&:name).map(&:length).max if scenario.steps.any?
+ name = scenario.name
+
+ # This number has no significance, it's just to line things up
+ max_length = @max_step_name_length + 19
+ out.puts "\n #{'Scenario:'.green} #{name.light_green.ljust(max_length)}" \
+ " # #{scenario.feature.filename}:#{scenario.line}"
+ end
+end
+
+Spinach::Reporter::Stdout.prepend(StdoutReporterWithScenarioLocation)