0

I've got pure Ruby App for which I wrote few minitests. For example below test works well:

require 'pry'
require 'minitest/autorun'
require 'active_support'
require_relative '../../../../src/parsers/incoming_events/continue_quiz'

module Parsers
  module IncomingEvents
    class ContinueQuizTest < ActiveSupport::TestCase
      test 'parse JSON to Lexis Nexis format' do
        assert_equal expected_hash, service.call
      end

      private

      def service
        @service ||= ::Parsers::IncomingEvents::ContinueQuiz.new(event: event)
      end

      def event
        File.read('test/fixtures/files/continue_event.json')
      end

      def expected_hash
        JSON.parse(File.read('test/fixtures/files/incoming_events/continue_expected_result.json'))
      end
    end
  end
end

To run this thing I need to write this command in the console ruby test/src/parsers/responses/continue_quiz_test.rb which is a little annoying because I have 10 of these tests. Is it possible to run all the tests at once from the "test" folder?

I was hoping for the ruby test test/ command but my guess is that this is some kind of Rails magic command.

mr_muscle
  • 2,536
  • 18
  • 61
  • Does `ruby test/*` not work to run all files in your `test` directory? (You have to specify files for ruby to run, not a directory.) – JohnP Nov 29 '21 at 11:39
  • https://stackoverflow.com/questions/4788288/how-to-run-all-tests-with-minitest – Casper Nov 29 '21 at 11:44
  • You said it's a pure Ruby app, but you mentioned Rails in your question. Is it a Rails application? Also, from your test, it seems to be a Rails application. In this case, `rake test` or `rails test` should work. – sidney Nov 29 '21 at 12:04
  • @Sidney No, it's a pure Ruby app why do you think it's also Rails? – mr_muscle Nov 29 '21 at 12:58
  • @JohnP After running `ruby test/*` I'm getting this error: `ruby: Is a directory -- test/fixtures (LoadError)` – mr_muscle Nov 29 '21 at 12:59
  • OK, so perhaps you need to use `ruby test/*.rb` or to rename your files so you have a common part (e.g. they're all `test_foo_bar.rb`, so you can use `ruby test/test_*`). You should just need to pass the files (and nothing but the files) to your `ruby` command. – JohnP Nov 29 '21 at 13:04
  • Ok, but what if I have one test inside `test/src/parsers/responses/continue_quiz_test.rb` and another in `test/src/services/requests_test.rb` ? BTW I've got two tests inside `test/src/parsers/responses/` but only one test was fired after the command `ruby test/src/parsers/**/*.rb` – mr_muscle Nov 29 '21 at 13:19
  • Does this answer your question? [How to run all tests with minitest?](https://stackoverflow.com/questions/4788288/how-to-run-all-tests-with-minitest) – sidney Nov 29 '21 at 18:36

0 Answers0