Module: Evergreen

Defined in:
lib/evergreen.rb,
lib/evergreen/cli.rb,
lib/evergreen/spec.rb,
lib/evergreen/rails.rb,
lib/evergreen/suite.rb,
lib/evergreen/helper.rb,
lib/evergreen/runner.rb,
lib/evergreen/server.rb,
lib/evergreen/version.rb,
lib/evergreen/template.rb,
lib/evergreen/application.rb,
lib/evergreen/utils/timeout.rb

Defined Under Namespace

Classes: Application, Cli, Helper, Railtie, Runner, Server, Spec, Suite, Template

Constant Summary collapse

VERSION =
'1.3.0'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.applicationObject

Returns the value of attribute application.



20
21
22
# File 'lib/evergreen.rb', line 20

def application
  @application
end

.driverObject

Returns the value of attribute driver.



20
21
22
# File 'lib/evergreen.rb', line 20

def driver
  @driver
end

.helper_dirObject

Returns the value of attribute helper_dir.



20
21
22
# File 'lib/evergreen.rb', line 20

def helper_dir
  @helper_dir
end

.mounted_atObject

Returns the value of attribute mounted_at.



20
21
22
# File 'lib/evergreen.rb', line 20

def mounted_at
  @mounted_at
end

.public_dirObject

Returns the value of attribute public_dir.



20
21
22
# File 'lib/evergreen.rb', line 20

def public_dir
  @public_dir
end

.rootObject

Returns the value of attribute root.



20
21
22
# File 'lib/evergreen.rb', line 20

def root
  @root
end

.spec_dirObject

Returns the value of attribute spec_dir.



20
21
22
# File 'lib/evergreen.rb', line 20

def spec_dir
  @spec_dir
end

.spec_timeoutObject

Returns the value of attribute spec_timeout.



20
21
22
# File 'lib/evergreen.rb', line 20

def spec_timeout
  @spec_timeout
end

.template_dirObject

Returns the value of attribute template_dir.



20
21
22
# File 'lib/evergreen.rb', line 20

def template_dir
  @template_dir
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Evergreen)

    the object that the method was called on



22
23
24
# File 'lib/evergreen.rb', line 22

def configure
  yield self
end

.timeout(seconds = 1, error_message = nil, &block) ⇒ Object

Provides timeout similar to standard library Timeout, but avoids threads



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/evergreen/utils/timeout.rb', line 7

def timeout(seconds = 1, error_message = nil, &block)
  start_time = Time.now

  result = nil

  until result
    return result if result = yield

    delay = seconds - (Time.now - start_time)
    if delay <= 0
      raise TimeoutError, error_message || "timed out"
    end

    sleep(0.05)
  end
end

.use_defaults!Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/evergreen.rb', line 26

def use_defaults!
  configure do |config|
    config.application  = Evergreen::Application
    config.driver       = :selenium
    config.public_dir   = 'public'
    config.spec_dir     = 'spec/javascripts'
    config.template_dir = 'spec/javascripts/templates'
    config.helper_dir   = 'spec/javascripts/helpers'
    config.mounted_at   = ""
    config.spec_timeout = 300
  end
end