0
我正从RSpec转换到MiniTest,并且遇到了一些困难。我一直在下面的一些例子,我发现:为什么在MiniTest中有两种控制器测试?
class ArticlesControllerTest < ActionController::TestCase
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:articles)
end
end
所以这是从的ActionController :: TestCase的,这是有道理的继承的类。
但后来也有其他的例子是这样的:
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
为什么这两种风格不同?我使用第二个例子,我的重定向没有一个像我的开发系统一样工作。试图达到它的底部。
首先是经典的测试::单位的风格,第二个更Rspec的味道。不过,除了声明测试的方式之外,它们在功能上应该是相同的。 – tadman