<commit_before>require 'spec_helper'

RSpec.xdescribe IMF::Image, '.open' do
  describe 'Abnormal conditions' do
    context 'Given a non-existing pathname' do
      it 'raise Errno::ENOENT', :with_tmpdir do
        expect {
          IMF::Image.open(Pathname(tmpdir).join('non_existing.jpg'))
        }.to raise_error(Errno::ENOENT)
      end
    end

    context 'Given a directory pathname' do
      it 'raise Errno::EISDIR', :with_tmpdir do
        expect {
          IMF::Image.open(Pathname(tmpdir))
        }.to raise_error(Errno::EISDIR)
      end
    end

    context 'Given a non-existing filename string' do
      it 'raise Errno::ENOENT', :with_tmpdir do
        expect {
          IMF::Image.open(File.join(tmpdir, 'non_existing.jpg'))
        }.to raise_error(Errno::ENOENT)
      end
    end

    context 'Given a directory name string' do
      it 'raise Errno::EISDIR', :with_tmpdir do
        expect {
          IMF::Image.open(tmpdir)
        }.to raise_error(Errno::EISDIR)
      end
    end

    context 'Given an object not a string nor a pathname' do
      it 'raises ArgumentError' do
        expect {
          IMF::Image.open(42)
        }.to raise_error(ArgumentError)
      end
    end
  end<commit_msg>:white_check_mark: Add an example for closed IO object<commit_after>require 'spec_helper'

RSpec.xdescribe IMF::Image, '.open' do
  describe 'Abnormal conditions' do
    context 'Given a non-existing pathname' do
      it 'raise Errno::ENOENT', :with_tmpdir do
        expect {
          IMF::Image.open(Pathname(tmpdir).join('non_existing.jpg'))
        }.to raise_error(Errno::ENOENT)
      end
    end

    context 'Given a directory pathname' do
      it 'raise Errno::EISDIR', :with_tmpdir do
        expect {
          IMF::Image.open(Pathname(tmpdir))
        }.to raise_error(Errno::EISDIR)
      end
    end

    context 'Given a non-existing filename string' do
      it 'raise Errno::ENOENT', :with_tmpdir do
        expect {
          IMF::Image.open(File.join(tmpdir, 'non_existing.jpg'))
        }.to raise_error(Errno::ENOENT)
      end
    end

    context 'Given a directory name string' do
      it 'raise Errno::EISDIR', :with_tmpdir do
        expect {
          IMF::Image.open(tmpdir)
        }.to raise_error(Errno::EISDIR)
      end
    end

    context 'Given a closed IO' do
      it 'raises ArgumentError' do
        expect {
          closed_io = $stdin.dup.close
          IMF::Image.open(closed_io)
        }.to raise_error(ArgumentError)
      end
    end

    context 'Given an object not a string nor a pathname' do
      it 'raises ArgumentError' do
        expect {
          IMF::Image.open(42)
        }.to raise_error(ArgumentError)
      end
    end
  end
{'fraction_non_alphanumeric': 0.10055045871559633, 'fraction_numerical': 0.0014678899082568807, 'mean_word_length': 2.3365973072215422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '6786280', 'n_tokens_mistral': 893, 'n_tokens_neox': 847, 'n_words': 230}