Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Find correct path for contexts in shared examples

  • Loading branch information...
commit 86bc386f9577ef86e13c23f7f2e2e5f8a42b97e5 1 parent 0947d52
@sandro authored
Showing with 12 additions and 8 deletions.
  1. +12 −8 lib/specjour/loader.rb
View
20 lib/specjour/loader.rb
@@ -100,17 +100,21 @@ def rspec_examples
end
def filtered_examples
- ::RSpec.world.example_groups.map do |g|
+ examples = ::RSpec.world.example_groups.map do |g|
g.descendants.map do |gs|
gs.examples
- end.flatten.map do |e|
- meta = e.metadata
- if e.example_group.metadata[:shared_group_name]
- meta = e.metadata[:example_group]
- end
- "#{meta[:file_path]}:#{meta[:line_number]}"
end
- end.flatten.uniq
+ end.flatten
+ locations = examples.map do |e|
+ meta = e.metadata
+ shared_group = e.example_group.ancestors.detect do |group|
+ group.metadata[:shared_group_name]
+ end
+ if shared_group
+ meta = shared_group.metadata[:example_group]
+ end
+ meta[:location]
+ end.uniq
ensure
::RSpec.reset
end
Please sign in to comment.
Something went wrong with that request. Please try again.