Sha256: d620c4f712f6fcca91672028d4fa029fb18e102fe29cf657e7ac7030aaaeed70

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 KB

Contents

require 'spec_helper'

module Ransack
  module Nodes
    describe Grouping do

      before do
        @g = 1
      end

      let(:context) { Context.for(Person) }

      subject { described_class.new(context) }

      describe '#attribute_method?' do
        context 'for attributes of the context' do
          it 'is true' do
            expect(subject.attribute_method?('name')).to be_true
          end

          context "when the attribute contains '_and_'" do
            it 'is true' do
              expect(subject.attribute_method?('terms_and_conditions')).to be_true
            end
          end

          context "when the attribute contains '_or_'" do
            it 'is true' do
              expect(subject.attribute_method?('true_or_false')).to be_true
            end
          end

          context "when the attribute ends with '_start'" do
            it 'is true' do
              expect(subject.attribute_method?('life_start')).to be_true
            end
          end

          context "when the attribute ends with '_end'" do
            it 'is true' do
              expect(subject.attribute_method?('stop_end')).to be_true
            end
          end
        end

        context 'for unknown attributes' do
          it 'is false' do
            expect(subject.attribute_method?('not_an_attribute')).to be_false
          end
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
solidus_backend-1.0.0.pre3 vendor/bundle/gems/ransack-1.6.6/spec/ransack/nodes/grouping_spec.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/ransack-1.6.6/spec/ransack/nodes/grouping_spec.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/ransack-1.6.6/spec/ransack/nodes/grouping_spec.rb
ransack-1.6.6 spec/ransack/nodes/grouping_spec.rb
ransack-1.6.5 spec/ransack/nodes/grouping_spec.rb
ransack-1.6.4 spec/ransack/nodes/grouping_spec.rb