<commit_before>require 'inline_svg'
require 'nokogiri'
require 'active_support/core_ext'

describe InlineSvg::ActionView::Helpers do

  before(:each) do
    # Mock Rails
    unless defined?(::Rails)
      @mocked_rails_class = true
      class ::Rails
      end
    end
    # Allow mock Rails to give a path to our SVG
    path_mocker = double("path_mocker")
    allow(path_mocker).to receive(:join) { 'spec/files/example.svg' }
    allow(Rails).to receive(:root) { path_mocker }
  end

  let(:mock_helper) { ( Class.new { include InlineSvg::ActionView::Helpers } ).new }

  describe "#inline_svg" do
    
    context 'when passed a SVG file' do
      
      subject { mock_helper.inline_svg( 'mocked_path' ) }
      let(:example_svg) {
<<-SVG.sub(/\n$/, '')
<svg xmlns="http://www.w3.org/2000/svg" role="presentation" xml:lang="en"></svg>
SVG
      }
      
      it { is_expected.to eql example_svg }
      
      context 'and additional options' do
      
        subject { mock_helper.inline_svg( 'mocked_path', title: 'A title', desc: 'A desc' ) }
        let(:example_svg) {
<<-SVG.sub(/\n$/, '')
<svg xmlns="http://www.w3.org/2000/svg" role="presentation" xml:lang="en"><title>A title</title>
<desc>A desc</desc></svg>
SVG
        }
        
        it { is_expected.to eql example_svg }
      
      end # 'and additional options'
    <commit_msg>Improve test naming<commit_after>require 'inline_svg'
require 'nokogiri'
require 'active_support/core_ext'

describe InlineSvg::ActionView::Helpers do

  before(:each) do
    # Mock Rails
    unless defined?(::Rails)
      @mocked_rails_class = true
      class ::Rails
      end
    end
    # Allow mock Rails to give a path to our SVG
    path_mocker = double("path_mocker")
    allow(path_mocker).to receive(:join) { 'spec/files/example.svg' }
    allow(Rails).to receive(:root) { path_mocker }
  end

  let(:mock_helper) { ( Class.new { include InlineSvg::ActionView::Helpers } ).new }

  describe "#inline_svg" do
    
    context 'when passed a SVG file' do
      
      subject { mock_helper.inline_svg( 'mocked_path' ) }
      let(:example_svg) {
<<-SVG.sub(/\n$/, '')
<svg xmlns="http://www.w3.org/2000/svg" role="presentation" xml:lang="en"></svg>
SVG
      }
      
      it { is_expected.to eql example_svg }
      
      context 'and title and description options' do
      
        subject { mock_helper.inline_svg( 'mocked_path', title: 'A title', desc: 'A desc' ) }
        let(:example_svg) {
<<-SVG.sub(/\n$/, '')
<svg xmlns="http://www.w3.org/2000/svg" role="presentation" xml:lang="en"><title>A title</title>
<desc>A desc</desc></svg>
SVG
        }
        
        it { is_expected.to eql example_svg }
      
      end # 'and additional options'
    
{'fraction_non_alphanumeric': 0.1444811147781445, 'fraction_numerical': 0.007334066740007334, 'mean_word_length': 2.847672778561354, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 8}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '222576', 'n_tokens_mistral': 964, 'n_tokens_neox': 933, 'n_words': 206}