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

RspecJunitFormatter not working after upgrading rspec 2 to 3 #100

Closed
vjain98 opened this issue Sep 28, 2022 · 2 comments
Closed

RspecJunitFormatter not working after upgrading rspec 2 to 3 #100

vjain98 opened this issue Sep 28, 2022 · 2 comments

Comments

@vjain98
Copy link

vjain98 commented Sep 28, 2022

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)

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

@sj26
Copy link
Owner

sj26 commented Sep 29, 2022

Weird! That's come from this line, and so implies it's trying to report a test case which has a nil duration:

https://github.com/sj26/rspec_junit_formatter/blob/v0.5.1/lib/rspec_junit_formatter.rb#L73

I've pushed an update in v0.6.0 that will omit time when duration is nil. Please upgrade and try it!

@vjain98
Copy link
Author

vjain98 commented Sep 29, 2022

Thanks @sj26 for providing the quick fix. The above error is resolved now.

@vjain98 vjain98 closed this as completed Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants