We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
我改了default_url_options 方法,测试是通过的(否则是@weixin_message 为 nil ,FromUserName不存在): https://github.com/lanrion/weixin_rails_middleware/blob/master/app/controllers/weixin_rails_middleware/weixin_controller.rb#L66-L68
def default_url_options(options={}) #{ weichat_id: @weixin_message.FromUserName } { weichat_id: "o17q2s7mMOrwcFC8WT1BFgBJzAPE"} # 我的修改 end
post 'reply' => 'myweixin#reply'
it "...." do scaner = "<xml> <ToUserName>gh_7376db11d3a2</ToUserName> <FromUserName>o17q2s7mMOrwcFC8WT1BFgBJzAPE</FromUserName> <CreateTime>1430825981</CreateTime> <MsgType>event</MsgType> <Event>SCAN</Event> <EventKey>123</EventKey> <Ticket>gQEl8ToAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL3IwaE9VN2prb3pIYWgtdE4zMllUAAIEqKtIVQMEgDoJAA</Ticket> </xml>" post "reply", scaner # 得到 response 的测试返回是正确的: #@weixin_message #=> #<WeixinRailsMiddleware::Message:0x007f9a4c0e8560 # @source= # #<OpenStruct ToUserName="gh_7376db11d3a2", FromUserName="o17q2s7mMOrwcFC8WT1BFgBJzAPE", CreateTime="1430810714", MsgType="text", Content="Cvvc", MsgId="6145285223601690279">> end
我不修改 default_url_options 方法,请问如何测试通过?
@lanrion
The text was updated successfully, but these errors were encountered:
param_xml = request.body.read xml 字符串,放入body内。
param_xml = request.body.read
Sorry, something went wrong.
@lanrion 请问在哪里写 request.body = " xml...." ? 但问题是,在测试中,还没有等生成 @weixin_message,就先执行了default_url_options 方法的 @weixin_message.FromUserName 了 ,所以测试才会报错的.
@weixin_message.FromUserName
要不这样改 ?
before(:each) do WeixinRailsMiddleware::WeixinController.class_eval do protected def default_url_options(options={}) { weichat_id: "o17q2s7mMOrwcFC8WT1BFgBJzAPE"} end end end
这个还真没测试过。
No branches or pull requests
我改了default_url_options 方法,测试是通过的(否则是@weixin_message 为 nil ,FromUserName不存在):
https://github.com/lanrion/weixin_rails_middleware/blob/master/app/controllers/weixin_rails_middleware/weixin_controller.rb#L66-L68
routes.rb
myweixin_controller_spec.rb
我不修改 default_url_options 方法,请问如何测试通过?
@lanrion
The text was updated successfully, but these errors were encountered: