Class: Evergreen::Spec

Inherits:
Object
  • Object
show all
Defined in:
lib/evergreen/spec.rb

Defined Under Namespace

Classes: CoffeeScriptError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(suite, name) ⇒ Spec

Returns a new instance of Spec.



9
10
11
12
# File 'lib/evergreen/spec.rb', line 9

def initialize(suite, name)
  @suite = suite
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/evergreen/spec.rb', line 7

def name
  @name
end

#suiteObject (readonly)

Returns the value of attribute suite.



7
8
9
# File 'lib/evergreen/spec.rb', line 7

def suite
  @suite
end

Instance Method Details

#exist?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/evergreen/spec.rb', line 45

def exist?
  File.exist?(full_path)
end

#failure_messagesObject



41
42
43
# File 'lib/evergreen/spec.rb', line 41

def failure_messages
  runner.failure_messages
end

#full_pathObject



18
19
20
# File 'lib/evergreen/spec.rb', line 18

def full_path
  File.join(root, Evergreen.spec_dir, name)
end

#passed?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/evergreen/spec.rb', line 37

def passed?
  runner.passed?
end

#readObject Also known as: contents



22
23
24
25
26
27
28
29
30
# File 'lib/evergreen/spec.rb', line 22

def read
  if full_path =~ /\.coffee$/
    stdout, stderr = Open3.popen3("coffee -p #{full_path}")[1,2].map { |b| b.read }
    raise CoffeeScriptError, stderr unless stderr.empty?
    stdout
  else
    File.read(full_path)
  end
end

#rootObject



14
15
16
# File 'lib/evergreen/spec.rb', line 14

def root
  suite.root
end

#urlObject



33
34
35
# File 'lib/evergreen/spec.rb', line 33

def url
  "/run/#{name}"
end