module Kontrast

Constants

LazyTest
VERSION

Attributes

api_endpoint_builder[RW]
configuration[RW]
page_builder[RW]
spec_builder[RW]

Public Class Methods

api_endpoint_test_builder() click to toggle source
# File lib/kontrast/configuration.rb, line 14
def api_endpoint_test_builder
    self.api_endpoint_builder ||= TestBuilder.new
end
api_endpoint_test_suite() click to toggle source
# File lib/kontrast/configuration.rb, line 22
def api_endpoint_test_suite
    self.api_endpoint_builder ? self.api_endpoint_builder.suite : nil
end
configure() { |configuration| ... } click to toggle source
# File lib/kontrast/configuration.rb, line 5
def configure
    self.configuration ||= Configuration.new
    yield(configuration)
end
describe(spec_name) { |get_spec_builder| ... } click to toggle source
# File lib/kontrast/spec_builder.rb, line 9
def describe(spec_name)
    self.get_spec_builder.add(spec_name)
    yield(self.get_spec_builder)
end
fog() click to toggle source
# File lib/kontrast.rb, line 61
def fog
    return Fog::Storage.new({
        :provider                 => 'AWS',
        :aws_access_key_id        => Kontrast.configuration.aws_key,
        :aws_secret_access_key    => Kontrast.configuration.aws_secret
    })
end
get_spec_builder() click to toggle source
# File lib/kontrast/spec_builder.rb, line 5
def get_spec_builder
    self.spec_builder ||= SpecBuilder.new
end
in_rails?() click to toggle source
# File lib/kontrast.rb, line 34
def in_rails?
    # Logic: Rails uses Bundler, so if the Bundler environment contains Rails, return true.
    # If there's any error whatsoever, return false.
    begin
        Bundler.environment.current_dependencies.each do |dep|
            return true if dep.name == "rails"
        end
    rescue StandardError => e
        # Quietly ignore any exceptions
    end
    return false
end
page_test_builder() click to toggle source
# File lib/kontrast/configuration.rb, line 10
def page_test_builder
    self.page_builder ||= TestBuilder.new
end
page_test_suite() click to toggle source
# File lib/kontrast/configuration.rb, line 18
def page_test_suite
    self.page_builder ? self.page_builder.suite : nil
end
path() click to toggle source
# File lib/kontrast.rb, line 47
def path
    return @@path if @@path

    if Kontrast.configuration.run_parallel
        @@path = FileUtils.mkdir_p(Kontrast.configuration.local_path).join('')
    elsif Kontrast.in_rails?
        @@path = FileUtils.mkdir_p(Rails.root + "tmp/shots/#{Time.now.to_i}").join('')
    else
        @@path = FileUtils.mkdir_p("/tmp/shots/#{Time.now.to_i}").join('')
    end

    return @@path
end
root() click to toggle source
# File lib/kontrast.rb, line 30
def root
    File.expand_path('../..', __FILE__)
end
run() click to toggle source
# File lib/kontrast.rb, line 69
def run
    beginning_time = Time.now

    begin
        # Call "before" hook
        Kontrast.configuration.before_run

        runner = GlobalRunner.new
        runner.run
    ensure
        # Call "after" hook
        Kontrast.configuration.after_run
    end

    end_time = Time.now
    puts "Time elapsed: #{(end_time - beginning_time)} seconds"
end