<commit_before>require 'tango'

module Tango
  describe Step do

    context "with just a plain block" do
      it "should run the block" do
        block_calls = 0
        step = Step.new do
          block_calls += 1
        end

        step.run
        block_calls.should == 1
      end
    end

    context "with a meet block and a met block" do
      it "should check the met?, run the meet, then check the met? again" do
        met_block_calls  = 0
        meet_block_calls = 0
        step = Step.new do
          met? do
            met_block_calls += 1
            meet_block_calls > 0
          end
          meet { meet_block_calls += 1 }
        end

        step.run
        met_block_calls.should  == 2
        meet_block_calls.should == 1
      end

      it "should not run the meet if the met? succeeds the first time" do
        met_block_calls  = 0
        meet_block_calls = 0
        step = Step.new do
          met? do
            met_block_calls += 1
            true
          end
          meet { meet_block_calls += 1 }
        end

        step.run
        met_block_calls.should  == 1
        meet_block_calls.should == 0
      end

      it "should raise if the met? block fails twice" do
        met_block_calls  = 0
        meet_block_calls = 0
        step = Step.new do
          met? do
            met_block_calls += 1
            false
          end
          meet { meet_block_calls += 1 }
        end

        expect { step.run }.should raise_error(CouldNotMeetError)
        met_block_calls.should  == 2
        meet_block_calls.should == 1
      end

      it "should raise an error if there's a meet block without a met block" do
        step = Step.new do
          meet { }
        end

        expect { step.run }.should raise_error(MeetWithoutMetError)
      end
    end

    context "step arguments" do
      it "should pass a single argument to the step" do
        step = Step.new do |a|
          a.should == 1
        end

        step.run(1)
      end

      it "should pass multiple arguments to the step" do
        step = Step.new do |a, b|
          a.should == 1
          b.should == 2
        end

        step.run(1, 2)
      end
    end

  end
end
<commit_msg>Spec to ensure met?/meet blocks can get at step arguments.<commit_after>require 'tango'

module Tango
  describe Step do

    context "with just a plain block" do
      it "should run the block" do
        block_calls = 0
        step = Step.new do
          block_calls += 1
        end

        step.run
        block_calls.should == 1
      end
    end

    context "with a meet block and a met block" do
      it "should check the met?, run the meet, then check the met? again" do
        met_block_calls  = 0
        meet_block_calls = 0
        step = Step.new do
          met? do
            met_block_calls += 1
            meet_block_calls > 0
          end
          meet { meet_block_calls += 1 }
        end

        step.run
        met_block_calls.should  == 2
        meet_block_calls.should == 1
      end

      it "should not run the meet if the met? succeeds the first time" do
        met_block_calls  = 0
        meet_block_calls = 0
        step = Step.new do
          met? do
            met_block_calls += 1
            true
          end
          meet { meet_block_calls += 1 }
        end

        step.run
        met_block_calls.should  == 1
        meet_block_calls.should == 0
      end

      it "should raise if the met? block fails twice" do
        met_block_calls  = 0
        meet_block_calls = 0
        step = Step.new do
          met? do
            met_block_calls += 1
            false
          end
          meet { meet_block_calls += 1 }
        end

        expect { step.run }.should raise_error(CouldNotMeetError)
        met_block_calls.should  == 2
        meet_block_calls.should == 1
      end

      it "should raise an error if there's a meet block without a met block" do
        step = Step.new do
          meet { }
        end

        expect { step.run }.should raise_error(MeetWithoutMetError)
      end
    end

    context "step arguments" do
      it "should pass a single argument to the step" do
        step = Step.new do |a|
          a.should == 1
        end

        step.run(1)
      end

      it "should pass multiple arguments to the step" do
        step = Step.new do |a, b|
          a.should == 1
          b.should == 2
        end

        step.run(1, 2)
      end

      it "should capture arguments in the met? and meet blocks" do
        step = Step.new do |argument|
          met? do
            argument.should == 1
            false
          end
          meet { argument.should == 1 }
        end

        expect { step.run(1) }.should raise_error(CouldNotMeetError)
      end
    end

  end
end

{'fraction_non_alphanumeric': 0.06213632585203657, 'fraction_numerical': 0.012261014131338321, 'mean_word_length': 1.419808949220714, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5241208', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1413, 'n_words': 495}