내가 Minitest와 비트 주위에 놀고 있었고, 나는 아주 간단한 모델을 테스트 파일로이Minitest는 두 개의 연속 실행
에 대한 설명을 찾을 수 없습니다 동작을 발견에 다른 결과를 제공합니다 다음 : 난 후 처음으로이 코드를 실행하면
require 'minitest_helper'
describe User do
before do
@user = User.new(name: "Example User", email: "[email protected]",
password: "foobards", password_confirmation: "foobards")
end
describe "with admin attribute set to 'true'" do
before { @user.toggle!(:admin) }
it { @user.admin.must_equal true }
end
end
는 '레이크 DB : 테스트 : 준비', 테스트를 통과
내가 2 년 연속 시간 동안 실행, 그것은 나를을 제공합니다 오류 :
test_0001_anonymous 0:00:00.132
ERROR SQLite3::ConstraintException: column email is not unique: INSERT INTO "users" ("admin", "created_at", "email", "name", "password_digest", "updated_at") VALUES (?, ?, ?, ?, ?, ?)
는 그러나이 오류는 내가 꺼내 경우가 발생하지 않는 것
before { @user.toggle!(:admin) }
다음과 같이 내 minitest_helper.rb은 다음과 같습니다
ENV["RAILS_ENV"] = "test"
require File.expand_path("../../config/environment", __FILE__)
require "minitest/autorun"
require "capybara/rails"
require "active_support/testing/setup_and_teardown"
class IntegrationTest < MiniTest::Spec
include Rails.application.routes.url_helpers
include Capybara::DSL
register_spec_type(/integration$/, self)
end
class HelperTest < MiniTest::Spec
include ActiveSupport::Testing::SetupAndTeardown
include ActionView::TestCase::Behavior
register_spec_type(/Helper$/, self)
end
Turn.config.format = :outline
내가이 경우 이해 수없는 것 버그 또는 if (더 있음직 한) 나는 무엇인가 놓치고있다. 나보다 지식이 많은 사람이 설명해 주시겠습니까?
멋진으로 ORMs의 범위에 대해 여러 전략 (트랜잭션, 절단 등)을 database_cleaner 보석이 일을하는 한 가지 방법입니다
실행하고 지원합니다. rake db : test : prepare everytime을 호출하는 것 외에 Minitest로 테스트를 실행하기 전에 깨끗한 데이터베이스/세션을 보장하는 좋은 방법을 알고 있습니까? 나는 이것이 rspec에 관한 많은 이슈가 아니라고 느낀다. – hangsu