Sha256: 5a07ec1b53d4ac042e9cfcf568648d586fe88d9ec56cde959e842b065ef9ee72

Contents?: true

Size: 1.36 KB

Versions: 119

Compression:

Stored size: 1.36 KB

Contents

module Awspec::Generator
  module Spec
    class CloudwatchAlarm
      include Awspec::Helper::Finder
      def generate_all
        alarms = select_all_cloudwatch_alarms
        raise 'Not Found alarm' if alarms.empty?
        ERB.new(alarm_spec_template, nil, '-').result(binding).chomp
      end

      def alarm_spec_template
        template = <<-'EOF'
<% alarms.each do |alarm| %>
describe cloudwatch_alarm('<%= alarm.alarm_name %>') do
  it { should exist }
<%- alarm.ok_actions.each do |action| -%>
  it { should have_ok_action('<%= action %>') }
<%- end -%>
<%- alarm.alarm_actions.each do |action| -%>
  it { should have_alarm_action('<%= action %>') }
<%- end -%>
<%- alarm.insufficient_data_actions.each do |action| -%>
  it { should have_insufficient_data_action('<%= action %>') }
<%- end -%>
  it { should belong_to_metric('<%= alarm.metric_name %>').namespace('<%= alarm.namespace %>') }
  its(:state_value) { should eq '<%= alarm.state_value %>' }
  its(:statistic) { should eq '<%= alarm.statistic %>' }
  its(:period) { should eq <%= alarm.period %> }
  its(:unit) { should eq '<%= alarm.unit %>' }
  its(:evaluation_periods)  { should eq <%= alarm.evaluation_periods %> }
  its(:threshold)  { should eq <%= alarm.threshold %> }
  its(:comparison_operator)  { should eq '<%= alarm.comparison_operator %>' }
end
<% end %>
EOF
        template
      end
    end
  end
end

Version data entries

119 entries across 119 versions & 2 rubygems

Version Path
awspec-1.5.3 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.5.2 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.5.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.5.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.4.3 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.4.2 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.4.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.4.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.3.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.3.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.2.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.1.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.0.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.0.0.rc lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-0.88.2 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-0.88.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-0.88.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-0.87.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-0.87.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-0.86.0 lib/awspec/generator/spec/cloudwatch_alarm.rb