Sha256: 460f31a440b6eac61c6c5f3b560b846a9b2f8b5cca4224febbfd83bf4030992b

Contents?: true

Size: 1.7 KB

Versions: 20

Compression:

Stored size: 1.7 KB

Contents

require "datagrid"

#TODO: refactor this experimental shit
shared_examples_for "Datagrid" do
  describe "as Datagrid" do

    it "should have at least one entry if assets" do
      subject.assets.should_not be_empty
    end

    described_class.columns(:data => true).each do |column|
      describe "column ##{column.name}" do

        it "should has value in #data_hash" do
          subject.data_hash.first.should have_key(column.name)
        end

        it "should support order" do
          subject.order = column.name
          subject.assets.first.should_not be_nil
        end

        it "should support descending order" do
          subject.descending = true
          subject.assets.first.should_not be_nil
        end
      end

    end

    described_class.filters.each do |filter|
      describe "filter ##{filter.name}" do

        let(:filter_value) do
          
          case Datagrid::Filters::FILTER_TYPES.invert[filter.class]
          when :default, :string
            "text"
          when :date
            1.day.ago
          when :xboolean, :eboolean
            Datagrid::Filters::BooleanEnumFilter::YES
          when :boolean
            true
          when :integer
            1
          when :enum
            select = subject.select_options(filter)
            select.first.try(:last)
          else
            raise "unknown filter type: #{filter.class}"
          end.to_s
        end

        before(:each) do
          subject.attributes = {filter.name => filter_value}
          subject.send(filter.name).should_not be_nil
        end

        it "should be supported" do
          subject.assets.should_not be_nil 
          #TODO: better matcher.
        end
      end
    end

  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
datagrid-1.7.0 lib/datagrid/rspec.rb
datagrid-1.6.3 lib/datagrid/rspec.rb
datagrid-1.6.2 lib/datagrid/rspec.rb
datagrid-1.6.1 lib/datagrid/rspec.rb
datagrid-1.6.0 lib/datagrid/rspec.rb
datagrid-1.5.9 lib/datagrid/rspec.rb
datagrid-1.5.8 lib/datagrid/rspec.rb
datagrid-1.5.7 lib/datagrid/rspec.rb
datagrid-1.5.6 lib/datagrid/rspec.rb
datagrid-1.5.5 lib/datagrid/rspec.rb
datagrid-1.5.4 lib/datagrid/rspec.rb
datagrid-1.5.3 lib/datagrid/rspec.rb
datagrid-1.5.2 lib/datagrid/rspec.rb
datagrid-1.5.1 lib/datagrid/rspec.rb
datagrid-1.5.0 lib/datagrid/rspec.rb
datagrid-1.4.4 lib/datagrid/rspec.rb
datagrid-1.4.3 lib/datagrid/rspec.rb
datagrid-1.4.2 lib/datagrid/rspec.rb
datagrid-1.4.1 lib/datagrid/rspec.rb
datagrid-1.4.0 lib/datagrid/rspec.rb