require 'test_helper' class NavigationTest < ActionDispatch::IntegrationTest def setup Bot::Adapter::Test.empty_messages end test "notify" do post "/bot/notify" assert_equal 200, status post "/bot/notify", {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>true, "from"=>"bnmrrs", "timestamp"=>1452785908454, "type"=>"text", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}]} assert_text_response('Hello text!') end test "notify special types" do post "/bot/notify", {"messages"=>[{"body"=>"Hello", "readReceiptRequested"=>true, "from"=>"bnmrrs", "timestamp"=>1452785908454, "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}]} assert_text_response('Hello scan!') end test "notify multi types" do post "/bot/notify", {"messages"=>[{"body"=>"multi", "readReceiptRequested"=>true, "from"=>"bnmrrs", "timestamp"=>1452785908454, "type"=>"scan-data", "id"=>"2af0d873-d157-4627-b863-8be11b0dfd86"}]} assert_text_response('Hello multi!') end def assert_text_response(message) assert_equal 200, status assert_equal Bot::Adapter::Test.sent_messages.count, 1 assert_equal Bot::Adapter::Test.sent_messages.first["body"], message end end