Class: Webspicy::Specification::TestCase

Inherits:
Object
  • Object
show all
Includes:
Webspicy::Support::DataObject
Defined in:
lib/webspicy/specification/test_case.rb

Direct Known Subclasses

Web::Specification::TestCase

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Webspicy::Support::DataObject

#method_missing, #to_info

Constructor Details

#initialize(raw) ⇒ TestCase

Returns a new instance of TestCase.



6
7
8
9
# File 'lib/webspicy/specification/test_case.rb', line 6

def initialize(raw)
  super(raw)
  @counterexample = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Webspicy::Support::DataObject

Instance Attribute Details

#counterexampleObject (readonly)

Returns the value of attribute counterexample.



11
12
13
# File 'lib/webspicy/specification/test_case.rb', line 11

def counterexample
  @counterexample
end

#serviceObject (readonly)

Returns the value of attribute service.



10
11
12
# File 'lib/webspicy/specification/test_case.rb', line 10

def service
  @service
end

Class Method Details

.info(raw) ⇒ Object



34
35
36
# File 'lib/webspicy/specification/test_case.rb', line 34

def self.info(raw)
  new(raw)
end

Instance Method Details

#assertObject



66
67
68
# File 'lib/webspicy/specification/test_case.rb', line 66

def assert
  @raw[:assert] || []
end

#bind(service, counterexample) ⇒ Object



13
14
15
16
17
# File 'lib/webspicy/specification/test_case.rb', line 13

def bind(service, counterexample)
  @service = service
  @counterexample = counterexample
  self
end

#counterexample?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/webspicy/specification/test_case.rb', line 23

def counterexample?
  !!@counterexample
end

#descriptionObject



38
39
40
# File 'lib/webspicy/specification/test_case.rb', line 38

def description
  @raw[:description]
end

#example?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/webspicy/specification/test_case.rb', line 19

def example?
  !@counterexample
end

#expectedObject



54
55
56
# File 'lib/webspicy/specification/test_case.rb', line 54

def expected
  @raw[:expected] || {}
end

#expected_errorObject



58
59
60
# File 'lib/webspicy/specification/test_case.rb', line 58

def expected_error
  expected[:error]
end

#has_assertions?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/webspicy/specification/test_case.rb', line 70

def has_assertions?
  !assert.empty?
end

#has_expected_error?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/webspicy/specification/test_case.rb', line 62

def has_expected_error?
  !expected_error.nil?
end

#metadataObject



46
47
48
# File 'lib/webspicy/specification/test_case.rb', line 46

def 
  @raw[:metadata] ||= {}
end

#mutate(override) ⇒ Object



74
75
76
77
78
# File 'lib/webspicy/specification/test_case.rb', line 74

def mutate(override)
  m = self.dup
  m.raw = self.raw.merge(override)
  m
end

#seedsObject



42
43
44
# File 'lib/webspicy/specification/test_case.rb', line 42

def seeds
  @raw[:seeds]
end

#specificationObject Also known as: resource



27
28
29
# File 'lib/webspicy/specification/test_case.rb', line 27

def specification
  service.specification
end

#tagsObject



50
51
52
# File 'lib/webspicy/specification/test_case.rb', line 50

def tags
  @raw[:tags] ||= []
end

#to_sObject



80
81
82
# File 'lib/webspicy/specification/test_case.rb', line 80

def to_s
  description
end