<commit_before>require 'rails_helper'

RSpec.shared_examples "an invalid ActiveRecord" do
  context "once saved" do
    it "is not #valid?" do
      expect(card).to_not be_valid
    end

    it "has errors" do
      expect { card.valid? }
        .to change { card.errors.size }
        .from(0)
    end
  end
end

RSpec.describe Card, type: :model do
  let(:suit) { "hearts" }
  let(:rank) { "queen" }

  context "when initializing" do
    let(:card) { Card.new(rank: rank, suit: suit) }

    context "with correct suit and rank" do
      it "is #valid?" do
        expect(card).to be_valid
      end

      it "can save" do
        card.save!
      end
    end

    context "without parameters" do
      let(:card) { Card.new }
      it_behaves_like "an invalid ActiveRecord"
    end

    context "missing suit" do
      let(:suit) { nil }
      it_behaves_like "an invalid ActiveRecord"
    end

    context "missing rank" do
      let(:rank) { nil }
      it_behaves_like "an invalid ActiveRecord"
    end

    context "with invalid suit" do
      let(:suit) { "dude bro party massacre 3" }
      it_behaves_like "an invalid ActiveRecord"
    end

    context "with invalid rank" do
      let(:rank) { "kung fury" }
      it_behaves_like "an invalid ActiveRecord"
    end
  end
end<commit_msg>Refactor: Rename shared examples s/ActiveRecord/Card<commit_after>require 'rails_helper'

RSpec.shared_examples "an invalid Card" do
  context "once saved" do
    it "is not #valid?" do
      expect(card).to_not be_valid
    end

    it "has errors" do
      expect { card.valid? }
        .to change { card.errors.size }
        .from(0)
    end
  end
end

RSpec.describe Card, type: :model do
  let(:suit) { "hearts" }
  let(:rank) { "queen" }

  context "when initializing" do
    let(:card) { Card.new(rank: rank, suit: suit) }

    context "with correct suit and rank" do
      it "is #valid?" do
        expect(card).to be_valid
      end

      it "can save" do
        card.save!
      end
    end

    context "without parameters" do
      let(:card) { Card.new }
      it_behaves_like "an invalid Card"
    end

    context "missing suit" do
      let(:suit) { nil }
      it_behaves_like "an invalid Card"
    end

    context "missing rank" do
      let(:rank) { nil }
      it_behaves_like "an invalid Card"
    end

    context "with invalid suit" do
      let(:suit) { "dude bro party massacre 3" }
      it_behaves_like "an invalid Card"
    end

    context "with invalid rank" do
      let(:rank) { "kung fury" }
      it_behaves_like "an invalid Card"
    end
  end
end
{'fraction_non_alphanumeric': 0.09787234042553192, 'fraction_numerical': 0.0015473887814313346, 'mean_word_length': 2.328185328185328, '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': '4299357', 'n_tokens_mistral': 877, 'n_tokens_neox': 836, 'n_words': 273}