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

class Hotel < ActiveCouch::Base
  has :name, :which_is => :text, :with_default_value => "<NAME>"
  has :star_rating, :which_is => :decimal, :with_default_value => 5.0
  has :rooms, :which_is => :number, :with_default_value => 100
end

class Hospital < ActiveCouch::Base
  has :name
end

class CrazyPerson < ActiveCouch::Base
  has :name, :which_is => :text, :with_default_value => "<NAME>"
  has_many :hospitals
end

describe "An object instantiated from a subclass of ActiveCouch::Base with many attributes" do
  before(:each) do
    @h = Hotel.new
  end

  it "should have to the to_json method" do
    @h.methods.index('to_json').should_not == nil
  end

  it "should produce valid JSON output when sent the to_json method" do
    @h.to_json.should == "{\"name\":\"<NAME>\",\"rooms\":100,\"star_rating\":5.0}"
  end
  
  it "should produce valid JSON output when an attribute has been changed and the to_json method is sent" do
    @h.rooms = 200
    @h.to_json.should == "{\"name\":\"<NAME>\",\"rooms\":200,\"star_rating\":5.0}"
  end
end

describe "An object instantiated from a subclass of ActiveCouch::Base with a has_many association" do
  before(:each) do
    @c = CrazyPerson.new
    @h1 = Hospital.new
    @h1.name = "Crazy Hospital 1"
    
    @h2 = Hospital.new
    @h2.name = "Crazy Hospital 2"
    
    @c.add_hospital(@h1)
    @c.add_hospital(@h2)
  end
  
  it "should produce valid JSON when sent the to_json method" do
    @c.to_json.should == "{\"name\":\"<NAME>\",\"hospitals\":[\"{\\\"name\\\":\\\"Crazy Hospital 1\\\"}\",\"{\\\"name\\\":\\\"Crazy Hospital 2\\\"}\"]}"
  end
end<commit_msg>Cleaned up json spec<commit_after>require File.dirname(__FILE__) + '/spec_helper.rb'

class Hotel < ActiveCouch::Base
  has :name, :which_is => :text, :with_default_value => "<NAME>"
  has :star_rating, :which_is => :decimal, :with_default_value => 5.0
  has :rooms, :which_is => :number, :with_default_value => 100
end

class Hospital < ActiveCouch::Base
  has :name
end

class CrazyPerson < ActiveCouch::Base
  has :name, :which_is => :text, :with_default_value => "<NAME>"
  has_many :hospitals
end

describe "An object instantiated from a subclass of ActiveCouch::Base with many attributes" do
  before(:each) do
    @h = Hotel.new
  end

  it "should have to the to_json method" do
    @h.methods.index('to_json').should_not == nil
  end

  it "should produce valid JSON output when sent the to_json method" do
    @h.to_json.should == "{\"name\":\"<NAME>\",\"rooms\":100,\"star_rating\":5.0}"
  end
  
  it "should produce valid JSON output when an attribute has been changed and the to_json method is sent" do
    @h.rooms = 200
    @h.to_json.should == "{\"name\":\"<NAME>\",\"rooms\":200,\"star_rating\":5.0}"
  end
end

describe "An object instantiated from a subclass of ActiveCouch::Base with a has_many association" do
  before(:each) do
    @c = CrazyPerson.new
    
    @h1 = Hospital.new(:name => "Crazy Hospital 1")
    @h2 = Hospital.new(:name => "Crazy Hospital 2")
    
    @c.add_hospital(@h1)
    @c.add_hospital(@h2)
  end
  
  it "should produce valid JSON when sent the to_json method" do
    @c.to_json.should == "{\"name\":\"<NAME>\",\"hospitals\":[\"{\\\"name\\\":\\\"Crazy Hospital 1\\\"}\",\"{\\\"name\\\":\\\"Crazy Hospital 2\\\"}\"]}"
  end
end
{'fraction_non_alphanumeric': 0.1675111773472429, 'fraction_numerical': 0.01609538002980626, 'mean_word_length': 3.5722070844686646, 'pattern_counts': {'":': 20, '<': 19, '<?xml version=': 0, '>': 31, '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': '5748592', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1160, 'n_words': 328}