Class: MarkdownExec::TestLinkHistory

Inherits:
Minitest::Test
  • Object
show all
Defined in:
lib/link_history.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



142
143
144
145
146
147
148
149
150
151
152
# File 'lib/link_history.rb', line 142

def setup
  @link_history = LinkHistory.new
  @link_state1 = LinkState.new(
    block_name: 'block1', document_filename: 'document1.txt',
    context_code: ['code1.rb']
  )
  @link_state2 = LinkState.new(
    block_name: 'block2', document_filename: 'document2.txt',
    context_code: ['code2.rb']
  )
end

#test_context_code_accessorObject



174
175
176
177
# File 'lib/link_history.rb', line 174

def test_context_code_accessor
  state = LinkState.new(context_code: %w[line1 line2])
  assert_equal %w[line1 line2], state.context_code
end

#test_context_code_appendObject



184
185
186
187
188
# File 'lib/link_history.rb', line 184

def test_context_code_append
  state = LinkState.new(context_code: ['line1'])
  state.context_code_append(['line2'])
  assert_equal %w[line1 line2], state.context_code
end

#test_context_code_blockObject



179
180
181
182
# File 'lib/link_history.rb', line 179

def test_context_code_block
  state = LinkState.new(context_code: %w[line1 line2])
  assert_equal "line1\nline2", state.context_code_block
end

#test_context_code_countObject



190
191
192
193
# File 'lib/link_history.rb', line 190

def test_context_code_count
  state = LinkState.new(context_code: %w[line1 line2 line3])
  assert_equal 3, state.context_code_count
end

#test_context_code_equalityObject



202
203
204
205
206
207
208
# File 'lib/link_history.rb', line 202

def test_context_code_equality
  state1 = LinkState.new(context_code: ['line1'])
  state2 = LinkState.new(context_code: ['line1'])
  state3 = LinkState.new(context_code: ['line2'])
  assert_equal state1, state2
  refute_equal state1, state3
end

#test_context_code_present?Boolean

Returns:

  • (Boolean)


195
196
197
198
199
200
# File 'lib/link_history.rb', line 195

def test_context_code_present?
  state_with_code = LinkState.new(context_code: ['line1'])
  state_without_code = LinkState.new(context_code: nil)
  assert state_with_code.context_code_present?
  refute state_without_code.context_code_present?
end

#test_deprecated_context_code_methodsObject



210
211
212
213
214
215
216
217
# File 'lib/link_history.rb', line 210

def test_deprecated_context_code_methods
  state = LinkState.new(context_code: %w[line1 line2])
  # Test backward compatibility
  assert_equal %w[line1 line2], state.context_code
  assert_equal "line1\nline2", state.context_code_block
  assert_equal 2, state.context_code_count
  assert state.context_code_present?
end

#test_peek_emptyObject



166
167
168
# File 'lib/link_history.rb', line 166

def test_peek_empty
  assert_equal LinkState.empty, @link_history.peek
end

#test_popObject



159
160
161
162
163
164
# File 'lib/link_history.rb', line 159

def test_pop
  @link_history.push(@link_state1)
  @link_history.push(@link_state2)
  assert_equal @link_state2, @link_history.pop
  assert_equal @link_state1, @link_history.peek
end

#test_pop_emptyObject



170
171
172
# File 'lib/link_history.rb', line 170

def test_pop_empty
  assert_equal LinkState.empty, @link_history.pop
end

#test_pushObject



154
155
156
157
# File 'lib/link_history.rb', line 154

def test_push
  @link_history.push(@link_state1)
  assert_equal @link_state1, @link_history.peek
end