Class: MarkdownExec::TestHashDelegator::TestHashDelegatorCountBlockInFilename

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

Instance Method Summary collapse

Instance Method Details

#setupObject



2613
2614
2615
2616
2617
2618
2619
# File 'lib/hash_delegator.rb', line 2613

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



2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
# File 'lib/hash_delegator.rb', line 2621

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



2632
2633
2634
2635
2636
2637
2638
2639
2640
# File 'lib/hash_delegator.rb', line 2632

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