testunit

How can I tell Rails to use RSpec instead of test-unit when creating a new Rails app?

早过忘川 提交于 2019-12-02 15:45:01
I have test-unit installed and rspec installed (along with -core , -expectations , -mocks and -rails version 2.6.x). When I run the command rails new foo , it uses test-unit to generate the test stub files instead of rspec . Is there an option where I can tell rails to use rspec to generate the tests instead? The following should work: at command line: rails new MYAPP -T # The -T option tells rails not to include Test::Unit in Gemfile: gem 'rspec-rails' at command line: bundle install rails g rspec:install Create your new rails application as: rails new <app_name> -T Or remove your test

Mocha: stubbing method with specific parameter but not for other parameters

旧街凉风 提交于 2019-12-01 03:15:26
I want to stub a method with Mocha only when a specific parameter value is given and call the original method when any other value is given. When I do it like this: MyClass.any_instance.stubs(:show?).with(:wanne_show).returns(true) I get an unexpected invocation for MyClass.show?(:other_value) I also know, that I can stub all parameters when writing the mock without the ´with´-call and then give my specific mock. But then I have to know the return value for every call, which is not the case :/ tldr; Is there a way to call the original method in a stub or to stub just specific parameters and

minitest, test::unit, and rails

…衆ロ難τιáo~ 提交于 2019-12-01 02:06:25
I read somewhere that 'minitest' is the "new test::unit for ruby 1.9.2+". But ruby 1.9.3 seems to include both test::unit and minitest , is that true? In the default rails testing, as outlined in the Rails testing guide .... things like ActiveSupport::TestCase , ActionController::TestCase , are these using Test::Unit or Minitest ? In the rails guide, it shows examples with tests defined like this: test "should show post" do get :show, :id => @post.id assert_response :success end That syntax, test string , as opposed to defining methods with names like test_something -- isn't mentioned in the

minitest, test::unit, and rails

試著忘記壹切 提交于 2019-11-30 21:29:02
问题 I read somewhere that 'minitest' is the "new test::unit for ruby 1.9.2+". But ruby 1.9.3 seems to include both test::unit and minitest, is that true? In the default rails testing, as outlined in the Rails testing guide.... things like ActiveSupport::TestCase , ActionController::TestCase , are these using Test::Unit or Minitest ? In the rails guide, it shows examples with tests defined like this: test "should show post" do get :show, :id => @post.id assert_response :success end That syntax,

In Ruby, how to I control the order in which Test::Unit tests are run?

雨燕双飞 提交于 2019-11-30 07:28:14
For example, when these tests are run, I want to ensure that test_fizz always runs first. require 'test/unit' class FooTest < Test::Unit::TestCase def test_fizz puts "Running fizz" assert true end def test_bar puts "Running bar" assert true end end Update : Why do I want to do this? My thought is that early failure by certain tests (those testing the simpler, more fundamental methods) will make it easier to track down problems in the system. For example, the success of bar hinges on fizz working correctly. If fizz is broken, I want to know that right off the bat, because there's no need to

How to output names of ruby unit tests

白昼怎懂夜的黑 提交于 2019-11-30 05:15:36
I have a unit test (example is modified Test::Unit documentation ) require 'test/unit' class TC_MyTest < Test::Unit::TestCase def test_something assert(true) end end When I execute it, I get: Loaded suite C:/test Started . Finished in 0.0 seconds. 1 tests, 1 assertions, 0 failures, 0 errors I would like to get something like this ( test_something is outputted): Loaded suite C:/test Started test_something . Finished in 0.0 seconds. 1 tests, 1 assertions, 0 failures, 0 errors If you're testing in rails you can use rake test TESTOPTS=-v Run unit test with verbose option. test.rb -v v or test.rb -

In Ruby, how to I control the order in which Test::Unit tests are run?

与世无争的帅哥 提交于 2019-11-29 09:23:25
问题 For example, when these tests are run, I want to ensure that test_fizz always runs first. require 'test/unit' class FooTest < Test::Unit::TestCase def test_fizz puts "Running fizz" assert true end def test_bar puts "Running bar" assert true end end Update : Why do I want to do this? My thought is that early failure by certain tests (those testing the simpler, more fundamental methods) will make it easier to track down problems in the system. For example, the success of bar hinges on fizz

Rspec vs. TestUnit

我怕爱的太早我们不能终老 提交于 2019-11-28 17:23:13
问题 I'm beginning the planning phase of creating a testing suite for my rails 3.0.8 application. I'm trying to decide on which testing framework/gems to use. Normally I prefer to stick to Rails convention as much as possible. However, this means using TestUnit. There are many competing test frameworks to choose from that were created as an alternative to TestUnit. Has TestUnit gotten better over the years, or is it not a very good contender? I've also heard of a lot of good things about rspec.

Ruby on Rails: Switch from test_unit to rspec

浪尽此生 提交于 2019-11-28 14:37:01
问题 I'm going through a tutorial that has suggested using rspec , but I have already gone through a lot of default rails installation. I really don't want to have to redo the installation at all. Anyway, when I run $ rails g integration_test named I get invoke test_unit create test/integration/named_test.rb When I run bundle , various rspec gems are listed, but test_unit is not. The tutorial seems to have rails invoke rspec instead of test_unit without doing anything additional. How do I get

In Ruby's Test::Unit::TestCase, how do I override the initialize method?

泪湿孤枕 提交于 2019-11-27 05:10:52
问题 I'm struggling with Test::Unit. When I think of unit tests, I think of one simple test per file. But in Ruby's framework, I must instead write: class MyTest < Test::Unit::TestCase def setup end def test_1 end def test_1 end end But setup and teardown run for every invocation of a test_* method. This is exactly what I don't want. Rather, I want a setup method that runs just once for the whole class. But I can't seem to write my own initialize() without breaking TestCase's initialize. Is that