问题
I am using casper test cases with a rails application, for running the test case I am using following command.
result = `cd #{Rails.root.join}/casper && casperjs test #{params[:file]}.js`
The above mentioned code is working fine on development environment(webrick) but if I run this on staging(nginx+passenger) then I am getting nil response within seconds that means that the script is running asynchronously, I need to run this synchronously so that I can send a JSON response to the client. the method that I am using for providing response is as follow.
def test
@result = `cd #{Rails.root.join}/casper && casperjs test #{params[:file]}.js`
render json: JSON.parse(@result)
end
来源:https://stackoverflow.com/questions/28696685/rails-controller-returning-nil-response-while-running-casperjs-test-cases-with-s