Sha256: 4cbc76071a41e2623011d8942c2c0e629ab982dd6315b90e40b9b2e2eab64dcc

Contents?: true

Size: 1.37 KB

Versions: 7

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

7 entries across 7 versions & 2 rubygems

Version Path
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/ransack-1.6.2/spec/ransack/nodes/grouping_spec.rb
ransack-1.6.3 spec/ransack/nodes/grouping_spec.rb
ransack-1.6.2 spec/ransack/nodes/grouping_spec.rb
ransack-1.6.1 spec/ransack/nodes/grouping_spec.rb
ransack-1.6.0 spec/ransack/nodes/grouping_spec.rb
ransack-1.5.1 spec/ransack/nodes/grouping_spec.rb
ransack-1.5.0 spec/ransack/nodes/grouping_spec.rb