मैं व्यक्तियों की बिलिंग के लिए एक सेटअप स्क्रीन बना रहा हूं। नियंत्रक/विचार व्यवस्थापक नामस्थान में हैं।आरएसपीसी-रेल-कैपिबरा - विभिन्न विफलताओं के साथ: जेएस => सत्य और बिना
बिना पहले परीक्षण चलाएं: जेएस => सच मुझे एक विफलता मिलती है, जो मुझे लगता है कि यह लिंक इस तथ्य के नीचे है कि लिंक एक सहायक के रूप में काम नहीं करता है जो फ़ील्ड के नेस्टेड सेट बनाने के लिए जेएस स्क्रिप्ट का उपयोग करता है (Railscasts एकल रूप के आधार पर, एकाधिक टेबल - नेस्टेड विशेषताएँ)।
Failures:
1) Patient Setup create patient bill heading - with extended details -with valid data
Failure/Error: fill_in "Extended Bill Heading", :with => 'Regular Registration'
Capybara::ElementNotFound:
cannot fill in, no text field, text area or password field with id, name, or label 'Extended Bill Heading' found
# (eval):2:in `fill_in'
# ./spec/requests/admin/patient_setup_pages_spec.rb:52:in `block (4 levels) in <top (required)>'
Finished in 0.83047 seconds
3 examples, 1 failure, 2 pending
लेकिन जब मैं का उपयोग करें: जे एस = सच है, मैं एक विफलता जो अमान्य उपयोगकर्ता/पासवर्ड स्क्रीन पर चमकती जब चल रहा है के साथ लॉगिन से प्रतीत होता है हो रही है।
Failures:
1) Patient Setup create patient bill heading - with extended details -with valid data
Failure/Error: click_link 'System'
Capybara::ElementNotFound:
no link with title, id or text 'System' found
# (eval):2:in `click_link'
# ./spec/requests/admin/patient_setup_pages_spec.rb:22:in `block (2 levels) in <top (required)>'
Finished in 6.33 seconds
3 examples, 1 failure, 2 pending
यहाँ कोड है कि यह सभी बैक अप ले लेता है।
spec/requests/admin/patient_setup_spec.rb
require 'spec_helper'
feature 'Patient Setup' do
let!(:ci_user) { FactoryGirl.create(:user,
name: "configuration engineer",
password: "password",
password_confirmation: "password"
) }
let!(:admin_role) { FactoryGirl.create(:admin_role) }
let!(:assignment) { FactoryGirl.create(:assignment,
:role => admin_role,
:user => ci_user
) }
before do
visit login_path
fill_in "Name", with: "configuration engineer"
fill_in "Password", with: "password"
click_button "Login"
save_and_open_page
click_link 'System'
click_link 'Patient Setup'
end
describe "create patient bill heading" do
before do
click_link 'New Bill Heading'
fill_in 'Bill heading', :with => 'Consultation'
fill_in 'Abbreviation', :with => "CON"
end
context "- no extended details" do
pending
scenario "- with valid data" do
pending
click_button 'Create Patient bill heading'
page.should have_content('Patient Bill Heading created.')
end
end
context "- with extended details", :js => true do #(without :js => true 1st error)
before do
# save_and_open_page
click_link "Extended Bill Heading"
# save_and_open_page
end
scenario "-with valid data" do
save_and_open_page
fill_in "Extended Bill Heading", :with => 'Regular Registration'
end
end
end
end
यहां मेरा कारखाना सेटअप है।
spec/factories.rb
FactoryGirl.define do
# Users, Roles
factory :user do
name "Joesephine Bloggs"
password "testmenow"
password_confirmation "testmenow"
end
factory :admin, :class => User do
sequence(:name) { |n| "Administrator-#{n}" }
password "adminiam"
password_confirmation "adminiam"
after(:create) do |user|
FactoryGirl.create(:assignment, :role => FactoryGirl.create(:admin_role), :user => user)
end
end
factory :role do
description { "Clerical-#{rand(99)}" }
factory :admin_role do
description "Admin"
end
end
factory :assignment do
user
role
end
# Patients Module
factory :patient_bill_heading do
sequence(:bill_heading) { |n| "bill-heading-#{n}" }
sequence(:abbreviation) { |n| "abbreviation-#{n}" }
factory :delete_patient_bill_heading, :class => PatientBillHeading do
bill_heading :bill_heading
abbreviation :abbreviation
end
end
end
यहाँ मेरे विचार में लिंक सहायक कि नेस्टेड विशेषता क्षेत्रों उत्पन्न करता है कॉल करने के लिए है।
<p>
<%= link_to_add_fields "Extended Bill Heading", f, :patient_extended_bill_headings %>
</p>
और यहां सहायक है।
helpers/application_helper.rb
def link_to_add_fields(name, f, association, options={})
defaults = {
:partial_name => nil
}
options = defaults.merge(options)
new_object = f.object.send(association).klass.new
id = new_object.object_id
fields = f.fields_for(association, new_object, child_index: id) do |builder|
if options[:partial_name].nil?
render(association.to_s.singularize + "_fields", f: builder)
else
render(options[:partial_name], f: builder)
end
end
link_to("#{name} <i class='icon-plus icon-white'></i>".html_safe,
'#',
class: "btn btn-success add_fields",
data: {id: id, fields: fields.gsub("\n", "")}
)
end
मैं अपने RSpec परीक्षण ज्ञान में सुधार करने, जैसा कि मैंने सफलतापूर्वक एक घंटे कारण है कि मैं परीक्षण विफलताओं हो रही थी यह पता लगाने की कोशिश कर के बाद अपने आवेदन में यह काम कर निर्माण किया है कोशिश कर रहा हूँ। तो ऐप में यह काम करता है, लेकिन मैं समझना चाहता हूं कि मेरा टेस्ट पास कैसे करें।
क्या मेरा दावा है कि एक त्रुटि लिंक बनाने के लिए जेएस का उपयोग करने के कारण है, और capybara इसे नहीं चला रहा है क्योंकि मैं: js => true विकल्प का उपयोग नहीं करता हूं?
कोई भी देख सकता है कि मैं क्या कर रहा हूं: js => true विकल्प का उपयोग करते समय मैं गलत कर रहा हूं?
धन्यवाद वी, कि समस्या हल हो। अब मेरा अगला हल करने के लिए कैनकन 'load_and_authorize_resource' है! – user1149642
मुझे लगता है कि आपको वह वाक्यविन्यास गलत मिला है, यह 'config.before (: प्रत्येक) करते हैं | उदाहरण | '? – Noz
नहीं, यह काम करता है - मैं एक परियोजना में उस वाक्यविन्यास का उपयोग करता हूं। मैंने स्रोत कोड में बहुत कुछ नहीं पढ़ा। लेकिन मेरा अनुमान है कि इसमें https://github.com/rspec/rspec-core/blob/master/lib/rspec/core/example_group.rb#L440 के साथ कुछ करना है। आपका वाक्यविन्यास शायद भी काम करेगा। – Wei