活动管理员的功能rspec

活动管理员的功能rspec,rspec,cucumber,rspec-rails,rspec2,cucumberjs,Rspec,Cucumber,Rspec Rails,Rspec2,Cucumberjs,下面是我的活动管理资源文件和rspec功能 当我运行rspec时…它失败失败/错误:选择全年,从:从财务月 Capybara::ElementNotFound: 找不到全年的选项 有人能帮忙吗 ****资源文件:我已经让jst发布了我的资源文件的表单操作,这与我面临的问题有关**** ActiveAdmin.register ------------(code) --------------------------------(code) form do |f| f.inputs do

下面是我的活动管理资源文件和rspec功能

当我运行rspec时…它失败失败/错误:选择全年,从:从财务月 Capybara::ElementNotFound: 找不到全年的选项 有人能帮忙吗

****资源文件:我已经让jst发布了我的资源文件的表单操作,这与我面临的问题有关****

ActiveAdmin.register ------------(code)
 --------------------------------(code)
form do |f|
f.inputs do

  f.input :from_model_id, as: :select, collection: P*****::FinanceModel.all, label: 'From Finance Model', input_html: {
      onchange: remote_get('p**_***_revenue_variance_mapping_from_model_id', 'p**_***_revenue_variance_mapping_from_finance_month_id')}

  f.input :lrp_from_year, as: :select, collection: ["LRP 1st YEAR","LRP 2nd YEAR"], input_html: {disabled: true }, label: 'Lrp From Year'
  f.input :from_finance_month_id, as: :select, collection: P*****::FinanceMonth.for_revenue_variance_mapping(f.object.from_model_id), label: 'From Finance Month'

end

f.actions
end
end
Feature spec此规范测试当单击新资源按钮并用相应的值填充表单时,相应的记录应显示在索引页上

FinanceMonth模型:此模型中的方法“for_revenue_variance_mapping”以上述资源文件的动作形式调用

这意味着它所说的:没有找到元素。具体来说,Capybara希望在名为From Finance Month的select元素中找到一个值为Full Year的选项。但是为什么呢?如果看不到测试在浏览器中实际运行,就很难知道原因


您需要提供关于测试产生的输出的更多细节。也许您可以尝试中的建议,看看页面上有哪些元素。

请格式化代码,使其可读。您可能想查看关于提出好问题的提示:如果您看到资源文件->表单操作f.input:from\u finance\u month\u id,as::select,collection:PamClient::FinanceMonth.for\u revenue\u variance\u mappingf.obj‌​例如,从_model_id,标签:'from Finance Month',在模型'FinanceMonth'上使用'fir_revenue_variance_mapping'方法。对于上面资源文件的一些选择元素,在表单操作中还进行了一些ajax调用。我想我必须使用存根或模拟bt,我不知道如何使用它来获得@zettetic的值
 require 'spec_helper'---(code)

 ------------------------(code)
def i_click_on_new_revenue_variance_mapping
click_on "New Revenue Variance Mapping"
select "2012", from: "From year"
select "Budget", from: "From Finance Model"
select "Full-Year", from: "From Finance Month"

click_on "Create Revenue variance mapping"
 end

 def i_should_see_the_new_revenue_variance_mapping_in_the_index
  -----(code)
  )

 end
 end
module P######
 class FinanceMonth < ActiveRecord::Base
  include HasNamespacedName
  ------(code)
    def self.for_revenue_variance_mapping finance_model
  if !finance_model.nil?
  full_year_model_types = P****::FinanceModelType.where(P*****::FinanceModelType.arel_table[:finance_model_type_name].not_eq('CURRENT YEAR -    MONTHLY'))
  full_year_models = P*****::FinanceModel.order(:display_order).where(finance_model_type_id: full_year_model_types.map(&:finance_model_type_id))
  finance_model_ids = full_year_models.map(&:finance_model_id)
  if finance_model_ids.include? (finance_model.to_i)
models = [P*****::FinanceMonth.yearly_month]
  else if finance_model_ids.include? (finance_model)
         models = [P*****::FinanceMonth.yearly_month]
       else
         models = *****::FinanceMonth.twelve_months
       end
  end
Capybara::ElementNotFound: Unable to find option "Full-Year"