spec/wei_backend_spec.rb in wei-backend-0.1.0 vs spec/wei_backend_spec.rb in wei-backend-0.1.1

- old
+ new

@@ -1,30 +1,30 @@ require_relative 'spec_helper' describe 'app' do include Rack::Test::Methods it 'should echo string when request with echostr parameter' do - get '/?echostr=test' + get '/weixin?echostr=test' last_response.body.should include 'test' end it 'should return user defined text message when receive a text request message' do WeiBackend::MessageDispatcher.on_text do 'hello world' end - post '/', TEXT_MESSAGE_REQUEST, 'CONTENT_TYPE' => 'text/xml' + post '/weixin', TEXT_MESSAGE_REQUEST, 'CONTENT_TYPE' => 'text/xml' last_response.body.should include '<ToUserName><![CDATA[fromUser]]></ToUserName>' last_response.body.should include '<Content><![CDATA[hello world]]></Content>' end it 'should return user defined news message when receive a text request message' do WeiBackend::MessageDispatcher.on_text do {:title => 'title', :description => 'desc', :picture_url => 'pic url', :url => 'url'} end - post '/', TEXT_MESSAGE_REQUEST, 'CONTENT_TYPE' => 'text/xml' + post '/weixin', TEXT_MESSAGE_REQUEST, 'CONTENT_TYPE' => 'text/xml' last_response.body.should include '<ToUserName><![CDATA[fromUser]]></ToUserName>' last_response.body.should include '<Title><![CDATA[title]]></Title>' end it 'should return news message when receive a text request message and user defined a multi-news' do @@ -41,32 +41,32 @@ :picture_url => 'pic url1', :url => 'url1' }] end - post '/', TEXT_MESSAGE_REQUEST, 'CONTENT_TYPE' => 'text/xml' + post '/weixin', TEXT_MESSAGE_REQUEST, 'CONTENT_TYPE' => 'text/xml' last_response.body.should include '<ToUserName><![CDATA[fromUser]]></ToUserName>' last_response.body.should include '<Title><![CDATA[title]]></Title>' last_response.body.should include '<Title><![CDATA[title1]]></Title>' end it 'should echo location message when receive a location event message' do WeiBackend::MessageDispatcher.on_location do "location event: #{params[:Latitude]}" end - post '/', LOCATION_EVENT_REQUEST, 'CONTENT_TYPE' => 'text/xml' + post '/weixin', LOCATION_EVENT_REQUEST, 'CONTENT_TYPE' => 'text/xml' last_response.body.should include '<ToUserName><![CDATA[fromUser]]></ToUserName>' last_response.body.should include '<Content><![CDATA[location event: 23.137466]]></Content>' end it 'should echo location message when receive a location event message' do WeiBackend::MessageDispatcher.on_subscribe do 'Thank you for subscribe!' end - post '/', SUBSCRIBE_EVENT_REQUEST, 'CONTENT_TYPE' => 'text/xml' + post '/weixin', SUBSCRIBE_EVENT_REQUEST, 'CONTENT_TYPE' => 'text/xml' last_response.body.should include '<ToUserName><![CDATA[fromUser]]></ToUserName>' last_response.body.should include '<Content><![CDATA[Thank you for subscribe!]]></Content>' end it 'should do something when user have set token' do @@ -74,10 +74,10 @@ 'Thank you for subscribe!' end WeiBackend::MessageDispatcher.token 'combustest' - post '/?signature=0d144fa22f4119dbb2f6fe9710f3b732fb45092b&timestamp=1388674716&nonce=1388564676', SUBSCRIBE_EVENT_REQUEST, 'CONTENT_TYPE' => 'text/xml', 'token' => 'token' + post '/weixin?signature=0d144fa22f4119dbb2f6fe9710f3b732fb45092b&timestamp=1388674716&nonce=1388564676', SUBSCRIBE_EVENT_REQUEST, 'CONTENT_TYPE' => 'text/xml', 'token' => 'token' last_response.body.should include '<ToUserName><![CDATA[fromUser]]></ToUserName>' last_response.body.should include '<Content><![CDATA[Thank you for subscribe!]]></Content>' end end