Skip to content

Commit

Permalink
Actually fix tests? Idk
Browse files Browse the repository at this point in the history
  • Loading branch information
vickash committed Jul 30, 2023
1 parent 43bbb2b commit 43ada5f
Show file tree
Hide file tree
Showing 47 changed files with 212 additions and 212 deletions.
6 changes: 3 additions & 3 deletions test/analog_io/input_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ def part
end

def test__read
mock = MiniTest::Mock.new.expect :call, nil, [14, nil, nil, nil]
mock = Minitest::Mock.new.expect :call, nil, [14, nil, nil, nil]
board.stub(:analog_read, mock) do
part._read
end
mock.verify
end

def test__listen
mock = MiniTest::Mock.new
mock = Minitest::Mock.new
mock.expect :call, nil, [14, 16]
mock.expect :call, nil, [14, 32]
board.stub(:analog_listen, mock) do
Expand All @@ -29,7 +29,7 @@ def test__listen
end

def test__stop_listen
mock = MiniTest::Mock.new.expect :call, nil, [14]
mock = Minitest::Mock.new.expect :call, nil, [14]
board.stub(:stop_listener, mock) do
part._stop_listener
end
Expand Down
2 changes: 1 addition & 1 deletion test/analog_io/output_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def test_mode_set
end

def test_dac_write
mock = MiniTest::Mock.new.expect :call, nil, [14, 128]
mock = Minitest::Mock.new.expect :call, nil, [14, 128]

board.stub(:dac_write, mock) do
part.write 128
Expand Down
4 changes: 2 additions & 2 deletions test/analog_io/potentiometer_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require_relative '../test_helper'

class AnalogIOPotentiometerTest < MiniTest::Test
class AnalogIOPotentiometerTest < Minitest::Test
def board
@board ||= BoardMock.new
end
Expand All @@ -10,7 +10,7 @@ def part
end

def test_setup
mock = MiniTest::Mock.new.expect(:call, nil, [14,8])
mock = Minitest::Mock.new.expect(:call, nil, [14,8])
board.stub(:analog_listen, mock) do
part
end
Expand Down
2 changes: 1 addition & 1 deletion test/behaviors/bus_peripheral_addressed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def test_requires_address
end

def test_can_use_bus_atomically
mock = MiniTest::Mock.new
mock = Minitest::Mock.new
1.times {mock.expect(:call, nil)}

bus.mutex.stub(:synchronize, mock) do
Expand Down
2 changes: 1 addition & 1 deletion test/behaviors/bus_peripheral_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test_initialize
end

def test_can_use_bus_atomically
mock = MiniTest::Mock.new
mock = Minitest::Mock.new
1.times {mock.expect(:call, nil)}

bus.mutex.stub(:synchronize, mock) do
Expand Down
8 changes: 4 additions & 4 deletions test/behaviors/callbacks_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def part

def test_callback_mutex
callback = Proc.new{}
mock = MiniTest::Mock.new
mock = Minitest::Mock.new
3.times {mock.expect(:call, nil)}

part.callback_mutex.stub(:synchronize, mock) do
Expand Down Expand Up @@ -73,8 +73,8 @@ def test_remove_callback_with_key
end

def test_update_runs_callbacks_and_removes_read_callbacks
cb1 = MiniTest::Mock.new.expect :call, nil
cb2 = MiniTest::Mock.new.expect :call, nil
cb1 = Minitest::Mock.new.expect :call, nil
cb2 = Minitest::Mock.new.expect :call, nil
part.add_callback { cb1.call }
part.add_callback(:read) { cb2.call }
part.update("data")
Expand All @@ -84,7 +84,7 @@ def test_update_runs_callbacks_and_removes_read_callbacks
end

def test_pre_callback_filter_modifies_data
cb = MiniTest::Mock.new.expect :call, nil, ["denko: value"]
cb = Minitest::Mock.new.expect :call, nil, ["denko: value"]
part.add_callback { |x| cb.call(x) }
part.update("value")
cb.verify
Expand Down
4 changes: 2 additions & 2 deletions test/behaviors/component_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_sets_and_gets_state
end

def test_state_through_mutex
mock = MiniTest::Mock.new
mock = Minitest::Mock.new
2.times {mock.expect(:call, nil)}

part.instance_variable_get(:@state_mutex).stub(:synchronize, mock) do
Expand All @@ -47,7 +47,7 @@ def test_state_through_mutex
end

def test_micro_delay
mock = MiniTest::Mock.new.expect :call, nil, [1000]
mock = Minitest::Mock.new.expect :call, nil, [1000]

board.stub(:micro_delay, mock) do
part.micro_delay(1000)
Expand Down
6 changes: 3 additions & 3 deletions test/behaviors/listener_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ def test_divider_save_and_read
end

def test_call_stop_before_listening
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
part.stub(:stop, mock) { part.listen }
mock.verify
end

def test_call__listen
mock = MiniTest::Mock.new
mock = Minitest::Mock.new
mock.expect :call, nil, [nil]
mock.expect :call, nil, [32]
part.stub(:_listen, mock) do
Expand All @@ -45,7 +45,7 @@ def test_call__listen
end

def test_call__stop_listener
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
part.stub(:_stop_listener, mock) { part.stop }
mock.verify
end
Expand Down
6 changes: 3 additions & 3 deletions test/behaviors/poller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ def test_include_callbacks_and_threaded
end

def test_call_stop_before_polling
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
part.stub(:stop, mock) { part.poll(1) }
mock.verify
end

def test_uses_threaded_loop
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
part.stub(:threaded_loop, mock) { part.poll(1) }
mock.verify
end
Expand All @@ -57,7 +57,7 @@ def test_add_and_remove_callback
end

def test_stop_kills_thread
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
part.stub(:stop_thread, mock) { part.stop }
mock.verify
end
Expand Down
8 changes: 4 additions & 4 deletions test/behaviors/reader_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def test_include_callbacks
end

def test_read_once
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
inject(1)

part.stub(:_read, mock) do
Expand All @@ -53,20 +53,20 @@ def test_return_value

def test_read_using_with_lambda
inject(1)
reader = MiniTest::Mock.new.expect :call, nil
reader = Minitest::Mock.new.expect :call, nil
part.read_using -> { reader.call }
reader.verify
end

def test_read_using_with_method_and_args
inject(1)
reader = MiniTest::Mock.new.expect :call, nil, [10, 20], test_arg: 2
reader = Minitest::Mock.new.expect :call, nil, [10, 20], test_arg: 2
part.read_using reader, 10, 20, test_arg: 2
reader.verify
end

def test_add_run_remove_callback
cb = MiniTest::Mock.new.expect :call, nil
cb = Minitest::Mock.new.expect :call, nil
inject(1)
part.read { cb.call }
assert_nil part.callbacks[:read]
Expand Down
2 changes: 1 addition & 1 deletion test/behaviors/subcomponents_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_calls_stop_on_remove
pinless = PinlessComponentMock.new
board.add_component(pinless)

mock = MiniTest::Mock.new.expect(:call, nil)
mock = Minitest::Mock.new.expect(:call, nil)
pinless.stub(:stop, mock) do
board.remove_component(pinless)
end
Expand Down
14 changes: 7 additions & 7 deletions test/behaviors/threaded_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ def test_add_interrupts_using_interrupt_with
end

def test_threaded_stops_threads
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
part.stub(:stop_thread, mock) { part.threaded {} }
mock.verify
end

def test_threaded_enables_interrupts
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
part.stub(:enable_interrupts, mock) { part.threaded {} }
mock.verify
end

def test_threaded_calls_block_given
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
part.threaded { mock.call }
sleep 0.1 # Should find a better way to do this.
mock.verify
Expand All @@ -49,7 +49,7 @@ def test_thread_stored_in_instance_variable
end

def test_threaded_loop_calls_block_repeatedly
mock = MiniTest::Mock.new.expect(:call, nil).expect(:call, nil)
mock = Minitest::Mock.new.expect(:call, nil).expect(:call, nil)
part.stub(:foo, mock) do
part.threaded_loop do
part.foo
Expand All @@ -61,7 +61,7 @@ def test_threaded_loop_calls_block_repeatedly
end

def test_stop_thread_kills_thread
mock = MiniTest::Mock.new.expect(:kill, nil)
mock = Minitest::Mock.new.expect(:kill, nil)
part.instance_variable_set(:@thread, mock)
part.stop_thread
mock.verify
Expand All @@ -81,7 +81,7 @@ def test_interrupts_override_singleton_only
end

def test_original_method_called_when_interrupts_enabled
mock = MiniTest::Mock.new.expect(:call, nil, ["denko"])
mock = Minitest::Mock.new.expect(:call, nil, ["denko"])
part.stub(:foo, mock) do
part.enable_interrupts
part.foo("denko")
Expand All @@ -91,7 +91,7 @@ def test_original_method_called_when_interrupts_enabled

def test_interrupt_stops_thread
part.enable_interrupts
mock = MiniTest::Mock.new.expect :call, nil
mock = Minitest::Mock.new.expect :call, nil
part.stub(:stop_thread, mock) { part. foo }
mock.verify
end
Expand Down
16 changes: 8 additions & 8 deletions test/board/board_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def test_require_a_connection_object

def test_starts_observing_connection
io = ConnectionMock.new
mock = MiniTest::Mock.new.expect(:call, nil, [Denko::Board])
mock = Minitest::Mock.new.expect(:call, nil, [Denko::Board])
io.stub(:add_observer, mock) do
Denko::Board.new(io)
end
mock.verify
end

def test_calls_handshake_on_connection
mock = MiniTest::Mock.new.expect(:call, Constants::ACK)
mock = Minitest::Mock.new.expect(:call, Constants::ACK)
connection.stub(:handshake, mock) do
Denko::Board.new(connection)
end
Expand All @@ -49,7 +49,7 @@ def test_analog_resolution
assert_equal 1023, board.analog_read_high
assert_equal 10, board.analog_read_resolution

mock = MiniTest::Mock.new
mock = Minitest::Mock.new
mock.expect(:call, nil, [Denko::Message.encode(command:96, value:12)])
mock.expect(:call, nil, [Denko::Message.encode(command:97, value:12)])
board.stub(:write, mock) do
Expand All @@ -66,7 +66,7 @@ def test_analog_resolution
end

def test_eeprom
mock = MiniTest::Mock.new.expect(:call, "test eeprom", [], board: board)
mock = Minitest::Mock.new.expect(:call, "test eeprom", [], board: board)
Denko::EEPROM::BuiltIn.stub(:new, mock) do
board.eeprom
end
Expand All @@ -75,24 +75,24 @@ def test_eeprom

def test_write
board
mock = MiniTest::Mock.new.expect(:call, nil, ["message"])
mock = Minitest::Mock.new.expect(:call, nil, ["message"])
connection.stub(:write, mock) do
board.write("message")
end
mock.verify
end

def test_update_passes_messages_to_correct_components
mock1 = MiniTest::Mock.new.expect(:update, nil, ["data"])
mock1 = Minitest::Mock.new.expect(:update, nil, ["data"])
3.times { mock1.expect(:pin, 1) }

# Make sure lines are split only on the first colon.
# Tests for string based pine names too.
mock2 = MiniTest::Mock.new.expect(:update, nil, ["with:colon"])
mock2 = Minitest::Mock.new.expect(:update, nil, ["with:colon"])
3.times { mock2.expect(:pin, 14) }

# Special EEPROM mock.
mock3 = MiniTest::Mock.new.expect(:update, nil, ["bytes"])
mock3 = Minitest::Mock.new.expect(:update, nil, ["bytes"])
3.times { mock3.expect(:pin, 254) }

board.add_component(mock1)
Expand Down
Loading

0 comments on commit 43ada5f

Please sign in to comment.