require 'html_processor/node_replacer'

describe HTMLProcessor::NodeReplacer do
  let(:html) {
    <<-EOHTML
<div>
    <h3>a rather important title</h3>
</div>
    EOHTML
  }

  let(:processor) { described_class.new(html) }

  describe '.process' do
    subject(:processed_html) { processor.process('//h3', 'h2') }

    it 'replaces the target XPath with the new tag' do
      expect(Nokogiri::HTML(processed_html).xpath('//h2')).to have(1).item
    end
  end
end

require 'nokogiri'
require 'html_processor/node_replacer'

describe HTMLProcessor::NodeReplacer do
  subject(:processor) { described_class.new(html) }

  let(:html) {
    <<-EOHTML
<div>
    <h3>a rather important title</h3>
</div>
    EOHTML
  }

  describe '.process' do
    subject(:processed_html) { processor.process('//h3', 'h2') }

    it 'replaces the target elements with the specified element' do
      expect(Nokogiri::HTML(processed_html).xpath('//h2')).to have(1).item
    end
  end
end

Improve output of HTMLProcessor::NodeReplacer spec
Improve output of HTMLProcessor::NodeReplacer spec