Rspec don't show me the its - ruby

I have this repository on bitbucket
bitbucket.org/alu0100786330/prct08
And when I clone it in my cloud 9, the Rspec don't show me the its
I have this workspace that containt the repository and here it works right:
ide.c9.io/alu0100786330/lpp_67
Expected output:
[
BUT in the second workspace dont show me the results.
The commands that I made:
git clone bitbucket.org/alu0100786330/prct08
bundle install
And when I execute the rspec with the rake show me this, without its:
[]
What can I do to show the its?

RSpec reads from the .rspec configuration file in the directory you run it from. It sounds like in one workspace, that contains --format documentation, and in the other, it contains --format progress (or nothing, progress is default). You just need to add a .rspec file to your second workspace, or run rspec with the options you want (See rspec --help).
If you or your team has an .rspec you like, check it into the repository. Individuals can still create a .rspec-local that doesn't go in the repository if they want to override some settings just for themselves.

Related

How to delete reports folder before every run in cypress?

I am storing my cucumber html report under cucumber-html-reports folder and json files are storing under cucumber-json folder. Now I want delete/empty these two folders. I need a plug in to achieve this.
The correct way to do this is to add an npm script to clean up the report folder and execute it before the test run. Cypress has an example npm script on their website for this. https://docs.cypress.io/guides/tooling/reporters#Command-line-3
Usually, the CI/CD pipeline would run the clean up script before the test run kicks off. Alternatively, you could add a little bit of code to your plugins file to exec the npm script before the test run as well.
One sort of hacky option, there is a trashAssetsBeforeRuns option in the Cypress config (set to true by default). It's used to clean up the downloads, videos, and screenshots folders before a test run. If you map your reporter results to one of these directories that might work, although I can't guarantee success with it since I haven't done that.

Can't get feature file to run through Jenkins

I'm trying to get our automation environment set up to run headless through Jenkins on a linux server. The automation is set up through Ruby and uses Cucumber. I've run into an issue trying to get the feature files to run.
I have several plug ins for Jenkins, Xfvb, Cucumber reports, Cucumber-plugin.
I have setup the code in Ruby set up correctly (at least I believe so) for one of the feature files to run as headless.
But I can't quite get to test that specific file. When I try to run the build after enable the Cucumber-plugin it tries to run a different feature file. It seems to want to run the entire project. I've tried to add a new profile in my cucumber.yml (name jenkins) file and specify a tag like below:
jenkins: --tags #DisposalFeeService --no-source --format pretty --format html --out results.html --format json --out reports.json
I only have 1 feature file that is tagged with that tag and my build runs a completely different feature file. The feature is failing for good reasons, nothing to do with the Jenkins set-up, it would fail anyways. I also haven't set up all the features to run as headless, nor do I want to at this time. I'm just trying to show that I can get a feature file to run in through Jenkins.
If it is helpful, here is my cucumber-plug in in Jenkins: Cucumber Jenkins plug in

Rspec multiple spec folders

Im currently building a project using Rspec in which I sepparated in two different folders with domain code and infrastructure code. Both folders have their own specs in a spec folder. The domain/spec folder is the one containing the spec_helper.rb file, thats required from the tests inside the other folder infrastructure/spec
I'd like to know how to have a spec folder in the root of the project, including the spec_helper file and also tests, and being able to run all the tests with just one command (right now I do it running rspec domain/ infrastructure/)
RSpec is designed to work with all tests in one folder. By default, this folder is called spec/, but you can use a different name with the --default-path option.
So, your options as I see it are:
Edit the source code of rspec-core to let that configuration support multiple directories. Hopefully your PR will be approved and merged.
Or, write a simple wrapper script that runs rspec against both directories. For example, you could alias rspecs='rspec domain/ infrastructure/'.
Or (what I would recommend!), you could just restructure your tests slightly to use spec/domain/ and spec/infrastructure/ folders -- and then everything will just work, by convention, out of the box.

Where to put test files that get created. Ruby directory structure

Say I'm writing an integration test that reads in a CSV and outputs a CSV with some changes in the data. Where do I put this test file in a Ruby project? Is there some convention for where temporary files that get created in tests go that eventually get torn down or delete?
Say my project structure is simple:
--root
--app
--promotions
--spec
Gemfile
Gemfile.lock
Sounds like a perfect candidate for Dir.mktmpdir.

override --fail-fast in rspec

I run specs in my local machine and in a CI server. In the first case I want specs to fail fast, and in the other I want run all of them. I've set --fail-fast in my .rspec file. How can I override it on the CI server? I run there RSpec using rake spec and I set SPEC_OPTS env variable.
The simplest answer is to remove .rspec from your repo. It is used only by you and any other contributor don't need to see that you are using NyanCat to see how your test's are doing.
You can add a .rspec file in your home directory so that the settings only apply to your local machine, and then the .rspec in the project directory will override any settings there.
--no-fail-fast has since been added.
https://relishapp.com/rspec/rspec-core/docs/command-line/fail-fast-option#using-%60--no-fail-fast%60

Resources