点这篇文章Factory Girl
如果无法升级到Ruby 1.9和Rails 3,则可以继续使用factory_girl_rails版本1.x和FactoryGirl 2.x;那些将继续支持Ruby 1.8.7+和Rails 2.3.9 +。
我正在尝试使用Ruby 1.8.7将工厂女孩设置为Rails 2.3.14,但仍然无法捆绑:
Bundler could not find compatible versions for gem "rails":
In Gemfile:
factory_girl_rails (= 1.0.0) ruby depends on
rails (>= 3.0.0.beta4) ruby
rails (2.3.14)
的Gemfile
source :rubygems
source "http://gems.github.com"
gem "rails", "2.3.14"
gem "rspec", "1.2.6"
gem "rspec-rails", "1.2.6"
gem "factory_girl_rails", "1.0.0"
欢迎任何帮助。
答案 0 :(得分:3)
我尝试与您进行相同的设置,但factory_girl_rails
依赖于版本1.0的Rails 3,根据依赖项部分
https://rubygems.org/gems/factory_girl_rails/versions/1.0
您的Gemfile
应如下所示:
source :rubygems
group :development, :test do
gem "factory_girl", "2.6.4"
gem "rspec", "1.3.2", :require => false
gem "rspec-rails", "1.3.4", :require => false
end
group :test do
gem "capybara", "1.1.1"
gem "cucumber-rails", "0.3.2"
gem "database_cleaner"
gem 'email_spec'
end
factory_girl_rails的作用基本上是设置fixture_replacement选项(我不认为存在于Rails 2.3中),工厂路径和设置生成器。
我想我们必须调整此处https://github.com/thoughtbot/factory_girl_rails/blob/master/lib/factory_girl_rails/railtie.rb中的代码,通过调整Rspec和Cucumber配置文件使其适用于Rails 2.3。
答案 1 :(得分:0)
您可以尝试更改您的Gemfile:
source :rubygems
source "http://gems.github.com"
为此
source 'http://rubygems.org'