Sha256: 879233535aa59e6cd601416d6647ae00358e92d9bdd7069413f24391d64f468c

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require "spec_helper"
require "hirber"

RSpec.describe "activerecord table" do
  before do
    Hirb.enable
  end

  after do
    Hirb.disable
  end

  context "with no select" do
    let(:pet) do
      double(
        name: "rufus",
        age: 7,
        attributes: { "name" => "rufus", "age" => 7 },
        class: double(column_names: %w{age name}),
      )
    end

    it "gets default options" do
      expect(Hirb::Helpers::AutoTable.active_record__base_view(pet))
        .to eq(fields: [:age, :name])
    end
  end

  context "with select" do
    let(:pet) do
      double(
        name: "rufus",
        age: 7,
        attributes: { "name" => "rufus" },
        class: double(column_names: %w{age name}),
      )
    end

    it "gets default options" do
      expect(Hirb::Helpers::AutoTable.active_record__base_view(pet))
        .to eq(fields: [:name])
    end
  end
end

RSpec.describe "mongoid table" do
  let(:mongoid_stub) { double(class: double(fields: fields)) }
  let(:fields) { {"_id" => "x0f0x", "name" => "blah"} }

  it "only has one _id" do
    expect(Hirb::Helpers::AutoTable.mongoid__document_view(mongoid_stub))
      .to eq(fields: fields.keys.sort)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hirber-0.8.7 spec/views_spec.rb
hirber-0.8.6 spec/views_spec.rb
hirber-0.8.5 spec/views_spec.rb
hirber-0.8.4 spec/views_spec.rb