bsdcontrol.rb/test/unprivileged/readme_examples_test.rb

26 lines
643 B
Ruby
Raw Normal View History

2024-05-12 05:59:38 +02:00
# frozen_string_literal: true
2024-05-13 03:49:15 +02:00
require_relative "../setup"
2024-05-12 05:53:21 +02:00
2024-05-13 03:50:19 +02:00
module BSD::Control
class ReadmeExamplesTest < BSD::Control::Test
require "test/cmd"
2024-05-12 05:53:21 +02:00
2024-05-13 03:50:19 +02:00
def test_available_features_success
assert_equal true,
2024-05-13 16:26:29 +02:00
cmd("ruby", readme_example("1_available_features.rb")).success?
2024-05-13 03:50:19 +02:00
end
2024-05-12 06:32:20 +02:00
2024-05-13 03:50:19 +02:00
def test_available_features_stdout
2024-05-13 21:02:17 +02:00
assert_match %r|\A(The [a-zA-Z0-9_]+ feature is available\n){9}\z|,
cmd("ruby", readme_example("1_available_features.rb")).stdout
2024-05-13 03:50:19 +02:00
end
2024-05-12 05:53:21 +02:00
2024-05-13 03:50:19 +02:00
private
2024-05-12 05:53:21 +02:00
2024-05-13 03:50:19 +02:00
def readme_example(name)
File.join(Dir.getwd, "share", "bsdcontrol.rb", "examples", name)
end
2024-05-12 05:53:21 +02:00
end
end