Class: Specwrk::ListExamples
- Inherits:
-
Object
- Object
- Specwrk::ListExamples
- Defined in:
- lib/specwrk/list_examples.rb
Instance Method Summary collapse
- #examples ⇒ Object
-
#initialize(dir) ⇒ ListExamples
constructor
A new instance of ListExamples.
-
#stop(group_notification) ⇒ Object
Called as the formatter.
Constructor Details
#initialize(dir) ⇒ ListExamples
Returns a new instance of ListExamples.
9 10 11 |
# File 'lib/specwrk/list_examples.rb', line 9 def initialize(dir) @dir = dir end |
Instance Method Details
#examples ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/specwrk/list_examples.rb', line 13 def examples reset! return @examples if defined?(@examples) @examples = [] RSpec.configuration.files_or_directories_to_run = @dir RSpec::Core::Formatters.register self.class, :stop RSpec.configuration.add_formatter(self) unless RSpec::Core::Runner.new().run($stderr, out).zero? out.tap(&:rewind).each_line { |line| $stdout.print line } end @examples end |
#stop(group_notification) ⇒ Object
Called as the formatter
31 32 33 34 35 36 37 38 |
# File 'lib/specwrk/list_examples.rb', line 31 def stop(group_notification) group_notification.notifications.map do |notification| @examples << { id: notification.example.id, file_path: notification.example.[:file_path] } end end |