class Awspec::Generator::Spec::CloudwatchAlarm

Public Instance Methods

alarm_spec_template() click to toggle source
# File lib/awspec/generator/spec/cloudwatch_alarm.rb, line 11
      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
generate_all() click to toggle source
# File lib/awspec/generator/spec/cloudwatch_alarm.rb, line 5
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