<commit_before>require 'spec_helper'
require "active_support/core_ext/hash"
require "active_support/core_ext/object"

require 'datagrid/renderer'

describe Datagrid::Helper do
  subject do
    template = ActionView::Base.new
    template.view_paths << File.expand_path("../../../app/views", __FILE__)
    template.view_paths << File.expand_path("../../support/test_partials", __FILE__)
    template
  end

  before(:each) do
    subject.stub!(:params).and_return({})
    subject.stub(:url_for) do |options|
      options.to_param
    end

  end

  let(:group) { Group.create!(:name => "Pop") }
  let!(:entry) {  Entry.create!(
    :group => group, :name => "Star", :disabled => false, :confirmed => false, :category => "first"
  ) }
  let(:grid) { SimpleReport.new }

  describe ".datagrid_table" do
    it "should have grid class as html class on table" do
      subject.datagrid_table(grid).should match_css_pattern(
        "table.datagrid.simple_report" => 1
      )
    end
    it "should return data table html" do
      datagrid_table = subject.datagrid_table(grid)
<commit_msg>Added a spec for a grid with no results.<commit_after>require 'spec_helper'
require "active_support/core_ext/hash"
require "active_support/core_ext/object"

require 'datagrid/renderer'

describe Datagrid::Helper do
  subject do
    template = ActionView::Base.new
    template.view_paths << File.expand_path("../../../app/views", __FILE__)
    template.view_paths << File.expand_path("../../support/test_partials", __FILE__)
    template
  end

  before(:each) do
    subject.stub!(:params).and_return({})
    subject.stub(:url_for) do |options|
      options.to_param
    end

  end

  let(:group) { Group.create!(:name => "Pop") }
  let!(:entry) {  Entry.create!(
    :group => group, :name => "Star", :disabled => false, :confirmed => false, :category => "first"
  ) }
  let(:grid) { SimpleReport.new }

  context "when grid has no records" do
    let(:grid) do
      test_report do
        scope { Entry.where("1 != 1") }
      end
    end

    it "should show an empty table with dashes" do
      datagrid_table = subject.datagrid_table(grid)

      datagrid_table.should match_css_pattern(
        "table.datagrid tr td.noresults" => 1
      )
    end
  end

  describe ".datagrid_table" do
    it "should have grid class as html class on table" do
      subject.datagrid_table(grid).should match_css_pattern(
        "table.datagrid.simple_report" => 1
      )
    end
    it "should return data table html" do
      datagrid_table = subject.datagrid_table(grid)

{'fraction_non_alphanumeric': 0.13150684931506848, 'fraction_numerical': 0.0019569471624266144, 'mean_word_length': 3.2671118530884806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 18, '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': '3489444', 'n_tokens_mistral': 837, 'n_tokens_neox': 824, 'n_words': 197}