<commit_before>require 'i18nliner/extensions/inferpolation'
require 'ostruct'

describe I18nliner::Extensions::Inferpolation do
  
  let(:foo) do
    foo = OpenStruct.new(:bar => OpenStruct.new(:baz => "lol"))
    foo.instance_variable_set(:@bar, foo.bar)
    foo.extend I18nliner::Extensions::Inferpolation
    foo
  end

  it "should inferpolate valid instance method chains" do
    options = {:default => "hello %{bar.baz}"}
    foo.inferpolate(options).should == {
      :default => "hello %{bar_baz}",
      :bar_baz => foo.bar.baz
    }
  end

  it "should inferpolate valid instance variable chains" do
    options = {:default => "hello %{@bar.baz}"}
    foo.inferpolate(options).should == {
      :default => "hello %{bar_baz}",
      :bar_baz => foo.bar.baz
    }
  end

  it "should not inferpolate invalid instance method chains" do
    options = {:default => "hello %{lol} %{bar.baz.lol}"}
    foo.inferpolate(options).should == options
  end

  it "should not inferpolate invalid instance variable chains" do
    options = {:default => "hello %{@lol} %{@bar.baz.lol}"}
    foo.inferpolate(options).should == options
  end
end<commit_msg>slightly better spec for interpolation value inference<commit_after>require 'i18nliner/extensions/inferpolation'
require 'ostruct'

describe I18nliner::Extensions::Inferpolation do

  let(:foo) do
    foo = OpenStruct.new(:bar => OpenStruct.new(:baz => "lol"), :bar2 => "foo")
    foo.instance_variable_set(:@bar, foo.bar)
    foo.instance_variable_set(:@bar2, "foo")
    foo.extend I18nliner::Extensions::Inferpolation
    foo
  end

  it "should inferpolate valid instance methods and chains" do
    options = {:default => "hello %{bar.baz} %{bar2}"}
    foo.inferpolate(options).should == {
      :default => "hello %{bar_baz} %{bar2}",
      :bar_baz => foo.bar.baz,
      :bar2 => foo.bar2
    }
  end

  it "should inferpolate valid instance variables and chains" do
    options = {:default => "hello %{@bar.baz} %{@bar2}"}
    foo.inferpolate(options).should == {
      :default => "hello %{bar_baz} %{bar2}",
      :bar_baz => foo.bar.baz,
      :bar2 => foo.bar2
    }
  end

  it "should not inferpolate invalid instance methods and chains" do
    options = {:default => "hello %{lol} %{bar.baz.lol}"}
    foo.inferpolate(options).should == options
  end

  it "should not inferpolate invalid instance variables and chains" do
    options = {:default => "hello %{@lol} %{@bar.baz.lol}"}
    foo.inferpolate(options).should == options
  end
end
{'fraction_non_alphanumeric': 0.1474230922892529, 'fraction_numerical': 0.008789452656811825, 'mean_word_length': 3.6629422718808193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 26, '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': '2961934', 'n_tokens_mistral': 887, 'n_tokens_neox': 806, 'n_words': 205}