相关疑难解决方法(0)

在每个之前的所有vs之前的轨道rspec

contest_entry_spec.rb

    require 'spec_helper'

    describe ContestEntry do

      before(:all) do
        @admission=Factory(:project_admission)
        @project=Factory(:project_started, :project_type => @admission.project_type)
        @creative=Factory(:approved_creative, :creative_category => @admission.creative_category)
        @contest_entry=Factory(:contest_entry, :design_file_name => 'bla bla bla', :owner => @creative, :project => @project)
      end

      context 'non-specific tests' do
        subject { @contest_entry }
        it { should belong_to(:owner).class_name('User') }
        it { should belong_to(:project) }
        it { should have_many(:entry_comments) }

        it { should validate_presence_of(:owner) }
        it { should validate_presence_of(:project) }
        it { should validate_presence_of(:entry_no) }
        it { should validate_presence_of(:title) }

      end
end
Run Code Online (Sandbox Code Playgroud)

当我运行这些测试时,一切都很好,但是如果我在(:all)之前改变(之前):(每次),每次测试都会失败.我不知道为什么会发生这种情况?

这是错误

 Failure/Error: @contest_entry=Factory(:contest_entry, :design_file_name …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails

70
推荐指数
3
解决办法
5万
查看次数

标签 统计

rspec ×1

ruby-on-rails ×1