I am trying to sending XML content through POST to a controller ('Parse') method ('index') in a simple Rails project. It is not RESTful as 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
I am now trying cucumber (0.4.3), and would like to know as to how I can simulate the POST request in a "When" clause. I have only one controller method 'index', 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
- webrat within cucumber is only for HTML, and cannot do POST?
- @request variable is not available from cucumber environment?
- If I use something like 'visit index' (assuming it is Parse controller, index method) in features/step_definitions/car_steps.rb, I get the following error:
undefined method `index' for # (NoMethodError)
Appreciate any suggestions on how to do integration tests with Cucumber for HTTP POST with XML content.