How do I run individual tests on Rails 5 with ruby-test on Atom - ruby

When I left my company I also lost my license to RubyMine so I started working with Atom. One feature I really missed from RubyMine was the ability to run individual tests directly from the editor.
After poking around a bit I found a library for Atom that accomplished this: https://atom.io/packages/ruby-test
This package is great, except I found that whenever I ran a test that had spaces in the name, the test wouldn't actually run.
How can I get the package to run tests that have spaces in their name?

The command the package was using was:
ruby -I test {relative_path} -n "/{regex}/"
If you go into the settings, you can modify this to use TESTOPTS which supports spaces in the names:
ruby -I test {relative_path} TESTOPTS="-n /{regex}/"

Related

Parallel processing not working using create_app in julia

So I'm using the create_app() method in PackageCompiler to create an app of my julia package. It works except that the original package could run on multiple processes and after it's turned into and app it doesn't anymore.
I put this at the beginning of my script (and in the app main function)
#info("using $(nworkers()) workers\n")
It outputs whatever I pass with the -p flag when running the script indicating it is indeed running with multiple workers. After the package is turned into an app it always prints "using 1 workers" regardless of the flags I pass using --julia-args -pX
Is there something that I should enable to make this work, or is this inherently not possible?
cheers
jiq
UPDATE: it seems that using addprocs() does work (which provides a workaround for me) but I'm still confused as to why the command line argument -p is not picked up

Ruby Aruba testing can't find command in PATH-variable

I'm teaching myself the basics of how to make my own Ruby Gem using Bundler's guide. However when I get to setting up CLI tests with aruba/cucumber I keep running into a problem:
Command "co2domain" not found in PATH-variable "C:/.../PATH variables". (Aruba::LaunchError)
The only differences I made is to change some of the names of the example as I'd eventually like to build a gem that converts company names to their proper domains.
Here is my company.feature file:
Feature: Company
In order to portray Company
As a CLI
I want to be as objective as possible
Scenario: Positive number
When I run `co2domain portray --num 2`
Then the output should contain "positive"
Scenario: Negative number
When I run `co2domain portray --num -22`
Then the output should contain "negative"
This is my company.rb file:
module Co2domain
class Company
def self.portray(num)
if num > 0
"positive"
else
"negative"
end
end
end
end
As I am a beginner and the guide is for beginners I feel like I'm missing something small but important. Help appreciated.
The error you are seeing is equivalent to the sh: foodie: command not found error found in the guide you are using. The difference is you are using a windows machine, and the guide is using a *nix machine.
The cucumber tests are testing running a command from the shell, and the shell is not able to find the command to run. If you add the directory your program is in to your PATH, or move your program to a directory in your path, cucumber should be able to run it.

How to use whitespaces in feature names in Cucumber

I am using Windows and trying to run an existing feature pack which was initially built on Mac OS which allows them to get around the issue with using " \ " with the whitespace.
I am using Ruby 2.2.3 and Cucumber.
The feature names contain white spaces and I am unable to change this. I tried to use " " and ' ' to get around the white spaces but have the same issue each time.
Here is an example of the issue. If I run:
cucumber features/'Name containing whitespaces.feature'
it works OK.
But when I run:
cucumber -p my_profile
and cucumber.yml contains:
my_profile: features/'Name containing whitespaces.feature'
Then it fails with:
No such file or directory - features/'Name. You can use `cucumber --init` to get started.
Can anyone help me get round this issue as renaming is not an option in my case.
You can test specific features using Cucumber's # tags. I like using #wip, which stand for work in progress. For Example
In login.feature
Feature: Log in
#wip
Scenario: Successful Login
Given I do some things
Then I should be logged in
Then in the terminal you would run
cucumber --tags #wip
and it will only run the tests under that scenario or feature.
This will allow you to test specific features or scenarios in cucumber without having to worry about the whitespacing in the names.

Calling Rspec with syntax like ruby -I

I am trying to use https://github.com/rifraf/Vendorize which is run using a command like
D:\projects\SomeLibrary\lib>ruby -I..\..\Vendorize\lib -rvendorize some_lib.rb
It does something clever where it intercepts required files and logs them, but only the ones that get executed in your command line. On it's documentation pages it says
You can run the program several times with different options if the
required files depend on the options.
Or just run your tests…
I want to run all the tests with the -I function from the command line above, so that all the different avenues of code are run, and the libraries loaded (and logged). Given that I can run them like:
D:\projects\SomeLibrary\lib>rspec ..\spec\some_spec.rb
How do I do this? Thanks!
NB: I am a/ a ruby newbie and b/ running windows
I would try writing something like this at the top of some_spec.rb:
require_relative '..\..\Vendorize\lib\vendorize'
You might need to change that a bit depending on what your working directory is.
Then just runs your specs with rspec as you normally do without any extra commands.
If that doesn't work, then locate the rspec.rb executable and run:
ruby -I..\..\Vendorize\lib -rvendorize path/to/rspec.rb ..\spec\some_spec.rb

Xcode variables

In Xcode, I know that you can get variables such as PROJECT_DIR to use in some situations, such as a run script build phase. I am wondering if it's possible to get the build type (i.e., Release or Debug). Any ideas?
The best source is probably Apple's official documentation. The specific variable you are looking for is CONFIGURATION.
Here's a list of the environment variables. I think you might want CURRENT_VARIANT. See also BUILD_VARIANTS.
They're not all documented. For example, you won't find ARCHIVE_PATH, MARKETING_VERSION (the version string set in Xcode) in Naaff's or smorgan's answer. These 2 are very common pieces of information someone would need! Here's a list of all of them I got: https://gist.github.com/ben-xD/c063b0ca2c33684de1eb379bb9d6405d
How I got them
I found the best way was to print them using set, I just wrote this including a method to list all the environment variables available.
Add this to your run script (either Archive post run script, or your build phases run script, etc.):
#!/bin/sh
exec > ${PROJECT_DIR}/environment_variables.log 2>&1
set
Look in environment_variables.log and you'll see them all.

Resources