इम एक शर्त है जहाँ सफल साइनअप पर एक सफलता खाका निम्नलिखित नियंत्रक कोडRspec परीक्षण टेम्पलेट्स प्रदान की जा रही
def create
@user = User.new(params[:user])
if @user.save
render :template => "success"
else
flash[:notice] = "Oops Somethings not quite right! :("
render :action => "new"
end
end
मैं इस कोड
before(:each) do
@user = User.new
@user.attributes = valid_attributes
@params = valid_attributes
@user.stub!(:save).and_return(true)
end
def do_post
post :create
end
it "should create new user " do
count = User.count
do_post
user = User.new(@params)
user.save.should eql(true)
User.count.should eql(count + 1)
end
it "should render the success page on successful signup" do
do_post
@user.save
response.should render_template("success") if @user.save
end
बाहर का परीक्षण करने के बाद कल्पना का उपयोग कर रहा द्वारा प्रदान की गई है परीक्षण करने के लिए कोशिश कर रहा है
लेकिन उदाहरण के लिए विफल रहता है यह त्रुटि संदेश
1)
'UsersController handling POST /users should render the success page on successful signup' FAILED
expected "success", got "users/new.html.erb"
./spec/controllers/users_controller_spec.rb:67:
के साथ "यह सफल साइनअप पर सफलता पेज प्रस्तुत करना चाहिए"
सफलता दृश्य दृश्य/उपयोगकर्ताओं/बिना किसी कार्रवाई के संग्रहीत टेम्पलेट है। मैं अनुमान लगा रहा हूं कि मैं एक बहुत ही मौलिक गलती कर रहा हूं और कुछ मदद चाहूंगा।
मैं हटा आपके अंतिम पर user.save स्थिति अभिकथन। – Rimian