के साथ नियंत्रक का परीक्षण मेरे पास मॉडल हैं: पोस्ट और उपयोगकर्ता (डेविस)। मैं नियंत्रक पोस्ट का परीक्षण कर रहा हूँ।आरएसपीसी, डेविस, फैक्टरी गर्ल
describe "If user sign_in" do
before(:all){
@user = Factory(:user)
}
it "should get new" do
sign_in @user
get 'new'
response.should be_success
response.should render_template('posts/new')
end
it "should create post" do
sign_in @user
post 'create', :post => Factory(:post)
response.should redirect_to(post_path(:post))
end
end
लेकिन दूसरे टेस्ट में विफल रहता है:
Failure/Error: post 'create', :post => Factory(:post) ActiveRecord::RecordInvalid: Validation failed: Email has already been taken, Email has already been taken, Username has already been taken
मैं इसे कैसे ठीक कर सकता हूँ?
जब मैं spec_helper में अपना कोड शामिल करता हूं। मुझे त्रुटि मिली विफलता/त्रुटि: बैकट्रैस से सक्रिय लाइन ढूंढने में असमर्थ ActiveRecord :: स्टेटमेंट इन्वालिड: SQLite3 :: SQLException: लेनदेन के भीतर लेनदेन शुरू नहीं कर सकता: लेनदेन शुरू करें – Mike
आपको इसके लिए एक और मणि की आवश्यकता नहीं है। – coneybeare
मैंने पाया कि SQLite अपवाद समाधान 'clean_with (: truncation)' को निकालने के लिए था और रणनीति को पूरी तरह से 'DatabaseCleaner.strategy =' truncation' – Dan