Sha256: 7a4cc00b6e5483a45e0a5f62488937520d0f68895445e0535d072878560c86e1

Contents?: true

Size: 1.99 KB

Versions: 1

Compression:

Stored size: 1.99 KB

Contents

#
# Author:: Seth Chisamore (<schisamo@opscode.com>)
# Copyright:: Copyright (c) 2013 Opscode, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

shared_examples "filterable" do

  let(:unsorted_versions) do
    unsorted_version_strings.map{ |v| described_class.new(v) }
  end

  # this should/will be overriden by calling spec
  let(:release_versions){[]}
  let(:prerelease_versions){[]}
  let(:build_versions){[]}
  let(:release_build_versions){[]}
  let(:prerelease_build_versions){[]}

  it "filters by release versions only" do
    unsorted_versions.select(&:release?).should eq(release_versions.map{|v|
      described_class.new(v)
    })
  end # it

  it "filters by pre-release versions only" do
    filtered = unsorted_versions.select(&:prerelease?)
    filtered.should eq(prerelease_versions.map{|v|
      described_class.new(v)
    })
  end # it

  it "filters by build versions only" do
    filtered = unsorted_versions.select(&:build?)
    filtered.should eq(build_versions.map{|v|
      described_class.new(v)
    })
  end # it

  it "filters by release build versions only" do
    filtered = unsorted_versions.select(&:release_build?)
    filtered.should eq(release_build_versions.map{|v|
      described_class.new(v)
    })
  end # it

  it "filters by pre-release build versions only" do
    filtered = unsorted_versions.select(&:prerelease_build?)
    filtered.should eq(prerelease_build_versions.map{|v|
      described_class.new(v)
    })
  end # it

end # shared_examples

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mixlib-versioning-1.0.0 spec/support/shared_examples/behaviors/filterable.rb