Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Usage with fuubar #23

Open
mollerhoj opened this issue Aug 17, 2022 · 3 comments · May be fixed by #51
Open

Usage with fuubar #23

mollerhoj opened this issue Aug 17, 2022 · 3 comments · May be fixed by #51
Labels
enhancement New feature or request

Comments

@mollerhoj
Copy link

I use the fuubar formatter.

I just wanted to show a hack to get the formatter to work with this gem:

In Reporter#add, add the following hack:

       ...
        @formatters << formatter_class.new(output)

        if name == "Fuubar"
          output = `bundle exec rspec --dry-run | grep 'examples, 0 failures'`
          example_count = output.split(" ").first.to_i
          delegate_to_formatters(:start, RSpec::Core::Notifications::StartNotification.new(example_count))
        end

        @formatters
        ...

This will send the required StartNotification to fuubar.

Now we can run the specs with bundle exec turbo_tests -f Fuubar -r 'fuubar' to get nicely formatted output.

@ilyazub ilyazub added the enhancement New feature or request label Jan 20, 2023
@ilyazub
Copy link
Collaborator

ilyazub commented Jan 20, 2023

Thanks, @mollerhoj!

Confirming it works well even when delegate_to_formatters(:start, ...) is called for all formatters (without name == "Fuubar" condition).

Not sure where to add this in documentation. Maybe some section with workarounds.

P.S. I find JSON formatter more reliable for extracting the number of total examples.

json_summary = JSON.parse(`#{ENV["BUNDLE_BIN_PATH"]} exec rspec --dry-run --format json -- #{@files.join(" ")}`, symbolize_names: true)
total_examples_count = json_summary.dig(:summary, :example_count) || 0

@Mayurifag
Copy link

Thanks for useful information! Yea, I think, this should be added to README file. I mean, simplecov and fuubar are kinda must have and it would be very handy to have all needed info about them in single place right after putting gem to Gemfile. 😄

@ilyazub
Copy link
Collaborator

ilyazub commented Feb 21, 2023

@Mayurifag Thank you for your feedback.

@mollerhoj, @Mayurifag please open a PR with a README update. :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants