黄瓜:来自数据库的意外删除对象

我使用authlogic作为身份验证系统。 我为黄瓜写了这样的场景:
  Scenario: test login
    Given there are no users
    And the following users:
      | login | 
      | user  | 
    Given I authenticate as "user" with password "password"
    Then I should not see "Login not found"
这样的步骤:
Given /^the following users:$/ do |table|
  table.hashes.each do |attributes|
    User.make(attributes)
  end
end

Given /^I authenticate as "(.+)" with password "(.+)"$/ do |login, password|
  # just for debug
  Rails.logger.info "USER!!: #{User.last.inspect}"
  And %{I go to login}
  # just for debug
  Rails.logger.info "USER!!: #{User.last.inspect}"
  And %{I fill in "user_session_login" with "#{login}"}
  And %{I fill in "user_session_password" with "#{password}"}
  And %{I press "user_session_submit"}
end

Given /^there are no users$/ do                                                                                        
  User.destroy_all
end
test.log中:
USER!!: #<User id: 1, login: "user" ... >

Processing UserSessionsController#new (for 127.0.0.1 at 2011-02-04 01:54:49) [GET]
  Parameters: {"action"=>"new", "controller"=>"user_sessions"}
Rendering template within layouts/application
Rendering user_sessions/new
Rendered partials/_message (1.3ms)
Rendered partials/_ajax_loader (0.6ms)
Completed in 63ms (View: 41, DB: 21) | 200 OK [http://www.example.com/login]
  SQL (0.1ms)   SET NAMES 'utf8'
  SQL (0.1ms)   SET SQL_AUTO_IS_NULL=0
  User Columns (0.7ms)   SHOW FIELDS FROM `users`
  User Load (0.3ms)   SELECT * FROM `users` ORDER BY users.id DESC LIMIT 1
USER!!: nil
完整的方案日志:https://gist.github.com/810405 所以在第一个“用户!!”用户在数据库中找到。但是在加载页面后,数据库中没有用户。并且没有删除日志条目! 我无法认出原因。如果我通过脚本/控制台手动执行此类操作(加载蓝图,make用户)脚本/服务器(进行登录操作),那就没问题了。 user_session的代码#new和#create:
class UserSessionsController < ApplicationController
  before_filter :require_no_user, :only => [:new, :create]

  def new
    @user_session = UserSession.new
  end

  def create
    @user_session = UserSession.new(params[:user_session], :auto_register => true)

    @user_session.save do |result|
      if result
        flash[:notice] = I18n.translate "flashes.user_session.created"
        redirect_to account_url
      else
        render :action => :new
      end
    end
  end
end
blueprints.rb(机械师):
User.blueprint do
  name 
  login { Sham.name }
  password {'password'}
  password_confirmation { password }
  email
  active {true}
end
黄瓜支持/ env.rb:https://gist.github.com/810418 宝石列表(带版本):https://gist.github.com/810394 Rails 2.3.8 + bundler,RVM + Ruby 1.8.7,Cucumber 0.9.4     
已邀请:

要回复问题请先登录注册