Sha256: 86e0659b2230064b9e335e7c0dc49eae7d8b8a980a08b31372ab948178665d86

Contents?: true

Size: 1.54 KB

Versions: 8

Compression:

Stored size: 1.54 KB

Contents

require 'spec_helper'

require 'mspire/cv/paramable'
require 'mspire/cv/param'
require 'mspire/user_param'
require 'mspire/mzml/referenceable_param_group'

class MockObject
  include Mspire::CV::Paramable
end

describe 'Mspire::CV::Paramable' do

  subject do
    paramable = MockObject.new :params => ['MS:1000007', ['MS:1000511', 2]]
    paramable.user_params << Mspire::UserParam.new('hello', 477)
    paramable.ref_param_groups << Mspire::Mzml::ReferenceableParamGroup.new('id1', :params => [['MS:1000512', 'filter string']])
    paramable
  end

  it 'can be initialized with different types of params' do
    subject.cv_params.size.should == 2
    subject.ref_param_groups.size.should == 1
    subject.user_params.size.should == 1
  end

  it '#params grabs all params' do
    params = subject.params
    params.size.should == 4
    params.map(&:class).uniq.size.should == 2
  end

  it '#params? asks if there are any' do
    subject.params?.should be_true
  end

  it '#accessionable_params returns those with accession numbers' do
    subject.accessionable_params.size.should == 3
  end

  it '#param finds the value or true if param name exists' do
    # doesn't take accessions!
    subject.fetch('MS:1000511').should be_false
    subject.fetch('ms level').should == 2
    subject.fetch('inlet type').should be_true
  end

  it '#params? tells if has any' do
    subject.params?.should be_true
    mine = subject.dup
    [:cv_params, :user_params, :ref_param_groups].each do |key|
      mine.send("#{key}=", []) 
    end
    mine.params?.should be_false
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mspire-0.7.18 spec/mspire/cv/paramable_spec.rb
mspire-0.7.17 spec/mspire/cv/paramable_spec.rb
mspire-0.7.13 spec/mspire/cv/paramable_spec.rb
mspire-0.7.12 spec/mspire/cv/paramable_spec.rb
mspire-0.7.11 spec/mspire/cv/paramable_spec.rb
mspire-0.7.10 spec/mspire/cv/paramable_spec.rb
mspire-0.7.9 spec/mspire/cv/paramable_spec.rb
mspire-0.7.8 spec/mspire/cv/paramable_spec.rb