Sometimes I have a broken test on CircleCI, where the error can't be replicated locally. Instead of waiting for the whole suite to run, I'd like to run that one test individually. (I know I can ssh in, but that's time-consuming and running it that way wouldn't exactly replicate the usual automated test sequence.)
My aim is to make a temporary config commit to run just one test (ideally just a test method, but the whole class would be fine too). I can think of two possible solutions: (A) edit app.rake to make the default rake task run a single test; or (B) edit circle.yml to run just the one test from command-line using rake test. Any clue on either of these?
Related
You can run single test using Rails 5 test runner by specifying the file and the linenumber like the following:
rails test path/to/test:55
In RubyMine, you can run single test from context menu on a test you want to run. However, since it is not via the above test runner, it does not use a spring preloader and takes long to launch a test.
I have tried to create new Run/Debug configuration to run test via spring, but I am still not sure how to do it.
Please let me know how to run single test via Rail5 test runner?
To run a single test in Rails, we normally do:
rails test TEST=test/system/invitation_test.rb
But that doesn't work with system tests. Neither do this work:
rails test:system TEST=test/system/invitation_test.rb
With both those commandos above, all system tests (files) are run.
So my question is, how can I run a single system test?
As a side note, to run (all) system tests in Rails, you need to append :system to test.
rails test:system
While rails test doesn't seem to work if you want to run your system tests (you need to append test with :system), if you only want to run a single test it does seem to work:
rails test test/system/my_little_test.rb
I've never worked with Capistrano before and currently I am fighting the urge to just scrap it and go back to my old manual ways.
As I understand, Capistrano V3 does not create the initial database because they feel it is the duty of the DB administrator.
So I must be missing something but I have followed their instructions but the initial cap staging deploy fails when it gets to the rake db:migrate step because the database does not exist.
Because of the failure, the symlink for current -> releases never gets created.
Is it just accepted general practice that we SSH into our boxes and cd into the first folder under releases and manually run rake db:create...?
And then from there, am I supposed to just run cap staging deploy again so that it finishes creating the symlinks?
Seems hacky for something that is supposed to make things easier and I am not sure if I am understanding this correctly or not.
Thanks.
It does make sense to leave certain things out of a deployment. As the initial set up and the routine deployments are very separate functions and require different specialties, or in large deployments even different skillsets. That said.. I'm totally with you - on the first deploy having to manually set up the database and certain files (specifically linked files like secrets.yml) is a step that just wastes my time.
I use this plugin:
https://github.com/capistrano-plugins/capistrano-postgresql
just add the require capistrano/postgresql to your capfile as you would any plugin
then run cap staging setup before the first time you run cap staging deploy
When working with Rails, is there any way to customize the results from rake commands?
For instance, I use the rake dump task - rake db:dump - so that it gets all my locally produced database entries. I would want to expand that to a deployed app so that I can run one command and have a file that can reproduce my DB.
How can this be done?
What you could do is write a bash script that is just all the commands you need to dump and deploy.
You can also create an alias that runs multiple commands, which might be closer to what you want to do.
Here's a similar question that has answers explaining both:
How can I define a bash alias as a sequence of multiple commands?
For a couple of months now I have the problem that running rake spec cucumber (or each one separately) runs the specs and/or features always twice. It's kind of annoying, since it makes me wait longer.
Now if I run rspec or cucumber then the specs/or features only run a single time.
I'm not sure what details I could provide here, so I'll just link the repo here https://github.com/deiga/new-Roydon/tree/feature/allow-orders-without-registeration