Sha256: 10df14c7a70fdb8443d9cdf67af5a71012a802c83430413ffe6e0ca9ee2a596d

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'cypress_on_rails/configuration'

module CypressOnRails
  # loads and evals the command files
  class CommandExecutor
    def self.perform(file,command_options = nil)
      load_e2e_helper
      file_data = File.read(file)
      eval file_data, binding, file
    rescue => e
      logger.error("fail to execute #{file}: #{e.message}")
      logger.error(e.backtrace.join("\n"))
      raise e
    end

    def self.load_e2e_helper
      e2e_helper_file = "#{configuration.install_folder}/e2e_helper.rb"
      cypress_helper_file = "#{configuration.install_folder}/cypress_helper.rb"
      if File.exist?(e2e_helper_file)
        Kernel.require e2e_helper_file
      elsif File.exist?(cypress_helper_file)
        Kernel.require cypress_helper_file
        warn "cypress_helper.rb is deprecated, please rename the file to e2e_helper.rb"
      else
        logger.warn "could not find #{e2e_helper_file} nor #{cypress_helper_file}"
      end
    end

    def self.logger
      configuration.logger
    end

    def self.configuration
      CypressOnRails.configuration
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cypress-on-rails-1.17.0 lib/cypress_on_rails/command_executor.rb
cypress-on-rails-1.16.0 lib/cypress_on_rails/command_executor.rb
cypress-on-rails-1.15.1 lib/cypress_on_rails/command_executor.rb