Class: Kontrast::Test

Inherits:
Object
  • Object
show all
Defined in:
lib/kontrast/test.rb

Direct Known Subclasses

ApiEndpointTest, PageTest

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(prefix, name, path, headers: {}) ⇒ Test

Returns a new instance of Test.



5
6
7
# File 'lib/kontrast/test.rb', line 5

def initialize(prefix, name, path, headers: {})
    @prefix, @name, @path, @headers = prefix, name, path, headers
end

Instance Attribute Details

#headersObject (readonly)

Returns the value of attribute headers.



3
4
5
# File 'lib/kontrast/test.rb', line 3

def headers
  @headers
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/kontrast/test.rb', line 3

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



3
4
5
# File 'lib/kontrast/test.rb', line 3

def path
  @path
end

#prefixObject (readonly)

Returns the value of attribute prefix.



3
4
5
# File 'lib/kontrast/test.rb', line 3

def prefix
  @prefix
end

#specObject (readonly)

Returns the value of attribute spec.



3
4
5
# File 'lib/kontrast/test.rb', line 3

def spec
  @spec
end

Instance Method Details

#bind_spec(spec) ⇒ Object



9
10
11
# File 'lib/kontrast/test.rb', line 9

def bind_spec(spec)
    @spec = spec
end

#run_callback(name, *args) ⇒ Object

Usage: test.run_callback(:before_screenshot, arg1, arg2, arg3)



14
15
16
17
# File 'lib/kontrast/test.rb', line 14

def run_callback(name, *args)
    return if @spec.nil?
    @spec.send(name.to_sym, *args)
end

#to_sObject



19
20
21
# File 'lib/kontrast/test.rb', line 19

def to_s
    return "#{@prefix}_#{@name}"
end

#to_strObject



23
24
25
# File 'lib/kontrast/test.rb', line 23

def to_str
    return to_s
end