Ruby
The following sections provide information on using Testspace with popular Ruby
test frameworks and tools.
To push collected files simply use the Testspace client
:
$ testspace static-analysis-results test-results code-coverage-results
Test Frameworks
Minitest
Minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking.
Ruby Minitest sample: https://github.com/testspace-samples/ruby.minitest
Testspace accepts JUnit XML formatted Test results. To produce such the ci_reporter_minitest needs to be configured with your test runner. Assuming you are using Minitest within a Rails application, configured to generated report files at ./test/reports
, simply run your tests:
rake minitest test
In the Testspace client
command-line reference ./test/reports/*.xml
as "test-results" files.
RSpec
RSpec is a Behaviour-Driven Development tool for Ruby programmers.
Ruby RSpec sample: https://github.com/testspace-samples/ruby.rspec
Testspace accepts JUnit XML formatted Test results. To produce such the ci_reporter_rspec needs to be configured with your test runner. Assuming you are using RSpec within a Rails application, configured to generated report files at ./spec/reports
, simply run your tests:
rake ci:setup:rspec spec
In the Testspace client
command-line reference ./spec/reports/*.xml
as "test-results" files.
Test::Unit
Test::Unit is an xUnit family unit testing framework for Ruby.
Testspace accepts JUnit XML formatted Test results. To produce such the ci_reporter_test_unit needs to be configured with your test runner. Assuming you are using Test::Unit within a Rails application, configured to generated report files at ./test/reports
, simply run your tests:
rake ci:setup:testunit test
In the Testspace client
command-line reference ./test/reports/*.xml
as "test-results" files.
Code Coverage
SimpleCov
SimpleCov is a code coverage analysis tool for Ruby.
Testspace accepts Cobertura XML formatted results. Assuming Cobertura formatter is installed and configured with your Test Framework to put results at ./coverage
, running your tests would also automatically produce the desired XML Report.
In the Testspace client
command-line reference ./coverage/coverage.xml
as "code-coverage-results" file.
Static Analysis
Brakeman
Brakeman is a vulnerability scanner specifically designed for Ruby on Rails applications.
Testspace accepts Checkstyle XML formatted results. Brakeman does not produce this natively, however BrakemanTranslateCheckstyleFormat could be used to interpret the native brakeman data files and generate the desired XML Report. Here is an example of how to produce such:
brakeman -o brakeman.json
brakeman_translate_checkstyle_format translate --file="brakeman.json" > analysis.xml
Note if you still want the full output of brakeman captured in the console use two -o
options:
brakeman -o brakeman.json -o /dev/stdout
In the Testspace client
command-line reference analysis.xml
as "static-analysis-results" file.
Rails Best Practices
Rails Best Practices is a code metric tool for Rails projects.
Testspace accepts Checkstyle XML formatted results. Here is an example of how to produce such:
rails_best_practices --format xml --output-file analysis.xml
In the Testspace client
command-line reference analysis.xml
as "static-analysis-results" file.
Reek
Reek is a code smell detector for Ruby.
Testspace accepts Checkstyle XML formatted results. Here is an example of how to produce such:
reek --format xml > analysis.xml
In the Testspace client
command-line reference analysis.xml
as "static-analysis-results" file.
Rubocop
Rubocop is a static code analyzer that enforces many of the guidelines outlined in the community Ruby Style Guide.
Testspace accepts GCC/Emacs style formatted output logs. Simply write your analysis 'emacs' formatted output to a file:
rubocop --format emacs --out analysis.log
In the Testspace client
command-line reference analysis.log{lint}
as "static-analysis-results" file.