Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Travis-CI && support V6 add-ons #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
coverage/*
test/client/coverage/*
test/coverage/*
Expand Down
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: ruby
rvm:
- 2.0.0
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ source "http://rubygems.org"
gem 'awesome_print'
gem 'yard'
gem 'bluecloth'
gem 'test-unit'

# Specify your gem's dependencies in stamps.gemspec
gemspec
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Stamps
Stamps [![Build Status](https://travis-ci.org/mattsears/stamps.svg?branch=master)](https://travis-ci.org/mattsears/stamps)
==========

Stamps is Stamps.com backed library for creating postage labels,
Expand Down
9 changes: 8 additions & 1 deletion lib/stamps/mapping.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ class Rate < Hashie::Trash
# Maps :rate to AddOns map
def add_ons=(addons)
self[:AddOns] = AddOnsArray.new(:add_on_v4 => addons[:add_on_v4],
:add_on_v5 => addons[:add_on_v5])
:add_on_v5 => addons[:add_on_v5],
:add_on_v6 => addons[:add_on_v6])
end
end

class AddOnsArray < Hashie::Trash
property :AddOnV4, :from => :add_on_v4
property :AddOnV5, :from => :add_on_v5
property :AddOnV6, :from => :add_on_v6

def add_on_v4=(vals)
return unless vals
Expand All @@ -101,6 +103,11 @@ def add_on_v5=(vals)
return unless vals
self[:AddOnV5] = vals.map{ |value| AddOn.new(value).to_hash }
end

def add_on_v6=(vals)
return unless vals
self[:AddOnV6] = vals.map{ |value| AddOn.new(value).to_hash }
end
end

class AddOn < Hashie::Trash
Expand Down
11 changes: 11 additions & 0 deletions test/mapping_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ class MappingTest < Test::Unit::TestCase
assert_equal @rate.to_hash['AddOns'], { "AddOnV5" => @expected }
end
end

context 'a rate with add_on_v6 add-ons' do
setup do
@params[:add_ons] = { add_on_v6: @add_ons}
@rate = Stamps::Mapping::Rate.new(@params)
end

should 'map add_ons to AddOnsV6' do
assert_equal @rate.to_hash['AddOns'], { "AddOnV6" => @expected }
end
end
end
end

Expand Down