Skip to content

Refactor test fixtures #253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions test/retest/program_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@
module Retest
class ProgramTest < Minitest::Test
class PauseTest < Minitest::Test
class RaisingRepository
class NotToBeCalledError < StandardError; end
def find_test(_)
raise NotToBeCalledError
end
end

def setup
@subject = Program.new(repository: Repository.new, stdout: StringIO.new)
end
Expand Down
27 changes: 27 additions & 0 deletions test/support/fixtures.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module Retest
class MethodCallError < StandardError; end

FakeFS = Struct.new(:files) do
def exist?(value)
files.include? value
end
end

class RaisingRepository
def find_test(_)
raise MethodCallError, "#{__method__} should not be called"
end
end

class RaisingRunner
def initialize
end

def sync(added:, removed:)
end

def run(file, repository:)
raise MethodCallError, "#{__method__} should not be called"
end
end
end
38 changes: 1 addition & 37 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,7 @@
require "retest"
require "byebug"
require "minitest/autorun"

WAITING_TIME = 0.0001

def wait(time = WAITING_TIME)
sleep time
end

FakeFS = Struct.new(:files) do
def exist?(value)
files.include? value
end
end

class RaisingRunner
class MethodCallError < StandardError; end

def initialize
end

def sync(added:, removed:)
end

def run(file, repository:)
raise MethodCallError, "#{__method__} should not be called"
end
end

def wait_until(max_attempts: 10)
attempts = 0
begin
yield
rescue Minitest::Assertion => e
raise e if attempts >= max_attempts
wait
attempts += 1
end
end
require "support/fixtures"

module Retest
# Remove Watchexec when not installed
Expand Down