diff options
| author | Paul Buetow <paul@buetow.org> | 2025-02-18 15:24:53 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-02-18 15:24:53 +0200 |
| commit | fdbd63c6798c6c92b482d03b1f197cbeb41a5448 (patch) | |
| tree | db78dc0d35d3a89bbff16a94f7e225d25154c490 /test | |
| parent | cd1bdda5f963236dac849eb9257812f81c8af8ba (diff) | |
add ensure absent for file line
Diffstat (limited to 'test')
| -rw-r--r-- | test/lib/dslkeywords/file_test.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/test/lib/dslkeywords/file_test.rb b/test/lib/dslkeywords/file_test.rb index de1615a..60b659e 100644 --- a/test/lib/dslkeywords/file_test.rb +++ b/test/lib/dslkeywords/file_test.rb @@ -50,12 +50,32 @@ class RCMFileTest < Minitest::Test assert_equal 'One plus two is 3!', File.read(FILE_PATH) end - def test_ensure_line + def test_line File.write(FILE_PATH, "Hey there\n") - configure_from_scratch { file(FILE_PATH) { ensure_line 'Whats up?' } } + configure_from_scratch { file(FILE_PATH) { line 'Whats up?' } } assert_equal "Hey there\nWhats up?\n", File.read(FILE_PATH) end + def test_line_absent + File.write(FILE_PATH, "Hey there\nWhats up?") + configure_from_scratch do + file(FILE_PATH) do + line 'Whats up?' + is :absent + end + end + assert_equal 'Hey there', File.read(FILE_PATH) + + File.write(FILE_PATH, "Hey there\nWhats up?") + configure_from_scratch do + file(FILE_PATH) do + line 'Hey there' + is :absent + end + end + assert_equal 'Whats up?', File.read(FILE_PATH) + end + def test_create_parent_directory file_path = "#{DIR_PATH}/foo/bar/baz/foo.txt" configure_from_scratch do |
