Class: Cucumber::Messages::Envelope

Inherits:
Message
  • Object
show all
Defined in:
lib/cucumber/messages/envelope.rb

Overview

Represents the Envelope message in Cucumber’s message protocol.

When removing a field, replace it with reserved, rather than deleting the line.

When adding a field, add it to the end and increment the number by one.
See https://developers.google.com/protocol-buffers/docs/proto#updating for details

*

All the messages that are passed between different components/processes are Envelope
messages.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Message

camelize, from_json, #to_h, #to_json

Constructor Details

#initialize(attachment: nil, gherkin_document: nil, hook: nil, meta: nil, parameter_type: nil, parse_error: nil, pickle: nil, source: nil, step_definition: nil, test_case: nil, test_case_finished: nil, test_case_started: nil, test_run_finished: nil, test_run_started: nil, test_step_finished: nil, test_step_started: nil, test_run_hook_started: nil, test_run_hook_finished: nil, undefined_parameter_type: nil) ⇒ Envelope

Returns a new instance of Envelope.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/cucumber/messages/envelope.rb', line 57

def initialize(
  attachment: nil,
  gherkin_document: nil,
  hook: nil,
  meta: nil,
  parameter_type: nil,
  parse_error: nil,
  pickle: nil,
  source: nil,
  step_definition: nil,
  test_case: nil,
  test_case_finished: nil,
  test_case_started: nil,
  test_run_finished: nil,
  test_run_started: nil,
  test_step_finished: nil,
  test_step_started: nil,
  test_run_hook_started: nil,
  test_run_hook_finished: nil,
  undefined_parameter_type: nil
)
  @attachment = attachment
  @gherkin_document = gherkin_document
  @hook = hook
  @meta = meta
  @parameter_type = parameter_type
  @parse_error = parse_error
  @pickle = pickle
  @source = source
  @step_definition = step_definition
  @test_case = test_case
  @test_case_finished = test_case_finished
  @test_case_started = test_case_started
  @test_run_finished = test_run_finished
  @test_run_started = test_run_started
  @test_step_finished = test_step_finished
  @test_step_started = test_step_started
  @test_run_hook_started = test_run_hook_started
  @test_run_hook_finished = test_run_hook_finished
  @undefined_parameter_type = undefined_parameter_type
  super()
end

Instance Attribute Details

#attachmentObject (readonly)

Returns the value of attribute attachment.



19
20
21
# File 'lib/cucumber/messages/envelope.rb', line 19

def attachment
  @attachment
end

#gherkin_documentObject (readonly)

Returns the value of attribute gherkin_document.



21
22
23
# File 'lib/cucumber/messages/envelope.rb', line 21

def gherkin_document
  @gherkin_document
end

#hookObject (readonly)

Returns the value of attribute hook.



23
24
25
# File 'lib/cucumber/messages/envelope.rb', line 23

def hook
  @hook
end

#metaObject (readonly)

Returns the value of attribute meta.



25
26
27
# File 'lib/cucumber/messages/envelope.rb', line 25

def meta
  @meta
end

#parameter_typeObject (readonly)

Returns the value of attribute parameter_type.



27
28
29
# File 'lib/cucumber/messages/envelope.rb', line 27

def parameter_type
  @parameter_type
end

#parse_errorObject (readonly)

Returns the value of attribute parse_error.



29
30
31
# File 'lib/cucumber/messages/envelope.rb', line 29

def parse_error
  @parse_error
end

#pickleObject (readonly)

Returns the value of attribute pickle.



31
32
33
# File 'lib/cucumber/messages/envelope.rb', line 31

def pickle
  @pickle
end

#sourceObject (readonly)

Returns the value of attribute source.



33
34
35
# File 'lib/cucumber/messages/envelope.rb', line 33

def source
  @source
end

#step_definitionObject (readonly)

Returns the value of attribute step_definition.



35
36
37
# File 'lib/cucumber/messages/envelope.rb', line 35

def step_definition
  @step_definition
end

#test_caseObject (readonly)

Returns the value of attribute test_case.



37
38
39
# File 'lib/cucumber/messages/envelope.rb', line 37

def test_case
  @test_case
end

#test_case_finishedObject (readonly)

Returns the value of attribute test_case_finished.



39
40
41
# File 'lib/cucumber/messages/envelope.rb', line 39

def test_case_finished
  @test_case_finished
end

#test_case_startedObject (readonly)

Returns the value of attribute test_case_started.



41
42
43
# File 'lib/cucumber/messages/envelope.rb', line 41

def test_case_started
  @test_case_started
end

#test_run_finishedObject (readonly)

Returns the value of attribute test_run_finished.



43
44
45
# File 'lib/cucumber/messages/envelope.rb', line 43

def test_run_finished
  @test_run_finished
end

#test_run_hook_finishedObject (readonly)

Returns the value of attribute test_run_hook_finished.



53
54
55
# File 'lib/cucumber/messages/envelope.rb', line 53

def test_run_hook_finished
  @test_run_hook_finished
end

#test_run_hook_startedObject (readonly)

Returns the value of attribute test_run_hook_started.



51
52
53
# File 'lib/cucumber/messages/envelope.rb', line 51

def test_run_hook_started
  @test_run_hook_started
end

#test_run_startedObject (readonly)

Returns the value of attribute test_run_started.



45
46
47
# File 'lib/cucumber/messages/envelope.rb', line 45

def test_run_started
  @test_run_started
end

#test_step_finishedObject (readonly)

Returns the value of attribute test_step_finished.



47
48
49
# File 'lib/cucumber/messages/envelope.rb', line 47

def test_step_finished
  @test_step_finished
end

#test_step_startedObject (readonly)

Returns the value of attribute test_step_started.



49
50
51
# File 'lib/cucumber/messages/envelope.rb', line 49

def test_step_started
  @test_step_started
end

#undefined_parameter_typeObject (readonly)

Returns the value of attribute undefined_parameter_type.



55
56
57
# File 'lib/cucumber/messages/envelope.rb', line 55

def undefined_parameter_type
  @undefined_parameter_type
end

Class Method Details

.from_h(hash) ⇒ Object

Returns a new Envelope from the given hash. If the hash keys are camelCased, they are properly assigned to the corresponding snake_cased attributes.

Cucumber::Messages::Envelope.from_h(some_hash) # => #<Cucumber::Messages::Envelope:0x... ...>


107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/cucumber/messages/envelope.rb', line 107

def self.from_h(hash)
  return nil if hash.nil?

  new(
    attachment: Attachment.from_h(hash[:attachment]),
    gherkin_document: GherkinDocument.from_h(hash[:gherkinDocument]),
    hook: Hook.from_h(hash[:hook]),
    meta: Meta.from_h(hash[:meta]),
    parameter_type: ParameterType.from_h(hash[:parameterType]),
    parse_error: ParseError.from_h(hash[:parseError]),
    pickle: Pickle.from_h(hash[:pickle]),
    source: Source.from_h(hash[:source]),
    step_definition: StepDefinition.from_h(hash[:stepDefinition]),
    test_case: TestCase.from_h(hash[:testCase]),
    test_case_finished: TestCaseFinished.from_h(hash[:testCaseFinished]),
    test_case_started: TestCaseStarted.from_h(hash[:testCaseStarted]),
    test_run_finished: TestRunFinished.from_h(hash[:testRunFinished]),
    test_run_started: TestRunStarted.from_h(hash[:testRunStarted]),
    test_step_finished: TestStepFinished.from_h(hash[:testStepFinished]),
    test_step_started: TestStepStarted.from_h(hash[:testStepStarted]),
    test_run_hook_started: TestRunHookStarted.from_h(hash[:testRunHookStarted]),
    test_run_hook_finished: TestRunHookFinished.from_h(hash[:testRunHookFinished]),
    undefined_parameter_type: UndefinedParameterType.from_h(hash[:undefinedParameterType])
  )
end