<commit_before>require 'spec_helper'

class Convection::Model::Template::Resource
  describe EventsRule do
    let(:template) do
      Convection.template do
        description 'EventsRule Test Template'

        # TODO: Test simple properties of EventsRule as well?
        events_rule 'MyEventsRule' do
          event_pattern 'source', %w(aws.ec2)
          event_pattern 'detail', 'state' => %w(running)
          event_pattern 'detail-type', ['EC2 Instance State-change Notification']
        end
      end
    end

    subject do
      template_json
        .fetch('Resources')
        .fetch('MyEventsRule')
        .fetch('Properties')
    end

    it 'combines all event pattern calls into a single event pattern JSON object' do
      p template_json
      p subject
      p subject['EventPattern']
      expect(subject['EventPattern']).to include(
        'source' => %w(aws.ec2),
        'detail' => { 'state' => %w(running) },
        'detail-type' => ['EC2 Instance State-change Notification']
      )
    end

    private

    def template_json
      JSON.parse(template.to_json)
    end
  end
end<commit_msg>Remove uneeded debug steps from events_rule_spec.rb<commit_after>require 'spec_helper'

class Convection::Model::Template::Resource
  describe EventsRule do
    let(:template) do
      Convection.template do
        description 'EventsRule Test Template'

        # TODO: Test simple properties of EventsRule as well?
        events_rule 'MyEventsRule' do
          event_pattern 'source', %w(aws.ec2)
          event_pattern 'detail', 'state' => %w(running)
          event_pattern 'detail-type', ['EC2 Instance State-change Notification']
        end
      end
    end

    subject do
      template_json
        .fetch('Resources')
        .fetch('MyEventsRule')
        .fetch('Properties')
    end

    it 'combines all event pattern calls into a single event pattern JSON object' do
      expect(subject['EventPattern']).to include(
        'source' => %w(aws.ec2),
        'detail' => { 'state' => %w(running) },
        'detail-type' => ['EC2 Instance State-change Notification']
      )
    end

    private

    def template_json
      JSON.parse(template.to_json)
    end
  end
end
{'fraction_non_alphanumeric': 0.10243682310469314, 'fraction_numerical': 0.0036101083032490976, 'mean_word_length': 2.5585874799357944, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3400202', 'n_tokens_mistral': 630, 'n_tokens_neox': 622, 'n_words': 176}