<commit_before>require 'spec_helper'

describe WhippedCream::Runner do
  subject(:runner) { described_class.new(plugin) }

  let(:plugin) {
    WhippedCream::Plugin.build do
      name "Garage"
    end
  }

  describe '#name' do
    subject { super().name }
    it { is_expected.to eq("Garage") }
  end

  describe '.instance' do
    subject { described_class.instance }
    it { is_expected.to be_an_instance_of(WhippedCream::Runner) }
  end

  context "with a button" do
    let(:plugin) {
      WhippedCream::Plugin.build do
        button "Open/Close", pin: 4
      end
    }

    it "sets up that pin with direction: :out" do
      pin = runner.pins[:open_close]

      expect(pin).to be_a(PiPiper::Pin)
      expect(pin.pin).to eq(4)
      expect(pin.direction).to eq(:out)
    end

    it "defines an open_close method that taps the pin" do<commit_msg>Fixes Runner.instance test to create an instance of the class before testing for its existance<commit_after>require 'spec_helper'

describe WhippedCream::Runner do
  subject(:runner) { described_class.new(plugin) }

  let(:plugin) {
    WhippedCream::Plugin.build do
      name "Garage"
    end
  }

  describe '#name' do
    subject { super().name }
    it { is_expected.to eq("Garage") }
  end

  describe '.instance' do
    subject { described_class.instance }
    let!(:runner_instance) { described_class.create_instance(plugin) }

    it { is_expected.to eq(runner_instance) }
  end

  context "with a button" do
    let(:plugin) {
      WhippedCream::Plugin.build do
        button "Open/Close", pin: 4
      end
    }

    it "sets up that pin with direction: :out" do
      pin = runner.pins[:open_close]

      expect(pin).to be_a(PiPiper::Pin)
      expect(pin.pin).to eq(4)
      expect(pin.direction).to eq(:out)
    end

    it "defines an open_close method that taps the pin" do
{'fraction_non_alphanumeric': 0.11129119394921665, 'fraction_numerical': 0.0021609940572663426, 'mean_word_length': 2.9913793103448274, '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': '5884449', 'n_tokens_mistral': 626, 'n_tokens_neox': 597, 'n_words': 159}