Skip to content

Commit

Permalink
Create Commnad::MultipleTestsNotSupported error
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexB52 committed Nov 24, 2024
1 parent 696c452 commit 13c20f8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
6 changes: 4 additions & 2 deletions lib/retest/command/base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Retest
class Command
class MultipleTestsNotSupported < StandardError; end

class Base
def initialize(all: false, file_system: FileSystem, command: nil)
@file_system = file_system
Expand Down Expand Up @@ -36,11 +38,11 @@ def hardcoded_type?
end

def to_s
raise NotImplementedError
@command
end

def format_batch(*files)
raise NotImplementedError
raise MultipleTestsNotSupported, "Multiple test files run not supported for '#{to_s}'"
end

private
Expand Down
10 changes: 1 addition & 9 deletions lib/retest/command/hardcoded.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
module Retest
class Command
class Hardcoded < Base
def to_s
@command
end

def format_batch(*files)
raise ArgumentError, "Multiple test files run not supported for '#{to_s}'"
end
end
class Hardcoded < Base; end
end
end
4 changes: 2 additions & 2 deletions test/retest/command/hardcoded_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ def test_to_s
end

def test_format_with_one_file
assert_raises(ArgumentError) do
assert_raises(Command::MultipleTestsNotSupported) do
@subject.format_batch('a/file/path.rb')
end
end

def test_format_with_multiple_files
assert_raises(ArgumentError) do
assert_raises(Command::MultipleTestsNotSupported) do
@subject.format_batch('a/file/path.rb', 'another/file/path.rb')
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/retest/runner_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def test_returns_last_command
end

def test_run_multiple_tests
assert_raises(ArgumentError) do
assert_raises(Command::MultipleTestsNotSupported) do
@subject.command = @command
@subject.format_instruction(test_files: ['file_path.rb', 'file_path_two.rb'])
end
Expand Down

0 comments on commit 13c20f8

Please sign in to comment.