Skip to content

Instantly share code, notes, and snippets.

@zamith
Created April 12, 2016 16:10
Show Gist options
  • Save zamith/2ea2745bc68f42d2f655e5f778fca201 to your computer and use it in GitHub Desktop.
Save zamith/2ea2745bc68f42d2f655e5f778fca201 to your computer and use it in GitHub Desktop.
ExVCR and Hound interaction issue
[
{
"request": {
"body": "",
"headers": [],
"method": "get",
"options": [],
"request_body": "",
"url": "http://localhost:8910/session/cab0b8d0-00c7-11e6-8d48-af5941ebb3ff/element/:wdc:1460476880575/text"
},
"response": {
"body": "{\"sessionId\":\"cab0b8d0-00c7-11e6-8d48-af5941ebb3ff\",\"status\":0,\"value\":\"SPORTING CLUBE DE BRAGA\"}",
"headers": {
"Cache": "no-cache",
"Content-Length": "97",
"Content-Type": "application/json;charset=UTF-8"
},
"status_code": 200,
"type": "ok"
}
},
{
"request": {
"body": "{\"value\":\"#NomeClube\",\"using\":\"css selector\"}",
"headers": {
"Content-Type": "text/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "http://localhost:8910/session/cab0b8d0-00c7-11e6-8d48-af5941ebb3ff/element"
},
"response": {
"body": "{\"sessionId\":\"cab0b8d0-00c7-11e6-8d48-af5941ebb3ff\",\"status\":0,\"value\":{\"ELEMENT\":\":wdc:1460476880575\"}}",
"headers": {
"Cache": "no-cache",
"Content-Length": "104",
"Content-Type": "application/json;charset=UTF-8"
},
"status_code": 200,
"type": "ok"
}
},
{
"request": {
"body": "{\"desiredCapabilities\":{\"version\":\"\",\"takesScreenshot\":true,\"rotatable\":false,\"platform\":\"ANY\",\"nativeEvents\":false,\"javascriptEnabled\":false,\"cssSelectorsEnabled\":true,\"browserName\":\"phantomjs\"}}",
"headers": {
"Content-Type": "text/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "http://localhost:8910/session"
},
"response": {
"body": "{\"sessionId\":\"cab0b8d0-00c7-11e6-8d48-af5941ebb3ff\",\"status\":0,\"value\":{\"browserName\":\"phantomjs\",\"version\":\"1.9.7\",\"driverName\":\"ghostdriver\",\"driverVersion\":\"1.1.0\",\"platform\":\"mac-unknown-64bit\",\"javascriptEnabled\":true,\"takesScreenshot\":true,\"handlesAlerts\":false,\"databaseEnabled\":false,\"locationContextEnabled\":false,\"applicationCacheEnabled\":false,\"browserConnectionEnabled\":false,\"cssSelectorsEnabled\":true,\"webStorageEnabled\":false,\"rotatable\":false,\"acceptSslCerts\":false,\"nativeEvents\":true,\"proxy\":{\"proxyType\":\"direct\"}}}",
"headers": {
"Cache": "no-cache",
"Content-Length": "534",
"Content-Type": "application/json;charset=UTF-8"
},
"status_code": 200,
"type": "ok"
}
},
{
"request": {
"body": "{\"url\":\"http://www.fpb.pt/fpb2014/!site.go?s=1&show=clu&id=2404\"}",
"headers": {
"Content-Type": "text/json"
},
"method": "post",
"options": [],
"request_body": "",
"url": "http://localhost:8910/session/cab0b8d0-00c7-11e6-8d48-af5941ebb3ff/url"
},
"response": {
"body": "{\"sessionId\":\"cab0b8d0-00c7-11e6-8d48-af5941ebb3ff\",\"status\":0,\"value\":{}}",
"headers": {
"Cache": "no-cache",
"Content-Length": "74",
"Content-Type": "application/json;charset=UTF-8"
},
"status_code": 200,
"type": "ok"
}
},
{
"request": {
"body": "",
"headers": [],
"method": "get",
"options": [],
"request_body": "",
"url": "http://localhost:8910/session/cab0b8d0-00c7-11e6-8d48-af5941ebb3ff/element/:wdc:1460476880575/attribute/src"
},
"response": {
"body": "{\"sessionId\":\"cab0b8d0-00c7-11e6-8d48-af5941ebb3ff\",\"status\":0,\"value\":null}",
"headers": {
"Cache": "no-cache",
"Content-Length": "76",
"Content-Type": "application/json;charset=UTF-8"
},
"status_code": 200,
"type": "ok"
}
},
{
"request": {
"body": "",
"headers": [],
"method": "delete",
"options": [],
"request_body": "",
"url": "http://localhost:8910/session/cab0b8d0-00c7-11e6-8d48-af5941ebb3ff"
},
"response": {
"body": "{\"sessionId\":\"cab0b8d0-00c7-11e6-8d48-af5941ebb3ff\",\"status\":0,\"value\":{}}",
"headers": {
"Cache": "no-cache",
"Content-Length": "74",
"Content-Type": "application/json;charset=UTF-8"
},
"status_code": 200,
"type": "ok"
}
}
]
defmodule Fpb.TeamsScrapperTaskTest do
import Ecto.Query
use Fpb.ConnCase
use ExVCR.Mock, adapter: ExVCR.Adapter.Hackney
alias Fpb.Club
test "adds a club that is active" do
use_cassette "one_active_club" do
HTTPoison.start
Mix.Tasks.Scraper.Teams.run([])
club = Repo.one(from c in Club, order_by: [desc: c.id], limit: 1)
assert club != nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment