1

我的 Gemfile 看起来像这样:-

group :test do
  # Pretty printed test output
  gem 'capybara'#,'1.1.2'
  gem 'cucumber-rails','1.2.1'
  gem 'cucumber','1.1.4'
  gem 'rspec-rails','2.8.1'
  gem 'rspec-cells','0.1.2'
  gem "factory_girl_rails"
  gem "guard-rspec"
  gem "minitest"
  gem 'headless'
  gem 'minitest-rails'
  gem 'minitest-rails-capybara'  
 end

minitest_helper.rb 看起来像:-

ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "minitest/autorun"
require "capybara/rails"


class ControllerTest  < MiniTest::Spec
 include Rails.application.routes.url_helpers
 include Capybara::DSL
 register_spec_type(/integration$/, self)
end

我的 products_controller_test.rb 看起来像这样:-

require "minitest_helper"


describe "Products Controller" do
   it "shows product's name" do  
    uname="Glasses"

    product1 = Product.create!(:name => uname, :description => uname, :no_of_items =>    3,:fee_percentage => 4)
    visit products_path
    page.text.must_include "Glasses"
  end

   end

但是..在执行 ruby​​ 之后-Itest test/controllers/products_controller_test.rb

我没有收到错误,没有迹象表明该测试类已加载:-

ruby -Itest test/controllers/products_controller_test.rb
:public is no longer used to avoid overloading Module#public, use :public_folder instead
    from /usr/local/rvm/gems/ruby-1.9.2-p290/gems/resque-1.19.0/lib/resque/server.rb:12:in `<class:Server>'
Loaded suite test/controllers/products_controller_test
Started

Finished in 0.004953 seconds.

0 tests, 0 assertions, 0 failures, 0 errors, 0 skips

这是我第一次使用 Minitest ......

4

1 回答 1

0

你的 Gemfile 有点重......如果你删除所有的 RSpec 引用,你会运行得很好。

(“描述”和“它”方法被 rspec 篡夺了)

消除:

 gem 'rspec-rails','2.8.1'
 gem 'rspec-cells','0.1.2'
于 2012-11-08T15:45:10.047 回答