I have the following file:
/spec/controllers/groups_controller_spec.rb
What command in terminal do I use to run just that spec and in what
@apneadiving answer is a neat way of solving this. However, now we have a new method in Rspec 3.3. We can simply run rspec spec/unit/baseball_spec.rb[#context:#it] instead of using a line number. Taken from here:
RSpec 3.3 introduces a new way to identify examples[...]
For example, this command:
$ rspec spec/unit/baseball_spec.rb[1:2,1:4]…would run the 2nd and 4th example or group defined under the 1st top-level group defined in spec/unit/baseball_spec.rb.
So instead of doing
rspec spec/unit/baseball_spec.rb:42 where it (test in line 42) is the first test, we can simply do
rspec spec/unit/baseball_spec.rb[1:1] or rspec spec/unit/baseball_spec.rb[1:1:1] depending on how nested the test case is.