Class: MarkdownExec::TestHashDelegatorCountBlockInFilename

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

Instance Method Summary collapse

Instance Method Details

#setupObject



4533
4534
4535
4536
4537
4538
4539
# File 'lib/hash_delegator.rb', line 4533

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

#test_count_blocks_in_filenameObject



4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
# File 'lib/hash_delegator.rb', line 4541

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



4552
4553
4554
4555
4556
4557
4558
4559
4560
# File 'lib/hash_delegator.rb', line 4552

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