Sha256: d2c778a3ed6f81de8a035fbb5580c519a4ba67f33d7981a5646cc0148ecd6184

Contents?: true

Size: 1.82 KB

Versions: 6

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'

describe ActiveAdmin::Views::Columns do
  include Arbre::HTML
  let(:assigns){ {} }

  describe "Rendering one column" do
    let(:cols) do
      columns do
        column { span "Hello World" }
      end
    end

    it "should have the class .columns" do
      cols.class_list.should include("columns")
    end

    it "should have one column" do
      cols.children.size.should == 1
      cols.children.first.class_list.should include("column")
    end

    it "should have one column with the width 100%" do
      cols.children.first.attr(:style).should include("width: 100%")
    end
  end

  describe "Rendering two columns" do
    let(:cols) do
      columns do
        column { span "Hello World" }
        column { span "Hello World" }
      end
    end

    it "should have two columns" do
      cols.children.size.should == 2
    end

    it "should have a first column with width 49% and margin 2%" do
      cols.children.first.attr(:style).should == "width: 49%; margin-right: 2%;"
    end

    it "should have a second column with width 49% and no right margin" do
      cols.children.last.attr(:style).should == "width: 49%;"
    end
  end

  describe "Rendering four columns" do
    let(:cols) do
      columns do
        column { span "Hello World" }
        column { span "Hello World" }
        column { span "Hello World" }
        column { span "Hello World" }
      end
    end

    it "should have four columns" do
      cols.children.size.should == 4
    end


    (0..2).to_a.each do |index|
      it "should have column #{index + 1} with width 49% and margin 2%" do
        cols.children[index].attr(:style).should == "width: 23.5%; margin-right: 2%;"
      end
    end

    it "should have column 4 with width 49% and no margin" do
      cols.children[3].attr(:style).should == "width: 23.5%;"
    end
  end

end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
nsm-activeadmin-0.2.2 spec/unit/views/components/columns_spec.rb
saulolso-activeadmin-0.2.2.1 spec/unit/components/columns_spec.rb
saulolso-activeadmin-0.2.2 spec/unit/components/columns_spec.rb
activeadmin-0.2.2 spec/unit/components/columns_spec.rb
activeadmin-0.2.1 spec/unit/components/columns_spec.rb
activeadmin-0.2.0 spec/unit/components/columns_spec.rb