Building API integrations you can live with.

Building API integrations you can live with.

The integration is in place. Now what? Presented at Defrag 2013 in Broomfield, CO.

54b75f6fbf4434162bfcda6b0cb9b86b?s=128

John Sheehan

November 05, 2013
Tweet

Transcript

  1. John Sheehan CEO, Runscope Building API integrations you can live

    with. Tuesday, November 5, 13
  2. Software is eating lunch and APIs are for dessert! Tuesday,

    November 5, 13
  3. “There's just no getting around it: you're building a distributed

    system. -- Mark Cavage, ACM Queue Tuesday, November 5, 13
  4. Mobile & Desktop Apps Web Sites & Applications Internal APIs

    3rd-party Service APIs Public APIs Tuesday, November 5, 13
  5. Mobile & Desktop Apps Web Sites & Applications Internal APIs

    3rd-party Service APIs Public APIs fn(){} fn(){} Tuesday, November 5, 13
  6. Mobile & Desktop Apps Web Sites & Applications Internal APIs

    3rd-party Service APIs Public APIs fn(){} fn(){} fn(){} fn(){} fn(){} Tuesday, November 5, 13
  7. fn(){} fn(){} fn(){} fn(){} fn(){} Tuesday, November 5, 13

  8. fn(){} fn(){} fn(){} fn(){} fn(){} YOUR APPLICATION Tuesday, November 5,

    13
  9. What are the challenges for running an API-driven application? Tuesday,

    November 5, 13
  10. CHALLENGE #1 Getting a complete picture of your app. Tuesday,

    November 5, 13
  11. Keep an eye on everything. Tuesday, November 5, 13

  12. CHALLENGE #2 Managing change. Tuesday, November 5, 13

  13. Prefer lighter abstractions. Tuesday, November 5, 13

  14. Think twice about taking a dependency on an SDK. Tuesday,

    November 5, 13
  15. OUR STRATEGY Tuesday, November 5, 13

  16. OUR STRATEGY Smarter HTTP client Tuesday, November 5, 13

  17. OUR STRATEGY Smarter HTTP client Thin wrappers Tuesday, November 5,

    13
  18. CHALLENGE #3 High-fidelity testing. Tuesday, November 5, 13

  19. Let’s look at some popular API testing frameworks. Tuesday, November

    5, 13
  20. frisby.js Tuesday, November 5, 13

  21. require  'rubygems' require  'test/unit' require  'vcr' VCR.configure  do  |c|  

     c.cassette_library_dir  =  'fixtures/vcr_cassettes'    c.hook_into  :webmock  #  or  :fakeweb end class  VCRTest  <  Test::Unit::TestCase    def  test_example_dot_com        VCR.use_cassette('synopsis')  do              url  =  'http://yourapihere.com'            response  =  Net::HTTP.get_response(URI(url))            assert_match  /Example  domains/,  response.body        end    end end VCR github.com/vcr/vcr Tuesday, November 5, 13
  22. mocky.io Tuesday, November 5, 13

  23. aspec github.com/songkick/aspec # no users have pending notifications GET /users/with-pending-notifications

    200 application/json [] # users with events on their calendar have pending notifications POST /users/764/metro-areas/999 204 POST /users/764/artists/123 204 POST /events/5?artist_ids=123&metro_area_id=999 204 POST /events/5/enqueue-notifications 204 GET /users/with-pending-notifications 200 application/json [[764, "ep"]] # users are unique in the response POST /users/764/artists/123 204 POST /users/764/artists/456 204 POST /users/764/metro-areas/999 204 POST /events/5?artist_ids=123,456&metro_area_id=999 204 POST /events/5/enqueue-notifications 204 GET /users/with-pending-notifications 200 application/json [[764, "ep"]] Tuesday, November 5, 13
  24. service  "http://localhost:4567"  do    def  responds_with_json_where        JSON.parse(response.body)

       end    resource  "/lolz"  do        get  do            it  {  responds_with.status  :ok  }            it  {  responds_with_json_where['lolz'].must_be_instance_o            with_query("q=monorail")  do                it  "only  lists  lolz  that  match  the  query"  do                    responds_with_json_where['lolz'].wont_be_empty                    responds_with_json_where['lolz'].each  do  |lol|                        lol['title'].must_match  /monorail/                    end                end            end HyperSpec Tuesday, November 5, 13
  25. Tuesday, November 5, 13

  26. Sign up free: runscope.com Tuesday, November 5, 13