<commit_before>require File.expand_path("../../../spec_helper", __FILE__)

describe CouchRest do

  before(:each) do
    @cr = CouchRest.new(COUCHHOST)
    begin
      @db = @cr.database(TESTDB)
      @db.delete! rescue nil      
    end
  end

  after(:each) do
    begin
      @db.delete! rescue nil
    end
  end

  describe "getting info" do
    it "should list databases" do
      @cr.databases.should be_an_instance_of(Array)
    end
    it "should get info" do
      @cr.info["couchdb"].should == "Welcome"
      @cr.info.class.should == Hash   
    end
  end
  
  it "should restart" do
    # Don't bother actually restarting as it causes problems in CouchDB 1.0
    @cr.respond_to?('restart!').should be_true  # @cr.restart! ## 
  end

  it "should provide one-time access to uuids" do
    @cr.next_uuid.should_not be_nil
  end

  describe "initializing a database" do
    it "should return a db" do
      db = @cr.database(TESTDB)
      db.should be_an_instance_of(CouchRest::Database)
      db.host.should == @cr.uri<commit_msg>Improving restart test<commit_after>require File.expand_path("../../../spec_helper", __FILE__)

describe CouchRest do

  before(:each) do
    @cr = CouchRest.new(COUCHHOST)
    begin
      @db = @cr.database(TESTDB)
      @db.delete! rescue nil      
    end
  end

  after(:each) do
    begin
      @db.delete! rescue nil
    end
  end

  describe "getting info" do
    it "should list databases" do
      @cr.databases.should be_an_instance_of(Array)
    end
    it "should get info" do
      @cr.info["couchdb"].should == "Welcome"
      @cr.info.class.should == Hash   
    end
  end
  
  it "should restart" do
    @cr.restart!
    begin
      @cr.info
    rescue
      # Give the couchdb time to restart
      sleep 0.2
      retry
    end
  end

  it "should provide one-time access to uuids" do
    @cr.next_uuid.should_not be_nil
  end

  describe "initializing a database" do
    it "should return a db" do
      db = @cr.database(TESTDB)
      db.should be_an_instance_of(CouchRest::Database)
      db.host.should == @cr.uri
{'fraction_non_alphanumeric': 0.1055930568948891, 'fraction_numerical': 0.0019286403085824494, 'mean_word_length': 2.4583333333333335, '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': '5379783', 'n_tokens_mistral': 724, 'n_tokens_neox': 702, 'n_words': 193}