<commit_before>describe Product do
  let(:product) { FactoryGirl.build(:product) }

  before do
    Utusemi.configure do
      map :sample do |options|
        name :title
        caption options[:caption] || :none
      end
    end
  end

  it { should respond_to(:utusemi) }

  # TODO: Implement the new syntax
  #
  #   map(:product) { ... }
  #   Product.utusemi.first
  #
  describe '#utusemi(type)' do
    subject { product.utusemi(:sample) }
    it { should respond_to(:title) }
    it { should respond_to(:name) }
  end

  describe '#utusemi(type, options)' do
    subject { product.utusemi(:sample, caption: :title) }
    it { expect(subject.caption).to eq(subject.title) }
  end

  describe '::utusemi(type)' do
    before { FactoryGirl.create(:product, title: 'foobar') }
    subject { described_class.utusemi(:sample) }

    it '::where by alias column' do
      expect(subject.where(name: 'foobar').count).to eq(1)
    end

    it '::order by alias column' do<commit_msg>Add tests for ActiveRecord::Base::where method<commit_after>describe Product do
  let(:product) { FactoryGirl.build(:product) }

  before do
    Utusemi.configure do
      map :sample do |options|
        name :title
        caption options[:caption] || :none
      end
    end
  end

  it { should respond_to(:utusemi) }

  # TODO: Implement the new syntax
  #
  #   map(:product) { ... }
  #   Product.utusemi.first
  #
  describe '#utusemi(type)' do
    subject { product.utusemi(:sample) }
    it { should respond_to(:title) }
    it { should respond_to(:name) }
  end

  describe '#utusemi(type, options)' do
    subject { product.utusemi(:sample, caption: :title) }
    it { expect(subject.caption).to eq(subject.title) }
  end

  describe '::utusemi(type)' do
    before { FactoryGirl.create(:product, title: 'foobar') }
    subject { described_class.utusemi(:sample) }

    it '::where by alias column in Hash and String' do
      expect(subject.where(name: 'foobar').count).to eq(1)
    end

    it '::where by alias column in Hash and Array' do
      FactoryGirl.create(:product, title: 'hoge')
      expect(subject.where(name: %w(foobar hoge)).count).to eq(2)
    end

    it '::where by alias column in String' do
      expect(subject.where('name LIKE ?', 'foo%').count).to eq(1)
    end

    it '::order by alias column' do
{'fraction_non_alphanumeric': 0.13405172413793104, 'fraction_numerical': 0.0017241379310344827, 'mean_word_length': 3.0576923076923075, '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': '1654821', 'n_tokens_mistral': 776, 'n_tokens_neox': 744, 'n_words': 198}