davidmann4 / botstack

rapid chatbot development with ruby on rails
127 stars 23 forks source link

Unregistered request during test : thread_settings #38

Open luizcarvalho opened 6 years ago

luizcarvalho commented 6 years ago

I clone the project and when I run rspec, this happens:

Verify the bot with the following verify_token :github
/home/luiz/.rvm/gems/ruby-2.3.3/gems/webmock-2.3.1/lib/webmock/http_lib_adapters/net_http.rb:114:in `request': Real HTTP connections are disabled. Unregistered request: POST https://graph.facebook.com/v2.6/me/thread_settings?access_token= with body '{"setting_type":"call_to_actions","thread_state":"existing_thread","call_to_actions":[{"type":"postback","title":"Reset","payload":"RESET_BOT"},{"type":"postback","title":"Info","payload":"INFO_BOT"}]}' with headers {'Content-Type'=>'application/json'} (WebMock::NetConnectNotAllowedError)

You can stub this request with the following snippet:

stub_request(:post, "https://graph.facebook.com/v2.6/me/thread_settings?access_token=").
  with(:body => "{\"setting_type\":\"call_to_actions\",\"thread_state\":\"existing_thread\",\"call_to_actions\":[{\"type\":\"postback\",\"title\":\"Reset\",\"payload\":\"RESET_BOT\"},{\"type\":\"postback\",\"title\":\"Info\",\"payload\":\"INFO_BOT\"}]}",
       :headers => {'Content-Type'=>'application/json'}).
  to_return(:status => 200, :body => "", :headers => {})