首先,我是编程的新手,这是问题
这是规范
@IBAction func Vib(_ sender: UIButton) {
let generator = UIImpactFeedbackGenerator(style: .light)
generator.impactOccurred()
}
这是我的回答
require 'minitest/autorun'
require_relative '../pet_shop'
class TestPetShop < Minitest::Test
def setup
@customers = [{
name: "Craig",
pets: [],
cash: 1000
}, {
name: "Zsolt",
pets: [],
cash: 50
}]
@new_pet = {
name: "Bors the Younger",
pet_type: :cat,
breed: "Cornish Rex",
price: 100
}
@pet_shop = {
pets: [{
name: "Sir Percy",
pet_type: :cat,
breed: "British Shorthair",
price: 500
}, {
name: "King Bagdemagus",
pet_type: :cat,
breed: "British Shorthair",
price: 500
}, {
name: "Sir Lancelot",
pet_type: :dog,
breed: "Pomsky",
price: 1000,
}, {
name: "Arthur",
pet_type: :dog,
breed: "Husky",
price: 900,
}, {
name: "Tristan",
pet_type: :dog,
breed: "Basset Hound",
price: 800,
}, {
name: "Merlin",
pet_type: :cat,
breed: "Egyptian Mau",
price: 1500,
}],
admin: {
total_cash: 1000,
pets_sold: 0,
},
name: "Camelot of Pets"
}
end
def test_find_pet_by_name__returns_pet
pet = find_pet_by_name(@pet_shop, "Arthur")
assert_equal("Arthur", pet[:name])
end
end
保持错误的参数数量错误请记住我显然不知道我在做什么,因为我是新的编程。
答案 0 :(得分:0)
您在此处调用find_pet_by_name(shop)
方法:
pet = find_pet_by_name(@pet_shop, "Arthur")
正如评论者提到的那样,在调用方法时,您传递了2个参数:@pet_shop
和"Arthur"
。但是你的方法定义只允许传入1个参数:shop
。所以你的方法调用应该是:
pet = find_pet_by_name(@pet_shop)
没有必要传递“Arthur”,因为该方法不需要(或允许)该信息。因此,您获得的“错误的参数数量”错误。