Consider a solution that uses the built-in rails testing tasks, like stackoverflow. Documentation: rubydoc. James James 1, 3 3 gold badges 20 20 silver badges 27 27 bronze badges. But this runs all test cases in the file, the question asks to run a single test Roozbeh Zabihollahi Roozbeh Zabihollahi 6, 43 43 silver badges 36 36 bronze badges. This seems to be the best answer based on the Rails guides, at least for testing a specific line. Christopher Oezbek Alupotha Alupotha 8, 4 4 gold badges 44 44 silver badges 47 47 bronze badges.
Note the word inside a pair of forward slashes can match any of the method names. Joshua Pinter I noticed this, too. Thank you so much for this answer, now I can finally run specific tests Brian Rose Brian Rose 1, 13 13 silver badges 10 10 bronze badges.
Diego Plentz Diego Plentz 5, 2 2 gold badges 28 28 silver badges 31 31 bronze badges. Aupajo Aupajo 5, 6 6 gold badges 28 28 silver badges 28 28 bronze badges. Not in Rails -- at least not with the default test files generated. If you change every first line to an explicit require "require File. Gaius Double-checked. First one doesn't work, but cd -ing in does. Just to be clear I'm not sure if I'm mis-reading this, but you did say "generated test files" , this is for the Rails library itself, not a Rails project.
Jim U Jim U 3, 1 1 gold badge 11 11 silver badges 23 23 bronze badges. Igor Kasyanchuk Igor Kasyanchuk 4 4 silver badges 12 12 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Darryl Darryl 5, 1 1 gold badge 23 23 silver badges 30 30 bronze badges. This doesn't work for me on functional or unit tests. I get 0 tests, 0 assertions, 0 failures, 0 errors. Rails 3. Shell escaping is always fun, so I tend to stick to simple regexes, but it's far easier than writing out the full test name all the time.
Groxx - Finally a solution! Thank you! It bypasses some testing tasks built into rails like db:test:prepare which are used for many things, like swapping local data for fixture data, and restoring it again. Running this blew away my local database.
Consider a solution that uses the built-in rails testing tasks, like stackoverflow. Documentation: rubydoc. James James 1, 3 3 gold badges 20 20 silver badges 27 27 bronze badges. But this runs all test cases in the file, the question asks to run a single test Roozbeh Zabihollahi Roozbeh Zabihollahi 6, 43 43 silver badges 36 36 bronze badges.
This seems to be the best answer based on the Rails guides, at least for testing a specific line. Christopher Oezbek Alupotha Alupotha 8, 4 4 gold badges 44 44 silver badges 47 47 bronze badges. Note the word inside a pair of forward slashes can match any of the method names.
Joshua Pinter I noticed this, too. Thank you so much for this answer, now I can finally run specific tests Brian Rose Brian Rose 1, 13 13 silver badges 10 10 bronze badges. Diego Plentz Diego Plentz 5, 2 2 gold badges 28 28 silver badges 31 31 bronze badges.
Aupajo Aupajo 5, 6 6 gold badges 28 28 silver badges 28 28 bronze badges. Not in Rails -- at least not with the default test files generated. HOW TO? ID : viewed : 8 Tags : ruby-on-rails unit-testing rake ruby-on-rails Top 5 Answer for unit testing - How to run a single test from a Rails test suite? Top 3 video Explaining unit testing - How to run a single test from a Rails test suite? Rails: How can I rename a database column in a Ruby on Rails migration?
How to understand nil vs. What distinguishes Heroku from AWS?
0コメント