<commit_before>require "spec_helper"

describe Sro::Mock::ActiveRecordModel do
  subject { Sro::Mock::ActiveRecordModel.new }

  it "inherits from ActiveRecord::Base" do
    klass    = subject.class
    ancestors = klass.ancestors
    expect(ancestors).to include(ActiveRecord::Base)
  end

  context "#active_record_model" do
    it "returns an ActiveRecordModel object" do
      object = subject.active_record_model
      expect(object).to be_instance_of(Sro::Mock::ActiveRecordModel)
    end
  end

  context "#inject_getter" do
    it "adds method to the object" do
      subject.inject_getter("hello")
      subject.instance_variable_set("@hello", "world")
      hello  = subject.hello
      expect(hello).to eq("world")
    end
  end

  context "#inject_setter" do
    it "adds method to the object" do
      subject.inject_setter(:hello)
      subject.hello = "world"
      hello  = subject.instance_variable_get("@hello")
      expect(hello).to eq("world")
    end
  end

  context "#set_getter" do
    it "generates getter" do
      getter = subject.set_getter(:hello)
      expect(getter).to eq("def hello; @hello ; end;")
    end
  end

  context "#set_setter" do
    it "generates setter" do
      getter = subject.set_setter(:hello)
      expect(getter).to eq("def hello=(value); @hello=value; end;")
    end
  end<commit_msg>(red) Write failing test => Sro::Mock::ActiveRecordModel#set_value<commit_after>require "spec_helper"

describe Sro::Mock::ActiveRecordModel do
  subject { Sro::Mock::ActiveRecordModel.new }

  it "inherits from ActiveRecord::Base" do
    klass    = subject.class
    ancestors = klass.ancestors
    expect(ancestors).to include(ActiveRecord::Base)
  end

  context "#active_record_model" do
    it "returns an ActiveRecordModel object" do
      object = subject.active_record_model
      expect(object).to be_instance_of(Sro::Mock::ActiveRecordModel)
    end
  end

  context "#inject_getter" do
    it "adds method to the object" do
      subject.inject_getter("hello")
      subject.instance_variable_set("@hello", "world")
      hello  = subject.hello
      expect(hello).to eq("world")
    end
  end

  context "#inject_setter" do
    it "adds method to the object" do
      subject.inject_setter(:hello)
      subject.hello = "world"
      hello  = subject.instance_variable_get("@hello")
      expect(hello).to eq("world")
    end
  end

  context "#set_getter" do
    it "generates getter" do
      getter = subject.set_getter(:hello)
      expect(getter).to eq("def hello; @hello ; end;")
    end
  end

  context "#set_setter" do
    it "generates setter" do
      getter = subject.set_setter(:hello)
      expect(getter).to eq("def hello=(value); @hello=value; end;")
    end
  end

  context "#set_value" do
    it "#set_value" do
      subject.set_value(:hello, "world")
      hello = subject.instance_variable_get("@hello")
      expect(hello).to eq("world")
    end
  end
{'fraction_non_alphanumeric': 0.1135042735042735, 'fraction_numerical': 0.0, 'mean_word_length': 3.386806596701649, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '4727602', 'n_tokens_mistral': 951, 'n_tokens_neox': 934, 'n_words': 225}