【发布时间】:2015-11-10 06:59:49
【问题描述】:
以下是我的活动管理资源文件和 rspec 功能。
当我运行 rspec 时...失败失败/错误:选择“全年”,来自:“来自财务月” 水豚::ElementNotFound: 找不到“全年”选项 谁能帮忙???
****资源文件:(我已经发布了与我面临的问题相关的资源文件的表单操作)****
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
功能规范(该规范测试当点击一个新的资源按钮并用相应的值填充表单时,相应的记录应该显示在索引页面上)
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
FinanceMonth模型:(该模型中的方法'for_revenue_variance_mapping'在上面资源文件的表单动作中调用)
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
【问题讨论】:
-
请格式化代码以使其可读。您可能需要查看提出好问题的提示:stackoverflow.com/help/how-to-ask
标签: rspec cucumber rspec-rails rspec2 cucumberjs