当我运行我的规范时,我突然得到一个奇怪的错误,这导致我的规格失败。这些规格之前找到了 - 但最近我们从Rails 3.0升级 - > Rails 3.1。似乎机械师在尝试为我的测试创建数据时遇到了一些问题,但我不明白为什么'rand'突然无法使用。
任何事情/提示都会非常感激。
以下是我的蓝图中的一行:
Invoice.blueprint do
invno { Faker::Base.bothify(["#######", "N######", "C######"].rand) }
order_no { Faker::Base.numerify("N######") }
以下是有关我的环境的一些信息 -
ruby -v:
ruby 1.9.2p290 (2011-07-09 revision 32553) [i686-linux]
rvm和rvm list(显示我的gemset):
rvm 1.8.5 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]
=> ruby-1.9.2-p290 [ i386 ]
以下是正在发生的错误:
NoMethodError: private method `rand' called for ["#######", "N######", "C######"]:Array
/home/tom/work/ruby/litdistco-sales/spec/blueprints.rb:93:in `block (2 levels) in <top (required)>'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/machinist-1.0.6/lib/machinist.rb:77:in `generate_attribute_value'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/machinist-1.0.6/lib/machinist.rb:46:in `method_missing'
/home/tom/work/ruby/litdistco-sales/spec/blueprints.rb:93:in `block in <top (required)>'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/machinist-1.0.6/lib/machinist.rb:20:in `instance_eval'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/machinist-1.0.6/lib/machinist.rb:20:in `run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/machinist-1.0.6/lib/machinist/active_record.rb:53:in `make'
/home/tom/work/ruby/litdistco-sales/spec/models/invoice_sales_tax_assignment_mixin_spec.rb:7:in `block (3 levels) in <top (required)>'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in `instance_eval'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in `run_in'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in `block in run_all'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in `each'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in `run_all'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:116:in `run_hook'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in `block in eval_before_eachs'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in `each'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in `eval_before_eachs'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:145:in `run_before_each'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:47:in `block in run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:107:in `with_around_hooks'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:45:in `run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:294:in `block in run_examples'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in `map'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in `run_examples'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:262:in `run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `block in run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `map'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in `run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `block (2 levels) in run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `map'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in `block in run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/reporter.rb:12:in `report'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:21:in `run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in `run_in_process'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in `run'
/home/tom/work/ruby/litdistco-sales/foreman/ruby/1.9.1/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in `block in autorun'