-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge ruby-app to use both watchexec and listen watchers
- Loading branch information
Showing
27 changed files
with
207 additions
and
776 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,83 @@ | ||
require 'retest' | ||
require_relative 'support/test_helper' | ||
require 'byebug' | ||
require 'minitest/autorun' | ||
require_relative 'retest_test/file_changes_test' | ||
require_relative 'retest_test/flags_test' | ||
require_relative 'retest_test/setup_test' | ||
require_relative 'retest_test/matching_unmatching_command_test' | ||
require_relative 'support/test_helper' | ||
require_relative 'shared/file_changes' | ||
require_relative 'shared/setup' | ||
require_relative 'shared/explicit_matching' | ||
|
||
$stdout.sync = true | ||
|
||
include FileHelper | ||
class TestListenWatcher < Minitest::Test | ||
# Helpers | ||
include FileHelper | ||
include OutputHelper | ||
include CommandHelper | ||
|
||
# Assertions | ||
include Setup | ||
include FileChanges | ||
include ExplicitMatching | ||
|
||
def setup | ||
@command = 'retest -w listen' | ||
end | ||
|
||
def test_start_retest | ||
launch_retest(@command) | ||
|
||
assert_match <<~EXPECTED, read_output | ||
Setup identified: [RUBY]. Using command: 'bundle exec ruby <test>' | ||
Watcher: [LISTEN] | ||
Launching Retest... | ||
Ready to refactor! You can make file changes now | ||
EXPECTED | ||
end | ||
end | ||
|
||
class TestWatchexecWatcher < Minitest::Test | ||
# Helpers | ||
include FileHelper | ||
include OutputHelper | ||
include CommandHelper | ||
|
||
# Assertions | ||
include Setup | ||
include FileChanges | ||
include ExplicitMatching | ||
|
||
def setup | ||
@command = 'retest -w watchexec' | ||
end | ||
|
||
def test_start_retest | ||
launch_retest(@command) | ||
|
||
assert_match <<~EXPECTED, read_output | ||
Setup identified: [RUBY]. Using command: 'bundle exec ruby <test>' | ||
Watcher: [WATCHEXEC] | ||
Launching Retest... | ||
Ready to refactor! You can make file changes now | ||
EXPECTED | ||
end | ||
end | ||
|
||
class TestDefaultWatcher < Minitest::Test | ||
include OutputHelper | ||
include CommandHelper | ||
|
||
def setup | ||
@command = 'retest' | ||
end | ||
|
||
def test_uses_watchexec_when_installed | ||
launch_retest(@command) | ||
|
||
assert_match <<~EXPECTED, read_output | ||
Setup identified: [RUBY]. Using command: 'bundle exec ruby <test>' | ||
Watcher: [WATCHEXEC] | ||
Launching Retest... | ||
Ready to refactor! You can make file changes now | ||
EXPECTED | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
module FileChanges | ||
def teardown | ||
end_retest | ||
end | ||
|
||
def test_modifying_existing_file | ||
launch_retest(@command) | ||
|
||
modify_file('lib/bottles.rb') | ||
|
||
read_output do |output| | ||
assert_match "Test file: test/bottles_test.rb", output | ||
assert_match "12 runs, 12 assertions, 0 failures, 0 errors, 0 skips", output | ||
end | ||
end | ||
|
||
def test_modifying_existing_test_file | ||
launch_retest(@command) | ||
|
||
modify_file('test/bottles_test.rb') | ||
|
||
read_output do |output| | ||
assert_match "Test file: test/bottles_test.rb", output | ||
assert_match "12 runs, 12 assertions, 0 failures, 0 errors, 0 skips", output | ||
end | ||
end | ||
|
||
def test_creating_a_new_test_file | ||
launch_retest(@command) | ||
|
||
create_file 'foo_test.rb' | ||
|
||
assert_match "Test file: foo_test.rb", read_output | ||
|
||
ensure | ||
delete_file 'foo_test.rb' | ||
end | ||
|
||
def test_creating_a_new_file | ||
launch_retest(@command) | ||
|
||
create_file 'foo.rb' | ||
assert_match <<~EXPECTED, read_output | ||
FileNotFound - Retest could not find a matching test file to run. | ||
EXPECTED | ||
|
||
create_file 'foo_test.rb' | ||
assert_match "Test file: foo_test.rb", read_output | ||
|
||
modify_file('lib/bottles.rb') | ||
assert_match "Test file: test/bottles_test.rb", read_output | ||
|
||
modify_file('foo.rb') | ||
assert_match "Test file: foo_test.rb", read_output | ||
|
||
ensure | ||
delete_file 'foo.rb' | ||
delete_file 'foo_test.rb' | ||
end | ||
|
||
def test_untracked_file | ||
create_file 'foo.rb', should_sleep: false | ||
create_file 'foo_test.rb', should_sleep: false | ||
|
||
launch_retest(@command) | ||
|
||
modify_file 'foo.rb' | ||
assert_match "Test file: foo_test.rb", read_output | ||
|
||
ensure | ||
delete_file 'foo.rb' | ||
delete_file 'foo_test.rb' | ||
end | ||
end |
4 changes: 2 additions & 2 deletions
4
...ruby-app/retest/retest_test/setup_test.rb → features/ruby-app/retest/shared/setup.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class SetupTest < Minitest::Test | ||
module Setup | ||
def test_repository_setup | ||
assert_equal :ruby, Retest::Setup.new.type | ||
end | ||
end | ||
end |
Oops, something went wrong.