【问题标题】:Rspec tests passing without actions being implementedRspec 测试通过但未执行操作
【发布时间】:2013-04-28 20:54:20
【问题描述】:

您好,我正在开发一个 Rails 项目,使用 vagrant box(ubuntu 服务器完全配置了乘客,尝试在类似生产的环境中进行开发,因为这是我的目标生产环境)。

我的问题是,当我运行“rails g controller people”时,我编写了一个简单的控制器规范,例如;

require 'spec_helper'

describe PeopleController do
  describe "GET #index" do
    it "responds with success" do
      get :index
      expect(response).to be_success
    end
  end
end

我使用“rspec spec/controllers/”运行它,即使没有在控制器中创建索引操作,测试也会立即通过。

您认为这可能是什么原因造成的? 谢谢你

【问题讨论】:

    标签: ruby-on-rails passenger rspec-rails vagrant


    【解决方案1】:

    app/views/people 中有 index.html.erb 吗?如果是这样,Rails 会为您隐式创建一个呈现模板的操作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-04
      • 2017-01-24
      • 2011-07-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多