<commit_before>require "spec_helper"

module C2y
  describe DSL do
    describe "unit" do
      context "with options" do
        let(:cloudconfigfile) do
          CloudConfigFile.create do
          <<-EOS
unit "docker-tcp" do
  command :start
  enable true
  content <<-CONTENT
[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=2375
Service=docker.service
BindIPv6Only=both

[Install]
WantedBy=sockets.target
  CONTENT
end
          EOS
          end
        end

        it do
          dsl = described_class.parse(cloudconfigfile)
          expect(dsl.units.length).to eq 1
          unit = dsl.units.first
          expect(unit.name).to eq "docker-tcp"
          expect(unit.command).to eq "start"
          expect(unit.enable).to be true
          expect(unit.content).to eq(<<-EOS)
[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=2375
Service=docker.service
BindIPv6Only=both

[Install]
WantedBy=sockets.target
          EOS
        end
      end
    end
  end
end<commit_msg>Rewrite unit_dsl_spec<commit_after>require "spec_helper"

module C2y
  describe DSL do
    describe "unit" do
      context "with options" do
        let(:cloudconfigfile) do
          CloudConfigFile.create do
          <<-EOS
unit "docker-tcp" do
  command :start
  enable true
  content <<-CONTENT
[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=2375
Service=docker.service
BindIPv6Only=both

[Install]
WantedBy=sockets.target
  CONTENT
end
          EOS
          end
        end

        subject do
          dsl = described_class.parse(cloudconfigfile)
          dsl.units.first
        end

        its(:name) { is_expected.to eq "docker-tcp" }
        its(:command) { is_expected.to eq "start" }
        its(:enable) { is_expected.to be true }
        its(:content) { is_expected.to eq(<<-EOS) }
[Unit]
Description=Docker Socket for the API

[Socket]
ListenStream=2375
Service=docker.service
BindIPv6Only=both

[Install]
WantedBy=sockets.target
        EOS
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08652900688298919, 'fraction_numerical': 0.011307767944936086, 'mean_word_length': 2.5146804835924006, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7222940', 'n_tokens_mistral': 683, 'n_tokens_neox': 656, 'n_words': 166}