所以我在我的文件中放了一个“hello world”,以确保我正在访问该文件,果然,它被打印出来了。但是,我的示例都没有运行。它说“没有找到例子”。有什么想法吗?
require 'rails_helper'
class PostsControllerTest < ActionController::TestCase
print "hello world"
setup do
@post = posts(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:posts)
end
test "should get new" do
get :new
assert_response :success
end
test "should create post" do
assert_difference('Post.count') do
post :create, post: { body: @post.body, title: @post.title }
end
assert_redirected_to post_path(assigns(:post))
end
test "should show post" do
get :show, id: @post
assert_response :success
end
test "should get edit" do
get :edit, id: @post
assert_response :success
end
test "should update post" do
patch :update, id: @post, post: { body: @post.body, title: @post.title }
assert_redirected_to post_path(assigns(:post))
end
test "should destroy post" do
assert_difference('Post.count', -1) do
delete :destroy, id: @post
end
assert_redirected_to posts_path
end
end
如果更多代码有帮助,请告诉我。谢谢。
最佳答案
那不是rspec,那是testunit,你不用rspec运行它,你用rake test
运行它
关于ruby-on-rails - RSPEC 找到了我的文件,但找不到我的示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29503626/