I am trying to run a request spec on a form (built with Simple Form). The form includes some select boxes that are generated using the association method and therefore database values for the model.
When running save_and_open_page it doesn t look like the select the values in the drop downs.
我已经看过Mocking和Stubbing,但这对我来说是新的,我仍然对这一概念略感困惑。
是否有办法为挑选的盒子收集资料,以便Capybara能够收回吗?
I m使用铁路3.1、简单表格、Kroybara和KadoGirl。
我的法典是......
<>strong>challenge_spec
describe "New 挑战s" do
before(:all) do
%w["Under 13", "13 - 16"].each do |item|
FactoryGirl.create(:age, :name => item)
end
end
it "should redirect to resources after submission" do
login_valid_user
visit new_challenge_path
@challenge = Factory.build(:challenge)
fill_in "challenge_name", :with => @challenge.name
fill_in "challenge_description", :with => @challenge.description
fill_in "challenge_description", :with => @challenge.description
select "30 mins", :from => "challenge_timescale"
save_and_open_page
select 1, :from => "challenge_age_id"
select @challenge.category, :from => "challenge_category_id"
click_button "save_button"
end
end
<><><><><>><>>>><>>>>>>
def new
@challenge = 挑战.new
respond_to do |format|
format.html # new.html.haml
format.json { render json: @challenge }
end
end
www.un.org/Depts/DGACM/index_spanish.htm 表格
<%= f.association :age, :prompt => "Please select..." %>
Models
挑战
class 挑战 < ActiveRecord::Base
belongs_to :age
end
年龄
class 年龄 < ActiveRecord::Base
has_many :challenges
end