Class: MarkdownExec::TestHashDelegatorCountBlockInFilename

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

Instance Method Summary collapse

Instance Method Details

#setupObject



6612
6613
6614
6615
6616
6617
6618
# File 'lib/hash_delegator.rb', line 6612

def setup
  @hd = HashDelegator.new(
    fenced_start_and_end_regex: '^```',
    filename: '/path/to/file'
  )
  @hd.stubs(:cfile).returns(mock('cfile'))
end

#test_count_blocks_in_filenameObject



6620
6621
6622
6623
6624
6625
6626
6627
6628
6629
# File 'lib/hash_delegator.rb', line 6620

def test_count_blocks_in_filename
  file_content = ["```ruby\n", "puts 'Hello'\n", "```\n",
                  "```python\n", "print('Hello')\n", "```\n"]
  @hd.cfile.stubs(:readlines)
     .with('/path/to/file', import_paths: nil).returns(file_content)

  count = @hd.count_blocks_in_filename

  assert_equal 2, count
end

#test_count_blocks_in_filename_with_no_matchesObject



6631
6632
6633
6634
6635
6636
6637
6638
6639
# File 'lib/hash_delegator.rb', line 6631

def test_count_blocks_in_filename_with_no_matches
  file_content = ["puts 'Hello'\n", "print('Hello')\n"]
  @hd.cfile.stubs(:readlines)
     .with('/path/to/file', import_paths: nil).returns(file_content)

  count = @hd.count_blocks_in_filename

  assert_equal 0, count
end