我正在尝试验证对传递给它的块的方法的期望。只要我不使用任何关键字,一切都运行得很好,但是我需要使用任何关键字,以便不匹配期望的所有部分。< / p>
要测试的实际功能调用。
RestClient::Request.execute(:method => :post, :url => some_url, :headers => {}.to_json, :payload => {}.to_json)
当我测试时,
这些工作(请注意使用任何内容)
RestClient::Request.expects(:execute).with(:method => :post, :url => some_url, :headers => {}.to_json, :payload => {}.to_json)
RestClient::Request.stubs(:execute).with(:method => :post, :url => some_url, :headers => {}.to_json, :payload => {}.to_json)
RestClient::Request.stubs(:execute).with(anything)
这不是(请注意任何内容的使用)
RestClient::Request.stubs(:execute).with(:method => :post, :url => some_url, :headers => anything, :payload => anything)
我的问题是我只想验证URL和方法,而不是请求的标题和正文。我错过了什么?
答案 0 :(得分:0)
想出来 - 如果有人帮助,这就是它的完成方式
使用 .with(has_entries(...)) 方法并仅传递要验证的参数 - 避免传递 任何内容 到 .with 方法。
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
devtool: 'cheap-module-eval-source-map',
context: path.resolve(__dirname, 'src'),
entry: './index.js',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist')
},
devServer: {
contentBase: path.resolve(__dirname, 'src')
},
module: {
loaders: [
{
test: /\.json$/,
loaders: ['json']
},
{
test: /\.html$/,
loader: ['raw-loader']
}
]
},
resolveLoader: {
moduleExtensions: ['-loader']
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
template: './index.html'
})
]
};