Sha256: 535ff989c39f74dc33ecb4ce0a4ce873ad3fc576dfed6a41f267f4b330309442

Contents?: true

Size: 1.47 KB

Versions: 60

Compression:

Stored size: 1.47 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 %> }
<%- if alarm.unit != nil -%>
  its(:unit) { should eq '<%= alarm.unit %>' }
<% end -%>
  its(:evaluation_periods)  { should eq <%= alarm.evaluation_periods %> }
  its(:datapoints_to_alarm)  { should eq <%= alarm.datapoints_to_alarm %> }
  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

60 entries across 60 versions & 3 rubygems

Version Path
awspec-1.25.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.25.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.24.4 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.24.3 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.24.2 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.24.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.24.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.23.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.22.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.22.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.21.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.21.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.20.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.19.2 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.19.1 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.19.0 lib/awspec/generator/spec/cloudwatch_alarm.rb
cthiesfork-awspec-1.2.4 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-api_gateway_extended-1.2.4 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-api_gateway_extended-1.2.3 lib/awspec/generator/spec/cloudwatch_alarm.rb
awspec-1.18.6 lib/awspec/generator/spec/cloudwatch_alarm.rb