ruby-on-railscirclecirspec3

RspecJunitFormatter not working after upgrading rspec 2 to 3


After upgrading rspec 2.99 to rspec 3, I'm getting following error on CircleCI rspec_junit_formatter.rb:73:in '%': can't convert nil into Float (TypeError) and none of the specs are running.

The specs are running with rspec 2.99, but fails with rspec > 3.0

bundler: failed to load command: rspec (/home/circleci/test-application/vendor/bundle/ruby/2.4.0/bin/rspec)
Coverage report generated for RSpec to /home/circleci/test-application/coverage. 5908 / 17112 LOC (34.53%) covered.
/home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter.rb:73:in `%': can't convert nil into Float (TypeError)
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter.rb:73:in `xml_dump_example'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter.rb:46:in `block in xml_dump_examples'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter.rb:39:in `each'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter.rb:39:in `xml_dump_examples'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter.rb:34:in `xml_dump'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter/rspec3.rb:21:in `block in dump_summary'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter/rspec3.rb:111:in `swap_rspec_configuration'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter/rspec3.rb:128:in `without_color'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec_junit_formatter-0.5.1/lib/rspec_junit_formatter/rspec3.rb:21:in `dump_summary'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:137:in `block in notify'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:136:in `each'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:136:in `notify'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:118:in `finish'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:56:in `ensure in report'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/reporter.rb:56:in `report'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:108:in `run_specs'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:86:in `run'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in `run'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in `invoke'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.0.4/exe/rspec:4:in `<top (required)>'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/bin/rspec:25:in `load'
    from /home/circleci/test-application/vendor/bundle/ruby/2.4.0/bin/rspec:25:in `<top (required)>'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/cli/exec.rb:58:in `load'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/cli/exec.rb:58:in `kernel_load'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/cli/exec.rb:23:in `run'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/cli.rb:483:in `exec'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/cli.rb:31:in `dispatch'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/cli.rb:25:in `start'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/exe/bundle:48:in `block in <top (required)>'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
    from /home/circleci/.rubygems/gems/bundler-2.3.12/exe/bundle:36:in `<top (required)>'
    from /home/circleci/.rubygems/bin/bundle:25:in `load'
    from /home/circleci/.rubygems/bin/bundle:25:in `<main>'

Exited with code exit status 1

circleci config.yml

- run:
     name: Run tests
     command: |
     mkdir ~/test_results
     circleci tests glob "spec/**/*_spec.rb" | circleci tests split --split-by=timings> /tmp/tests-to-run
     bundle exec rspec $(cat /tmp/tests-to-run) --format documentation --profile --format RspecJunitFormatter -o ~/test_results/rspec.xml

rspec 3.0

rspec_junit_formatter 0.5.1

ruby 2.4


Solution

  • The above error is fixed in rspec_junit_formatter v0.6

    More info on github issue