Skip to content

Commit

Permalink
E2E tests for rspec-ruby with alias rspec command
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexB52 committed Jan 26, 2025
1 parent bdbfc36 commit eed74a9
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 54 deletions.
3 changes: 3 additions & 0 deletions features/rspec-ruby/bin/retest
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env sh

bundle exec rspec $@
71 changes: 68 additions & 3 deletions features/rspec-ruby/retest/retest_test.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,74 @@
require 'retest'
require_relative 'support/test_helper'
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/file_changes'

$stdout.sync = true

class TestDefaultCommand < Minitest::Test
include RetestHelper
include FileChanges

def setup
@command = "retest"
end

def teardown
end_retest
end

def test_repository_setup
assert_equal :rspec, Retest::Setup.new.type
end

def test_starting_details
launch_retest @command

assert_output_matches <<~OUTPUT
Setup: [RSPEC]
Command: 'bundle exec rspec <test>'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT

modify_file('lib/bottles.rb')

assert_output_matches "Test file: spec/bottles_spec.rb"
end
end

class TestAliasCommand < Minitest::Test
include RetestHelper
include FileChanges

def setup
@command = "retest --rspec 'bin/retest <test>'"
end

def teardown
end_retest
end

def test_repository_setup
assert_equal :rspec, Retest::Setup.new.type
end

def test_starting_details
launch_retest @command

assert_output_matches <<~OUTPUT
Setup: [RSPEC]
Command: 'bin/retest <test>'
Watcher: [LISTEN]
Launching Retest...
Ready to refactor! You can make file changes now
OUTPUT

modify_file('lib/bottles.rb')

assert_output_matches "Test file: spec/bottles_spec.rb"
end
end
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
class FileChangesTest < Minitest::Test
include RetestHelper

def setup
@command = 'retest --rspec'
end

def teardown
end_retest
end

def test_start_retest
launch_retest @command

assert_output_matches <<~EXPECTED
Launching Retest...
Ready to refactor! You can make file changes now
EXPECTED
end
module FileChanges
# Don't forget to end_retest in the class
# def teardown
# end_retest
# end

def test_modifying_existing_file
launch_retest @command
Expand Down
27 changes: 0 additions & 27 deletions features/rspec-ruby/retest/retest_test/flags_test.rb

This file was deleted.

5 changes: 0 additions & 5 deletions features/rspec-ruby/retest/retest_test/setup_test.rb

This file was deleted.

0 comments on commit eed74a9

Please sign in to comment.