gpt4 book ai didi

ruby-on-rails - NameError: 未初始化常量 Faker::

转载 作者:数据小太阳 更新时间:2023-10-29 06:58:10 26 4
gpt4 key购买 nike

Before(:all) do 
puts "HELLO ALL :D"
end

我的代码有问题:

/spec/factories.rb

require 'faker'
FactoryGirl.define do
factory :booking_error do
booking_id { Faker::Number.number(3).to_i }
error_type_cd BookingError.error_types.values.shuffle.first
process_name Enums::FlightEnum::PROCESSES.keys.shuffle.first
description "DESCRIPTION"
old_value "OLD_STRING"
new_value "NEW_STRING"
end
end

/spec/models/booking_error_spec.rb

require 'spec_helper'
describe BookingError do
before(:all) do
@booking_error = FactoryGirl.build(:booking_error)
@booking_error_types = BookingError.error_types
end

it 'Validating BookingError save.' do
@booking_error.save.should be_true
end
end

gem 文件

source 'https://rubygems.org'

gem 'rails', '3.2.13'

gem 'mysql2' , '0.3.11'
gem 'devise' , '2.2.0.rc'
gem 'devise-encryptable' , '0.1.1'
gem 'unicorn' , '4.5.0'
gem 'kaminari' , '0.14.1'
gem 'memcache-client' , '1.8.5'
gem 'simple_enum' , '1.6.4'
gem 'resque' , '1.23.0' , :require => "resque/server"
gem 'resque-logger' , '0.1.0'
gem 'resque-workers-lock'
gem 'whenever' , '0.8.1' , :require => false
gem 'httparty' , '0.9.0'
gem 'newrelic_rpm' , '3.6.1.88'
gem 'cancan' , '1.6.8'
gem 'rolify' , '3.2.0'
gem 'json-schema' , '1.1.1'
gem 'faker' , '1.1.2'
gem 'ruby-enum' , '0.2.1'
gem 'mail' , '2.5.4'
gem 'daemons-rails'

group :develop, :test do
gem 'capistrano' , '2.13.5'
gem 'capistrano-unicorn' , '0.1.6' , :require => false
gem 'capistrano-resque' , '~> 0.1.0' , :require => false
gem 'rvm-capistrano' , '1.2.7'
gem 'capistrano-ext'
gem 'rspec-rails' , '2.12.0'
gem 'debugger' , '1.5.0'
gem 'thin' , '1.5.0'
gem 'annotate' , '2.5.0'
gem 'factory_girl_rails' , '4.1.0'
gem 'yard' , '0.8.5.2'
end


# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'therubyracer' , '0.10.2'
gem 'coffee-rails' , '3.2.2'
gem 'uglifier' , '1.3.0'
gem 'twitter-bootstrap-rails' , '2.1.9'
gem 'sass' , '3.2.4'
gem 'jquery-ui-rails' , '3.0.0'
gem 'less-rails' , '2.2.6'
end

gem 'jquery-rails' , '2.1.4'

当我运行时:

$ rspec spec/models/booking_error_spec.rb

我得到标题中的错误:

NameError: uninitialized constant Faker::Number

最佳答案

Number 在您使用的版本 (1.1.2) 中不存在于 Faker 中。更新到 1.2.0 版即可。

关于ruby-on-rails - NameError: 未初始化常量 Faker::,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18595393/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com