summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-01 18:38:49 +0200
committerPaul Buetow <paul@buetow.org>2026-03-01 18:38:49 +0200
commit08129b43792eeec92eacb9f47ce3f879489aa03c (patch)
treef527ba7c71c58536fa68b0acaef41dcd56a3cfc6 /test
parent861e526d9ad9228f2b740dbcf00cf39d8fe652f2 (diff)
make rcm usable as a gem from any directory, fix bugs and tests
- Add lib/rcm.rb entry point and bin/rcm CLI executable - Update gemspec: v0.1.0, proper files list, executables, runtime deps - Support standalone arg parsing and --hosts filtering in options - Fix inverted logic and typo in FileBackup#different? (== vs !=, cecksum_b) - Fix unqualified File.directory? resolving to RCM::File in Directory - Fix test_chown assertions running before evaluate! creates files - Add setup to file tests to prevent order-dependent failures Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Diffstat (limited to 'test')
-rw-r--r--test/lib/dslkeywords/file_test.rb6
-rw-r--r--test/lib/dslkeywords/mode_test.rb24
2 files changed, 18 insertions, 12 deletions
diff --git a/test/lib/dslkeywords/file_test.rb b/test/lib/dslkeywords/file_test.rb
index 35a0f21..a290627 100644
--- a/test/lib/dslkeywords/file_test.rb
+++ b/test/lib/dslkeywords/file_test.rb
@@ -12,6 +12,12 @@ class RCMFileTest < Minitest::Test
FileUtils.rm_r(DIR_PATH) if File.directory?(DIR_PATH)
end
+ # Clean up shared temp file between tests to prevent order-dependent failures
+ def setup
+ File.unlink(FILE_PATH) if File.file?(FILE_PATH)
+ FileUtils.rm_r(DIR_PATH) if File.directory?(DIR_PATH)
+ end
+
def test_create_file_from_string
text = 'Hello World!'
configure_from_scratch do
diff --git a/test/lib/dslkeywords/mode_test.rb b/test/lib/dslkeywords/mode_test.rb
index a4bf099..6e93bde 100644
--- a/test/lib/dslkeywords/mode_test.rb
+++ b/test/lib/dslkeywords/mode_test.rb
@@ -48,12 +48,12 @@ class RCMModeTest < Minitest::Test
end
def test_chown
- configure_from_scratch do
- # Well, test only makes sense that it doesn't throw any exception, as test
- # can't change files to other owners as test will likely run as non-root.
- user_name = Etc.getlogin
- group_name = Etc.getgrgid(Process.gid).name
+ # Test only verifies no exception is thrown, as test runs as non-root
+ # and can't change files to other owners.
+ user_name = Etc.getlogin
+ group_name = Etc.getgrgid(Process.gid).name
+ configure_from_scratch do
touch FILE1_PATH do
owner user_name
group group_name
@@ -62,14 +62,14 @@ class RCMModeTest < Minitest::Test
owner user_name
group group_name
end
+ end
- stat = File.stat(FILE1_PATH)
- assert_equal user_name, Etc.getpwuid(stat.uid)
- assert_equal group_name, Etc.getgrgid(stat.gid)
+ stat = File.stat(FILE1_PATH)
+ assert_equal user_name, Etc.getpwuid(stat.uid).name
+ assert_equal group_name, Etc.getgrgid(stat.gid).name
- stat = File.stat(DIR_PATH)
- assert_equal user_name, Etc.getpwuid(stat.uid)
- assert_equal group_name, Etc.getgrgid(stat.gid)
- end
+ stat = File.stat(DIR_PATH)
+ assert_equal user_name, Etc.getpwuid(stat.uid).name
+ assert_equal group_name, Etc.getgrgid(stat.gid).name
end
end