<commit_before>module CDQ
  describe "CDQ Managed Object" do

    before do
      CDQ.cdq.setup

      class << self
        include CDQ
      end
    end

    after do
      CDQ.cdq.reset!
    end

    it "provides a cdq class method" do
      Writer.cdq.class.should == CDQTargetedQuery
    end

    it "has a where method" do
      Writer.where(:name).eq('eecummings').class.should == CDQTargetedQuery
    end

    it "has a sort_by method" do
      Writer.sort_by(:name).class.should == CDQTargetedQuery
    end

    it "has a first method" do
      eec = cdq(Writer).create(name: 'eecummings')
      Writer.first.should == eec
    end

    it "has an all method" do
      eec = cdq(Writer).create(name: 'eecummings')
      Writer.all.array.should == [eec]
    end

    it "can destroy itself" do
      eec = cdq(Writer).create(name: 'eecummings')
      eec.destroy
      Writer.all.array.should == []
    end

    it "returns the attributes of the entity" do
      Writer.attribute_names.should.include(:name)
    end

    it "allows boolean access via ? methods" do
      first = Article.create(published: true, title: "First Article")
      second = Article.create(published: false, title: "Second Article")

      first.published.should == 1
      first.published?.should == true

      second.published.should == 0
      second.published?.should == false
    end

    it "allows multiple property updates with `update()`" do
      article = Article.create(published: true, title: "First Article")
      article.published?.should == true
      article.title.should == "First Article"
      article_object_id = article.object_id

      article.update(published: false, title: "First Article Fixed")
      article.published?.should == false
      article.title.should == "First Article Fixed"
      article.object_id.should == article_object_id
    end

    it "raises an error when trying to update a property that doesn't exist with `update()`" do
      article = Article.create(published: true, title: "First Article")<commit_msg>Adds another update sec for updting a singe attribute<commit_after>module CDQ
  describe "CDQ Managed Object" do

    before do
      CDQ.cdq.setup

      class << self
        include CDQ
      end
    end

    after do
      CDQ.cdq.reset!
    end

    it "provides a cdq class method" do
      Writer.cdq.class.should == CDQTargetedQuery
    end

    it "has a where method" do
      Writer.where(:name).eq('eecummings').class.should == CDQTargetedQuery
    end

    it "has a sort_by method" do
      Writer.sort_by(:name).class.should == CDQTargetedQuery
    end

    it "has a first method" do
      eec = cdq(Writer).create(name: 'eecummings')
      Writer.first.should == eec
    end

    it "has an all method" do
      eec = cdq(Writer).create(name: 'eecummings')
      Writer.all.array.should == [eec]
    end

    it "can destroy itself" do
      eec = cdq(Writer).create(name: 'eecummings')
      eec.destroy
      Writer.all.array.should == []
    end

    it "returns the attributes of the entity" do
      Writer.attribute_names.should.include(:name)
    end

    it "allows boolean access via ? methods" do
      first = Article.create(published: true, title: "First Article")
      second = Article.create(published: false, title: "Second Article")

      first.published.should == 1
      first.published?.should == true

      second.published.should == 0
      second.published?.should == false
    end

    it "allows single property updates with `update()`" do
      article = Article.create(published: true, title: "First Article")
      article.published?.should == true
      article.title.should == "First Article"
      article_object_id = article.object_id

      article.update(title: "First Article Fixed")
      article.published?.should == true
      article.title.should == "First Article Fixed"
      article.object_id.should == article_object_id
    end

    it "allows multiple property updates with `update()`" do
      article = Article.create(published: true, title: "First Article")
      article.published?.should == true
      article.title.should == "First Article"
      article_object_id = article.object_id

      article.update(published: false, title: "First Article Fixed")
      article.published?.should == false
      article.title.should == "First Article Fixed"
      article.object_id.should == article_object_id
    end

    it "raises an error when trying to update a property that doesn't exist with `update()`" do
      article = Article.create(published: true, title: "First Article")
{'fraction_non_alphanumeric': 0.10231239092495636, 'fraction_numerical': 0.0008726003490401396, 'mean_word_length': 2.7246141348497157, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5914500', 'n_tokens_mistral': 1370, 'n_tokens_neox': 1312, 'n_words': 399}