1

将 Rails 从 3.2.6 更新到 3.2.7 时,我的项目https://github.com/phoet/on_ruby的 RSpec 测试套件失败。

rake spec
  1) Authorization should create an auth and a user from an auth-hash
     Failure/Error: Authorization.create_from_hash(auth)
     ActiveRecord::RecordNotUnique:
       SQLite3::ConstraintException: column nickname is not unique: INSERT INTO "users" ("admin", "available", "created_at", "description", "freelancer", "github", "hide_jobs", "image", "location", "name", "nickname", "slug", "updated_at", "url") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
     # ./app/models/user.rb:74:in `create_from_hash!'
     # ./app/models/authorization.rb:15:in `create_from_hash'
     # ./spec/models/authorization_spec.rb:23:in `block (3 levels) in <top (required)>'
     # ./spec/models/authorization_spec.rb:22:in `block (2 levels) in <top (required)>'

Google Geocoding API error: over query limit.                  | ETA:  00:00:03
  2) Location finder should find users within the default scope
     Failure/Error: Location.unscoped.all.size.should be(2)

       expected #<Fixnum:5> => 2
            got #<Fixnum:21> => 10

       Compared using equal?, which compares object identity,
       but expected and actual are not the same object. Use
       'actual.should eq(expected)' if you don't care about
       object identity in this example.
     # ./spec/models/location_spec.rb:16:in `block (3 levels) in <top (required)>'

直接运行RSpec不会出现这个问题,travis上也不会出现:http ://travis-ci.org/#!/phoet/on_ruby/builds/1989858

看起来好像事务没有正确回滚。有人经历过类似的行为吗?

有任何想法吗?

4

1 回答 1

2

我也一样。据我所知,rails 现在设置了 ENV['RAILS_ENV']=development,因此您的测试正在针对您的开发数据库运行。尝试rake spec RAILS_ENV=test

看起来是这个问题:https ://github.com/rails/rails/issues/7175

于 2012-07-30T22:05:25.767 回答