minitest, test::unit, and rails

There is a Test::Unit “compatibility” module that comes with Minitest, so that you can (presumably) use your existing Test::Unit tests as-is. This is probably the Test::Unit module you are seeing. As of rails 3.2.3, generator-created tests include rails/test_help which includes test/unit. The test “something” do syntax is a rails extension. It’s defined in ActiveSupport::Testing::Declarative, which … Read more

How to use assert_select to test for presence of a given link?

In assert_select, you can also use a question mark for the attribute value, and then follow with a string to match. assert_select “a[href=?]”, “https://stackoverflow.com/desired_path/1” There’s another way to use assert_select that is more friendly, especially if you want to match a partial string or regexp pattern: assert_select “a”, :href => /acebook\.com\/share/

Ruby on Rails: Switch from test_unit to rspec

In your config/application.rb file : config.generators do |g| g.test_framework :rspec end Now when you run your generators (example rails generate scaffold post), you get rspec test files. Remember to restart your server. For more information on generators see: RailsCasts #216 Generators in Rails 3 If you really want to use the integration_test generator you’ll need … Read more