如何使用allow来接收绕过测试方法中的参数?
我的规范中有两个哈希值,我想用于keys_1
和keys_2
,但我需要绕过yaml_1
和yaml_2
因为我目前没有任何要读取的文件。我该怎么做?
let(:main_hash) {
{ navigation:
{ about: 'About',
blog: 'Blog',
contributors: 'Contributors',
partners: 'Partners',
privacy: 'Privacy Policy'}
}
}
let(:second_hash) {
{ navigation:
{ about: 'About',
blog: 'Blog',
partners: 'Partners'}
}
}
describe '.compare' do
subject(:subject) { described_class.compare(locale_1, locale_2) }
it 'compares locales' do
expect(subject).to eq(result)
end
end
def compare(locale_1, locale_2)
yaml_1 = YAML.load(File.open(File.expand_path(locale_1)))
yaml_2 = YAML.load(File.open(File.expand_path(locale_2)))
keys_1 = flatten_keys(yaml_1[yaml_1.keys.first])
keys_2 = flatten_keys(yaml_2[yaml_2.keys.first])
end