Ruby on rails 4 为什么MiniTest中有两种控制器测试?
我正在从RSpec转换到MiniTest,在这方面有一些困难。我一直在遵循我发现的一些例子:Ruby on rails 4 为什么MiniTest中有两种控制器测试?,ruby-on-rails-4,minitest,ruby-on-rails-4.2,Ruby On Rails 4,Minitest,Ruby On Rails 4.2,我正在从RSpec转换到MiniTest,在这方面有一些困难。我一直在遵循我发现的一些例子: class ArticlesControllerTest < ActionController::TestCase test "should get index" do get :index assert_response :success assert_not_nil assigns(:articles) end end 为什么这两种风格不同?我使用的是第二
class ArticlesControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:articles)
end
end
为什么这两种风格不同?我使用的是第二个示例,我的重定向没有一个像在我的开发系统中那样工作。第一个是Minitest::Unit test语法解释
第二种更像Rspec语法,您可以使用gem来实现这一点第一种是经典的Test::Unit风格,第二种更像Rspec风格。但是,它们在功能上应该是相同的,不同于如何声明测试。
require 'test_helper'
describe ThingsController do
describe "#create" do
it do "valid"
login_user
post :create, { catalog: { name: "My Thing", description: "Description of my thing."}}
assert_redirected_to thing_path(Thing.last)
end
end
end