Sha256: a716d8f2281b8470b7ce6779f1c5807b6e2954bf8382061026ccd75ee06a504e

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 deprecated method temporarily
    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.35 lib/soaspec/soaspec_shared_examples.rb
soaspec-0.0.34 lib/soaspec/soaspec_shared_examples.rb
soaspec-0.0.33 lib/soaspec/soaspec_shared_examples.rb
soaspec-0.0.32 lib/soaspec/soaspec_shared_examples.rb
soaspec-0.0.31 lib/soaspec/soaspec_shared_examples.rb