<commit_before>require "spec_helper"

describe Flip::DeclarationStrategy do

  def definition(default)
    Flip::Definition.new :feature, default: default
  end

  describe "#knows?" do
    specify "definition without default should be false" do
      subject.knows?(Flip::Definition.new :feature).should be_false
    end
    specify " should be true" do
      subject.knows?(definition(true)).should be_true
    end
  end

  describe "#on? for Flip::Definition with default of" do
    specify "true" do
      subject.on?(definition(true)).should be_true
    end
    specify "false" do
      subject.on?(definition(false)).should be_false
    end
    specify "proc returning true" do
      subject.on?(definition(proc { true })).should be_true
    end
    specify "proc returning false" do
      subject.on?(definition(proc { false })).should be_false
    end
  end

end<commit_msg>Better example wording in declaration_strategy_spec.<commit_after>require "spec_helper"

describe Flip::DeclarationStrategy do

  def definition(default)
    Flip::Definition.new :feature, default: default
  end

  describe "#knows?" do
    it "does not know definition with no default specified" do
      subject.knows?(Flip::Definition.new :feature).should be_false
    end
    it "knows definition with default set to true" do
      subject.knows?(definition(true)).should be_true
    end
  end

  describe "#on? for Flip::Definition" do
    subject { Flip::DeclarationStrategy.new.on? definition(default) }
    [
      { default: true, result: true },
      { default: false, result: false },
      { default: proc { true }, result: true, name: "proc returning true" },
      { default: proc { false }, result: false, name: "proc returning false" },
    ].each do |parameters|
      context "with default of #{parameters[:name] || parameters[:default]}" do
        let(:default) { parameters[:default] }
        it { should == parameters[:result] }
      end
    end
  end

end
{'fraction_non_alphanumeric': 0.10646968925114621, 'fraction_numerical': 0.0, 'mean_word_length': 3.403587443946188, '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': '5304419', 'n_tokens_mistral': 556, 'n_tokens_neox': 559, 'n_words': 176}