<commit_before>require File.dirname(__FILE__) + '/../../spec_helper'
require 'stringio'

describe "StringIO#initialize when passed [Object, Integer]" do
  it "sets the mode based on the passed Integer" do
    io = StringIO.allocate
    io.send(:initialize, "example", IO::RDONLY)
    io.closed_read?.should be_false
    io.closed_write?.should be_true

    io = StringIO.allocate
    io.send(:initialize, "example", IO::WRONLY)
    io.closed_read?.should be_true
    io.closed_write?.should be_false

    io = StringIO.allocate
    io.send(:initialize, "example", IO::RDWR)
    io.closed_read?.should be_false
    io.closed_write?.should be_false

    io = StringIO.allocate
    io.send(:initialize, "example", IO::APPEND)
    io.closed_read?.should be_false
    io.closed_write?.should be_true

    io = StringIO.allocate
    io.send(:initialize, "example", IO::CREAT)
    io.closed_read?.should be_false
    io.closed_write?.should be_true

    io = StringIO.allocate
    io.send(:initialize, "example", IO::EXCL)
    io.closed_read?.should be_false
    io.closed_write?.should be_true
  end
end

describe "StringIO#initialize when passed [Object, Object]" do
  before(:each) do
    @io = StringIO.allocate
  end
  
  it "tries to convert the passed mode-Object to a String using #to_str" do
    obj = mock('to_str')
    obj.should_receive(:to_str).and_return("r")
    @io.send(:initialize, "example", obj)
    
    @io.closed_read?.should be_false
    @io.closed_write?.should be_true
  end

  ruby_version_is "" ... "1.8.7" do<commit_msg>Removed bogus specs. Thanks Vladimir!<commit_after>require File.dirname(__FILE__) + '/../../spec_helper'
require 'stringio'

describe "StringIO#initialize when passed [Object, Integer]" do
  it "sets the mode based on the passed Integer" do
    io = StringIO.allocate
    io.send(:initialize, "example", IO::RDONLY)
    io.closed_read?.should be_false
    io.closed_write?.should be_true

    io = StringIO.allocate
    io.send(:initialize, "example", IO::WRONLY)
    io.closed_read?.should be_true
    io.closed_write?.should be_false

    io = StringIO.allocate
    io.send(:initialize, "example", IO::RDWR)
    io.closed_read?.should be_false
    io.closed_write?.should be_false
  end
end

describe "StringIO#initialize when passed [Object, Object]" do
  before(:each) do
    @io = StringIO.allocate
  end
  
  it "tries to convert the passed mode-Object to a String using #to_str" do
    obj = mock('to_str')
    obj.should_receive(:to_str).and_return("r")
    @io.send(:initialize, "example", obj)
    
    @io.closed_read?.should be_false
    @io.closed_write?.should be_true
  end

  ruby_version_is "" ... "1.8.7" do
{'fraction_non_alphanumeric': 0.1229846269216348, 'fraction_numerical': 0.0022497187851518562, 'mean_word_length': 3.6239168110918545, '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': '4027243', 'n_tokens_mistral': 901, 'n_tokens_neox': 866, 'n_words': 210}