ruby on rails - Test new controller action with rspec feature test -


i'm using mail form gem handle website's contact form. i'm using rspec , capybara in testing environment. i'm encountering error when trying test contact form page. new action of contacts controller create new instance of contact model, don't know how in rspec fix reason failure.

the failed test output:

no route matches {:action=>"new", :controller=>"contacts", :format=>nil} missing required keys: [] 

contact_form_spec.rb

require 'spec_helper' require 'rails_helper'  rspec.feature "comtact form email", :type => :feature   scenario "user sends email via contact form"     visit contacts_path      fill_in 'name', :with => 'jony ive'     fill_in 'email', :with => 'jony@apple.com'     fill_in 'subject', :with => 'subject here'     fill_in 'message', :with => 'message'      click_button 'send message'      expect(page).to have_text("thank message.")      last_email.to.should include('help@everydayrails.com')      last_email.from.should include('aaron@everydayrails.com')   end  end 

contacts_controller.rb

class contactscontroller < applicationcontroller   def new     @contact = contact.new   end    def create     @contact = contact.new(params[:contact])     @contact.request = request     if @contact.deliver       flash[:notice] = 'thank message. contact soon!'       redirect_to contacts_path     else       flash[:error] = 'your message not sent.'       render :new     end   end end 

routes.rb

match '/contacts',     to: 'contacts#new',             via: 'get' resources :contacts, only: [:create] 

routes output

contacts             /contacts(.:format)     contacts#new          post            /contacts(.:format)     contacts#create 


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -