Sha256: 6f9aeb1a69eb1cb81d8558205d5d36487dad042da167569fc182a53604d02e69

Contents?: true

Size: 1.49 KB

Versions: 3

Compression:

Stored size: 1.49 KB

Contents

require 'spec_helper'

require 'ms/isotope'

describe 'MS::Isotope constants' do
  it 'has all the common isotopes: MS::Isotope::ISOTOPES' do
    # frozen
    MS::Isotope::ISOTOPES.size.should == 288
    hydrogen_isotopes = MS::Isotope::ISOTOPES.select {|iso| iso.element == :h }
    hydrogen_isotopes.size.should == 2

    { atomic_number: 1, element: :h, mass_number: 1, atomic_mass: 1.00782503207, relative_abundance: 0.999885, average_mass: 1.00794, mono: true }.each do |k,v|
      hydrogen_isotopes.first.send(k).should == v
    end
    {atomic_number: 1, element: :h, mass_number: 2, atomic_mass: 2.0141017778, relative_abundance: 0.000115, average_mass: 1.00794, mono: false}.each do |k,v|
      hydrogen_isotopes.last.send(k).should == v
    end
    u = MS::Isotope::ISOTOPES.last
    {atomic_number: 92, element: :u, mass_number: 238, atomic_mass: 238.0507882, relative_abundance: 0.992742, average_mass: 238.02891, mono: true}.each do |k,v|
      u.send(k).should == v
    end
  end
  it 'has all common isotopes by element: MS::Isotope::BY_ELEMENT' do
    [{atomic_number: 6, element: :c, mass_number: 12, atomic_mass: 12.0, relative_abundance: 0.9893, average_mass: 12.0107, mono: true}, {atomic_number: 6, element: :c, mass_number: 13, atomic_mass: 13.0033548378, relative_abundance: 0.0107, average_mass: 12.0107, mono: false}].zip(MS::Isotope::BY_ELEMENT[:c]) do |hash, iso|
      hash.each do |k,v|
        iso.send(k).should == v
      end
    end
    MS::Isotope::BY_ELEMENT[:h].size.should == 2
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mspire-0.6.26 spec/ms/isotope_spec.rb
mspire-0.6.25 spec/ms/isotope_spec.rb
mspire-0.6.24 spec/ms/isotope_spec.rb