2011-06-11 63 views
1

在capybara 1.0.0.rc1中有一个新的dsl,与牛排非常相似。我试图在背景/部分之前设置一个灯具,但是当我调试第一个场景/例子并检查数据库时,在背景中设置的灯具不见了。我将use_transactional_fixtures设置为true,但奇怪的是,考虑到之前的背景是别名,这很重要。我究竟做错了什么?水豚请求规格DSL和交易装置

spec_helper.rb

require 'rubygems' 
require 'spork' 
require 'capybara/rspec' 

Spork.prefork do 
    # Loading more in this block will cause your tests to run faster. However, 
    # if you change any configuration or code from libraries loaded here, you'll 
    # need to restart spork for it take effect. 
    # This file is copied to spec/ when you run 'rails generate rspec:install' 
    ENV["RAILS_ENV"] ||= 'test' 
    require File.expand_path("../../config/environment", __FILE__) 
    require 'rspec/rails' 
    require File.expand_path(File.dirname(__FILE__) + "/blueprints") 

    # Requires supporting ruby files with custom matchers and macros, etc, 
    # in spec/support/ and its subdirectories. 
    Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f} 

    RSpec.configure do |config| 
    # == Mock Framework 
    # 
    # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line: 
    # 
    # config.mock_with :mocha 
    # config.mock_with :flexmock 
    # config.mock_with :rr 
    config.mock_with :rspec 

    # If you're not using ActiveRecord, or you'd prefer not to run each of your 
    # examples within a transaction, remove the following line or assign false 
    # instead of true. 
    config.use_transactional_fixtures = true 

    config.before(:all) { Sham.reset(:before_all) } 
    config.before(:each) { Sham.reset(:before_each) } 
    end 
end 

Spork.each_run do 
    # This code will be run each time you run your specs. 
end 

teacher_creates_event.rb

require 'requests/requests_helper'                  

feature "Teacher creates event" do                  
    background do                       
    Teacher.make(:username => 'testteacher', :password => 'mypassword')         
    visit new_user_session_url                   
    fill_in "Username", :with => 'testteacher'               
    fill_in "Password", :with => 'mypassword'               
    click_on "Sign in"                     
    end                         

    scenario "Teacher creates one-time event" do               
    visit studio_calendar_url                   
    click_on "New Event"                    
    fill_in "Title", :with => "Test One Time Event"              
    fill_in "Description", :with => "An event that occurs once and never repeats..."     
    fill_in "Start Date", :with => "2011-07-18"               
    fill_in "Start Time", :with => "1:00pm"                
    fill_in "End Date", :with => "2011-07-18"               
    fill_in "End Time", :with => "3:00pm"                
    uncheck "All Day"                     
    click_on "Create Event"                    
    end                         
end 

回答

0

出于某种原因,设置config.cache_classes为true在我的环境/ test.rb使其正常工作。不知道为什么。