Sha256: d0d93f89e70d7867c2dcbc0793bf466beada1f50cb9455e3248f2c102bc0deae

Contents?: true

Size: 1.13 KB

Versions: 31

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'

describe Postmark::Inflector do

  describe ".to_postmark" do
    it 'converts rubyish underscored format to camel cased symbols accepted by the Postmark API' do
      subject.to_postmark(:foo_bar).should == 'FooBar'
      subject.to_postmark(:_bar).should == 'Bar'
      subject.to_postmark(:really_long_long_long_long_symbol).should == 'ReallyLongLongLongLongSymbol'
      subject.to_postmark(:foo_bar_1).should == 'FooBar1'
    end

    it 'accepts strings as well' do
      subject.to_postmark('foo_bar').should == 'FooBar'
    end

    it 'acts idempotentely' do
      subject.to_postmark('FooBar').should == 'FooBar'
    end
  end

  describe ".to_ruby" do
    it 'converts camel cased symbols returned by the Postmark API to underscored Ruby symbols' do
      subject.to_ruby('FooBar').should == :foo_bar
      subject.to_ruby('LongTimeAgoInAFarFarGalaxy').should == :long_time_ago_in_a_far_far_galaxy
      subject.to_ruby('MessageID').should == :message_id
    end

    it 'acts idempotentely' do
      subject.to_ruby(:foo_bar).should == :foo_bar
      subject.to_ruby(:foo_bar_1).should == :foo_bar_1
    end
  end

end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
postmark-1.18.0 spec/unit/postmark/inflector_spec.rb
postmark-1.17.0 spec/unit/postmark/inflector_spec.rb
postmark-1.16.0 spec/unit/postmark/inflector_spec.rb
postmark-1.15.0 spec/unit/postmark/inflector_spec.rb
postmark-1.14.0 spec/unit/postmark/inflector_spec.rb
postmark-1.13.0 spec/unit/postmark/inflector_spec.rb
postmark-1.12.0 spec/unit/postmark/inflector_spec.rb
postmark-1.11.0 spec/unit/postmark/inflector_spec.rb
postmark-1.10.0 spec/unit/postmark/inflector_spec.rb
postmark-1.9.1 spec/unit/postmark/inflector_spec.rb
postmark-1.9.0 spec/unit/postmark/inflector_spec.rb
postmark-1.8.1 spec/unit/postmark/inflector_spec.rb
postmark-1.8.0 spec/unit/postmark/inflector_spec.rb
postmark-1.7.1 spec/unit/postmark/inflector_spec.rb
postmark-1.7.0 spec/unit/postmark/inflector_spec.rb
postmark-1.6.0 spec/unit/postmark/inflector_spec.rb
postmark-1.5.0 spec/unit/postmark/inflector_spec.rb
postmark-1.4.3 spec/unit/postmark/inflector_spec.rb
postmark-1.4.2 spec/unit/postmark/inflector_spec.rb
postmark-1.4.1 spec/unit/postmark/inflector_spec.rb