Skip to content

Fix ruby example for JUnit test

Vladimir Shushlin requested to merge patch-95 into master

What does this MR do?

This fixes 3 problems:

  1. rspec is being executed without bundle exec(it will probably work in CI environment since there is only 1 ruby installation, but it's generally a good idea to use bundle exec)
  2. removes specific directory spec/lib which assumes that users always have all tests there. spec/ dir is the default for rspec and I think it's better default in the example
  3. output currently is not visible in job because it's being printed only to JUnit file, adding second --format progress fixes that, now it's being printed to both console and JUnit file:
➜  test-artifacts git:(master) ✗ bundle exec rspec --format progress --format RspecJunitFormatter --out rspec.xml
F

Failures:

  1) test describe test example
     Failure/Error: expect(2 + 2).to eq 5
     
       expected: 5
            got: 4
     
       (compared using ==)
     # ./spec/test_spec.rb:7:in `block (2 levels) in <top (required)>'

Finished in 0.01608 seconds (files took 0.13167 seconds to load)
1 example, 1 failure

Failed examples:

rspec ./spec/test_spec.rb:6 # test describe test example

➜  test-artifacts git:(master) ✗ cat rspec.xml 
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="rspec" tests="1" skipped="0" failures="1" errors="0" time="0.016078" timestamp="2020-04-14T15:00:49+03:00" hostname="Vladimirs-MacBook-Pro.local">
<properties>
<property name="seed" value="53128"/>
</properties>
<testcase classname="spec.test_spec" name="test describe test example" file="./spec/test_spec.rb" time="0.014948"><failure message="
expected: 5
     got: 4

(compared using ==)
" type="RSpec::Expectations::ExpectationNotMetError">Failure/Error: expect(2 + 2).to eq 5

  expected: 5
       got: 4

  (compared using ==)
./spec/test_spec.rb:7:in `block (2 levels) in &lt;top (required)&gt;&apos;</failure></testcase>
</testsuite>

Screenshots

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by 🤖 GitLab Bot 🤖

Merge request reports