ruby-on-rails - RSPEC 找到了我的文件,但找不到我的示例

标签 ruby-on-rails testing rspec

所以我在我的文件中放了一个“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/

相关文章:

ruby-on-rails - 在 Ruby 1.9.3 中安装 Mongrel

haskell - 测试 Main 模块中定义的 Haskell 代码

testing - 沙箱环境测试给出 DUPLICATE_TRANSACTION 错误

ruby-on-rails - 具有自定义验证的 Shoulda Matcher 导致所有 shoulda 验证失败

ruby-on-rails - RSpec Controller 测试失败 - 如何加载模拟数据?

ruby-on-rails - 如何在Heroku中访问数据库

android - 对于使用移动应用程序的 Sorcery gem,我应该使用什么身份验证方法?

ruby-on-rails - rails 4 : How to change the output display page by page with helper

javascript - Testcafe:期望变量显示 Object 对象或 NaN

ruby - 在 RSpec 中捕获和断言 Meta 标签