Class: MarkdownExec::TestHashDelegator::TestHashDelegatorCountBlockInFilename

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

Instance Method Summary collapse

Instance Method Details

#setupObject



2767
2768
2769
2770
2771
2772
2773
# File 'lib/hash_delegator.rb', line 2767

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



2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
# File 'lib/hash_delegator.rb', line 2775

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



2786
2787
2788
2789
2790
2791
2792
2793
2794
# File 'lib/hash_delegator.rb', line 2786

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