Class: Spectro::Spec::Rule

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

Overview

Assert representation based on input params and an expected output. Meant to be used against an algorith to test its behavior.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, output) ⇒ Rule

Returns a new instance of Rule.

Parameters:

  • parmas (<Object>)

    set of input params

  • output (<Object>)

    expected result



13
14
15
16
# File 'lib/spectro/spec/rule.rb', line 13

def initialize params, output
  self.output = output
  self.params = params
end

Instance Attribute Details

#outputObject

Returns the value of attribute output.



9
10
11
# File 'lib/spectro/spec/rule.rb', line 9

def output
  @output
end

#paramsObject

Returns the value of attribute params.



9
10
11
# File 'lib/spectro/spec/rule.rb', line 9

def params
  @params
end

Instance Method Details

#==(rule) ⇒ Object



18
19
20
21
22
# File 'lib/spectro/spec/rule.rb', line 18

def == rule
  return \
    self.output == rule.output && \
    self.params == rule.params
end

#to_hashObject



24
25
26
27
28
29
# File 'lib/spectro/spec/rule.rb', line 24

def to_hash
  return {
    output: self.output,
    params: self.params
  }
end