I am trying to send XML content via POST to the controller method ("Parse") ("index") in a simple Rails project. This is not RESTful, since my model name is different, say, βcarsβ. I have the following in a functional test that works:
def test_index ... data_file_path = File.dirname(__FILE__) + '/../../app/views/layouts/index.xml.erb' message = ERB.new( File.read( data_file_path ) ) xml_result = message.result( binding ) doc = REXML::Document.new xml_result @request.env['RAW_POST_DATA'] = xml_result post :index assert_response :success end
Now I'm trying to use a cucumber (0.4.3) and would like to know how I can simulate a POST request in the When clause. I have only one controller "index" method, and I have the following in config / routes.rb:
ActionController::Routing::Routes.draw do |map| map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' end
- The webrat inside the cucumber is HTML only and cannot do POST?
- variable @request is not available from the environment of the cucumber?
- If I use something like a visit index (assuming it is a Parse controller, index method) in the / step _definitions / car_steps.rb functions, I get the following error:
undefined `index 'method for # (NoMethodError)
Evaluate any suggestions on how to do integration tests with Cucumber for HTTP POST with XML content.
ruby ruby-on-rails cucumber
mbuf
source share