Sha256: 02900d4f245e530788154b987b88fcf7d58047c77831ef2b8c4b980e9d96fc8b

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

describe WithFilters::Filter::BaseStart do
  subject {described_class.new(:year, :foo, '')}

  its(:field_name) {should == 'foo[year][start]'}
end

describe WithFilters::Filter::BaseStop do
  subject {described_class.new(:year, :foo, '')}

  its(:field_name) {should == 'foo[year][stop]'}
end

describe WithFilters::Filter::BaseRange do
  subject {described_class.new(:year, :foo, {})}

  its(:start) {should be_an_instance_of(WithFilters::Filter::BaseStart)}
  its(:stop)  {should be_an_instance_of(WithFilters::Filter::BaseStop)}

  context 'options' do
    it 'uses the :start and :stop option hashes for the individual filters and default any values not passed to the range options provided' do
      filter = described_class.new(:year, :foo, {}, label: 'Nobel Prize Won In')
      filter.start.label.should == 'Nobel Prize Won In'
      filter.stop.label.should  == 'Nobel Prize Won In'

      filter = described_class.new(:year, :foo, {}, label: 'Nobel Prize Won In', start: {label: 'Nobel Prize Won Between'}, stop: {label: 'and'})
      filter.start.label.should == 'Nobel Prize Won Between'
      filter.stop.label.should  == 'and'
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
with_filters-0.1.2 spec/models/filter/base_range_spec.rb
with_filters-0.1.1 spec/models/filter/base_range_spec.rb
with_filters-0.1.0 spec/models/filter/base_range_spec.rb