lib/mocktail/replaces_next.rb in mocktail-1.2.3 vs lib/mocktail/replaces_next.rb in mocktail-2.0.0

- old
+ new

@@ -1,13 +1,19 @@ module Mocktail class ReplacesNext + extend T::Sig + def initialize @top_shelf = TopShelf.instance @redefines_new = RedefinesNew.new @imitates_type = ImitatesType.new end + def replace_once(type) + replace(type, 1).fetch(0) + end + def replace(type, count) raise UnsupportedMocktail.new("Mocktail.of_next() only supports classes") unless type.is_a?(Class) mocktails = count.times.map { @imitates_type.imitate(type) } @@ -28,9 +34,9 @@ mocktail } end - (mocktails.size == 1) ? mocktails.first : mocktails + mocktails end end end