Sha256: 270e68794e27a10c97390502f8e9bb64b8738da8e9350d1bb5743acc29c21dd2

Contents?: true

Size: 1.34 KB

Versions: 5

Compression:

Stored size: 1.34 KB

Contents

require 'rspec'

shared_examples_for 'success scenario' do
  it 'has status code of 200' do
    expect(described_class.status_code).to eq 200
  end
  context 'has expected mandatory elements' do
    described_class.api_class.expected_mandatory_elements.each do |mandatory_element|
      it mandatory_element do
        expect(described_class).to contain_key mandatory_element
      end
    end
    # TODO: Remove this. Handle depracated method temporariliy
    described_class.api_class.mandatory_elements.each do |mandatory_element|
      puts "Overriding 'mandatory_elements' deprecated. Use new 'expected_mandatory_elements' instead of overriding this method"
      it mandatory_element do
        expect(described_class).to contain_key mandatory_element
      end
    end
  end
  described_class.api_class.expected_mandatory_xpath_values.each do |xpath, value|
    it "has xpath '#{xpath}' equal to '#{value}'" do
      expect(described_class).to have_xpath_value(xpath => value)
    end
  end
  # TODO: Remove deprecated method
  described_class.api_class.mandatory_xpath_values.each do |xpath, value|
    puts "Overriding 'mandatory_elements' deprecated. Use new 'expected_mandatory_elements' instead of overriding this method"
    it "has xpath '#{xpath}' equal to '#{value}'" do
      expect(described_class).to have_xpath_value(xpath => value)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
soaspec-0.0.30 lib/soaspec/soaspec_shared_examples.rb
soaspec-0.0.29 lib/soaspec/soaspec_shared_examples.rb
soaspec-0.0.28 lib/soaspec/soaspec_shared_examples.rb
soaspec-0.0.27 lib/soaspec/soaspec_shared_examples.rb
soaspec-0.0.26 lib/soaspec/soaspec_shared_examples.rb