Sha256: 68258ba4c75d579cf5dbe1622866329dfb549e2703038c4a510b4bf0728beb28

Contents?: true

Size: 836 Bytes

Versions: 4

Compression:

Stored size: 836 Bytes

Contents

module ForemanAnsible
  # Allow to add fixtures to plugins
  module PluginFixtures
    FIXTURE_MAPPING = {
      :ansible_permissions => :permissions
    }.freeze

    def self.add_fixtures(new_fixture_path)
      FileUtils.cp(
        Dir.glob(Rails.root.join('test', 'fixtures', '*')),
        new_fixture_path
      )
      copy_plugin_fixtures new_fixture_path
    end

    def self.copy_plugin_fixtures(new_fixture_path)
      FIXTURE_MAPPING.each do |key, value|
        fixture_path = "#{ForemanAnsible::Engine.root}/test/fixtures/#{key}.yml"
        break unless File.exist?(fixture_path)
        File.open("#{new_fixture_path}/#{value}.yml", 'a') do |file|
          File.open(fixture_path, 'r').each do |line|
            next if line =~ /---/
            file.write line
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
foreman_ansible-1.5.2 test/support/fixture_support.rb
foreman_ansible-1.5.1 test/support/fixture_support.rb
foreman_ansible-1.5.0 test/support/fixture_support.rb
foreman_ansible-1.4.6 test/support/fixture_support.rb