Sha256: 39bbcdca676d45b82a87b0a5c488f3b11bdd7bafda27cd05a6837c3546d3d6cb

Contents?: true

Size: 1.94 KB

Versions: 2

Compression:

Stored size: 1.94 KB

Contents

require 'yaml'

require "codeclimate-test-reporter"
CodeClimate::TestReporter.start

# Configure Rails Environment
ENV["RAILS_ENV"] = "test"

env_file = File.join(Pathname.new(__FILE__).parent.parent, 'config', 'application.yml')
YAML.load(File.open(env_file)).each do |key, value|
  ENV[key.to_s] = value.to_s
end if File.exists?(env_file)

require File.expand_path("../../test/dummy/config/environment.rb",  __FILE__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
require "rails/test_help"

# Filter out Minitest backtrace while allowing backtrace from other libraries
# to be shown.
Minitest.backtrace_filter = Minitest::BacktraceFilter.new

# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }

# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
  ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
end

def define_get_tests_auto(klass)
	klass.extended_methods.keys.grep(/^get_/).each do |extended_method|
    define_method("test_#{extended_method}_auto") do
      url_parameters_signature = klass.extended_methods[extended_method][:url_parameters]
      body_parameters_signature = klass.extended_methods[extended_method][:body_parameters]

      url_params = {}
      if url_parameters_signature
        url_parameters_signature.each do |url_parameter|
          url_params[url_parameter] = ENV[url_parameter.to_s.underscore]
        end
      end

      body_params = {}
      body_parameters_signature.each do |body_parameter|
        body_params[body_parameter] = ENV[body_parameter.to_s.underscore]
      end
      timestamp = Time.now.to_i * 1000
      body_params[:timestamp] = timestamp
      body_params[:hash] = Epom.create_hash(Epom.create_hash(ENV['password']), timestamp)

      response = klass.send(extended_method, url_params, body_params)
      assert_not_instance_of Fixnum, response
    end
	end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
epom-0.3 test/test_helper.rb
epom-0.1.0 test/test_helper.rb