How do you run a single test/spec file in RSpec?

前端 未结 14 1703
-上瘾入骨i
-上瘾入骨i 2020-12-12 08:45

I want to be able to run a single spec file\'s tests — for the one file I\'m editing, for example. rake spec executes all the specs. My project is not a

14条回答
  •  情深已故
    2020-12-12 09:23

    Ruby 1.9.2 and Rails 3 have an easy way to run one spec file:

      ruby -I spec spec/models/user_spec.rb
    

    Explanation:

    • ruby command tends to be faster than the rake command
    • -I spec means "include the 'spec' directory when looking for files"
    • spec/models/user_spec.rb is the file we want to run.

提交回复
热议问题