Convert the following CURL PUT to test the JSON request in rails -


मैं निम्नलिखित कर्ल PUT अनुरोध को rspec और JSON पार्सर के व्यवहार का परीक्षण कैसे करूं।

  कर्ल-डी - -X PUT - डेटा "जेसन नहीं" -एच "सामग्री-प्रकार: आवेदन / जेसन" http: // localhost: 3000  

और कैसे जांचना है प्रतिक्रिया? पहले से धन्यवाद।

सर्वश्रेष्ठ वीसीआर मणि का उपयोग करना है

बस बनाओ स्क्रिप्ट की तरह उचित HTTP अनुरोध के साथ।

  VCR.use_cassette ("json_test") req = Net :: HTTP :: Put.new ('http: // localhost: 3000') करें 'Json नहीं') req.content_type = 'application / json' res = Net :: HTTP.get_response (req) समाप्ति  

इस वास्तविक HTTP अनुरोध के साथ एक बार और आरएसपीसी स्थानीय में दर्ज किया जाएगा फ़ाइल का उपयोग इसके बजाय किया जाएगा।


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -