money_helper 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0ec1d057d296f1729ab55b1becee98afad5c50b7
4
- data.tar.gz: 786a1ae33bf67e9d1215be82a7856c0138d5c292
2
+ SHA256:
3
+ metadata.gz: b9409dd10ed69a492d053ef2f48f2df62b16b9eed8834f12c543dbc4865b1cfb
4
+ data.tar.gz: 134b17f59322299c63b49e516af4c82ebd9e1359f759184a17b06aaa0f4f6fa7
5
5
  SHA512:
6
- metadata.gz: a3ee33d19f4019bfae4b788fb62ca1ccf11d7264c6794b2f5acd5a39cb3ed3ceb967d9897d94c3e6d85ccd99a0e9416d298f688052ad2a6e1ab12affd356ac2f
7
- data.tar.gz: 038e37ac696e39834b2a88cd00bdc43fd0771aed279a9dde5d499a5e719e6e46a1a9e3ffbe7d3effe907175163f72c93b713fd656680c634810b1a2f01cfbe9c
6
+ metadata.gz: c6a1d9d53b70a8e0e8aa50a2cfabcb48b56f38b09dbc8f4e8d2ee2746a7ae2786b33875d732a87d00d911f52acac8490ca59a5c66e9abe8384e6220dfede353c
7
+ data.tar.gz: f36758af1bc845d8449ed052088b293a4659723cab6054112f960be5785f59932e480d26b783fc699ce206b4492d33669bc3861acec827fded3409f1c4171460
@@ -0,0 +1,4 @@
1
+ Gemfile.lock
2
+ gemfiles/*.lock
3
+ gemfiles/.bundle
4
+ gemfiles/vendor
@@ -0,0 +1,18 @@
1
+ AllCops:
2
+ Exclude:
3
+ - vendor/**/*
4
+ - gemfiles/vendor/**/*
5
+
6
+ Metrics:
7
+ Enabled: false
8
+
9
+ Metrics/LineLength:
10
+ Max: 512
11
+
12
+ Style/Documentation:
13
+ Enabled: false
14
+
15
+ Naming/MethodName:
16
+ Enabled: false
17
+
18
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,12 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2019-04-19 14:01:54 -0400 using RuboCop version 0.67.2.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 3
10
+ Lint/IneffectiveAccessModifier:
11
+ Exclude:
12
+ - 'lib/money_helper.rb'
@@ -0,0 +1,30 @@
1
+ language: ruby
2
+
3
+ cache: bundler
4
+
5
+ sudo: false
6
+
7
+ rvm:
8
+ - 2.3.4
9
+ - 2.4.1
10
+ - 2.5
11
+ - ruby-head
12
+
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+ include:
17
+ - rvm: 2.5
18
+ gemfile: gemfiles/activesupport_40.gemfile
19
+ - rvm: 2.5
20
+ gemfile: gemfiles/activesupport_41.gemfile
21
+ - rvm: 2.5
22
+ gemfile: gemfiles/activesupport_42.gemfile
23
+ - rvm: 2.5
24
+ gemfile: gemfiles/activesupport_50.gemfile
25
+ - rvm: 2.5
26
+ gemfile: gemfiles/activesupport_51.gemfile
27
+ - rvm: 2.5
28
+ gemfile: gemfiles/activesupport_52.gemfile
29
+ - rvm: 2.5
30
+ gemfile: gemfiles/activesupport_edge.gemfile
@@ -0,0 +1,29 @@
1
+ appraise 'activesupport_40' do
2
+ gem 'activesupport', '~> 4.0.0'
3
+ end
4
+
5
+ appraise 'activesupport_41' do
6
+ gem 'activesupport', '~> 4.1.0'
7
+ end
8
+
9
+ appraise 'activesupport_42' do
10
+ gem 'activesupport', '~> 4.2.0'
11
+ end
12
+
13
+ appraise 'activesupport_50' do
14
+ gem 'activesupport', '~> 5.0.0'
15
+ end
16
+
17
+ appraise 'activesupport_51' do
18
+ gem 'activesupport', '~> 5.1.0'
19
+ end
20
+
21
+ appraise 'activesupport_52' do
22
+ gem 'activesupport', '~> 5.2.1'
23
+ end
24
+
25
+ appraise 'activesupport_edge' do
26
+ git 'git://github.com/rails/rails.git' do
27
+ gem 'activesupport', require: 'active_support'
28
+ end
29
+ end
@@ -0,0 +1,39 @@
1
+ ### 1.0.2 (2019/4/19)
2
+
3
+ * [#16](https://github.com/artsy/money_helper/pull/16): Remove deprecation warnings - [@sweir27](https://github.com/sweir27).
4
+ * [#15](https://github.com/artsy/money_helper/pull/15): Added Rubocop - [@dblock](https://github.com/dblock).
5
+
6
+ ### 1.0.1 (2017/4/3)
7
+
8
+ * Relaxed activesupport version dependency - [@dblock](https://github.com/dblock).
9
+ * The `money_to_text` method now takes options - [@mzikherman](https://github.com/mzikherman).
10
+ * Added `symbol_with_optional_iso_code` - [@mzikherman](https://github.com/mzikherman).
11
+
12
+ ### 1.0.0 (2015/3/7)
13
+
14
+ * Added compatibility with Money 6.5.1+, including new currency symbols - [@syakhmi](https://github.com/syakhmi).
15
+
16
+ ### 0.0.5 (2014/4/12)
17
+
18
+ * Added compatibility with Money 6.1+ - [@syakhmi](https://github.com/syakhmi).
19
+ * Dropped support for pre 6.0 versions of Money - [@syakhmi](https://github.com/syakhmi).
20
+
21
+ ### 0.0.4 (2014/1/8)
22
+
23
+ * Added compatibility with Money 6.x - [@dblock](https://github.com/dblock).
24
+ * Avoid failing on deprecated currencies (such as ITL) - [@joeyAghion](https://github.com/joeyAghion).
25
+
26
+ ### 0.0.3 (2013/7/17)
27
+
28
+ * Added support for currencies that don't have a symbol, eg. Uzbekistan Som (UZS) - [@dblock](https://github.com/dblock).
29
+
30
+ ### 0.0.2 (2013/7/16)
31
+
32
+ * Added unit tests - [@syakhmi](https://github.com/syakhmi).
33
+ * Added support for Cambodian riel - [@syakhmi](https://github.com/syakhmi).
34
+ * Added dependencies to gemspec - [@syakhmi](https://github.com/syakhmi).
35
+ * Now defaults to USD when currency not specified - [@syakhmi](https://github.com/syakhmi).
36
+
37
+ ### 0.0.1 (2013/7/12)
38
+
39
+ * Initial public release - [@syakhmi](https://github.com/syakhmi).
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rubocop', '0.67.2'
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013-2018 Artsy, Sahil Yakhmi, Joey Aghion, and contributors.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,43 @@
1
+ MoneyHelper
2
+ ============
3
+
4
+ A simple module to assist in formatting unambiguous prices and price ranges in international currencies in a Roman Script environment.
5
+
6
+ [![Build Status](https://travis-ci.org/artsy/money_helper.svg?branch=master)](https://travis-ci.org/artsy/money_helper)
7
+
8
+ Usage
9
+ -----
10
+
11
+ Examples:
12
+
13
+ ``` ruby
14
+ money_to_text(10000, 'AUD')
15
+ ```
16
+ produces "AUD $10,000"
17
+
18
+ ``` ruby
19
+ money_to_text(10000, 'AUD', true)
20
+ ```
21
+ produces "10,000"
22
+
23
+ ``` ruby
24
+ money_range_to_text(10000, 40000, 'AUD', ' ... ')
25
+ ```
26
+ produces: "AUD $10,000 ... 40,000"
27
+
28
+ Defaults
29
+ --------
30
+
31
+ As of [#16](https://github.com/artsy/money_helper/pull/16) this library explicitly specifies the `Money.locale_backend = :currency` default.
32
+
33
+ Contributing
34
+ ------------
35
+
36
+ Fork the project. Make your feature addition or bug fix with tests. Send a pull request.
37
+
38
+ Copyright and License
39
+ ---------------------
40
+
41
+ MIT License, see [LICENSE](LICENSE.md) for details.
42
+
43
+ (c) 2013-2018 [Artsy](http://artsy.github.com), [Sahil Yakhmi](https://github.com/syakhmi), [Joey Aghion](https://github.com/joeyAghion) and [contributors](CHANGELOG.md).
@@ -0,0 +1,61 @@
1
+ # Releasing money_helper
2
+
3
+ There are no hard rules about when to release money_helper. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
4
+
5
+ ### Release
6
+
7
+ Run tests, check that all tests succeed locally.
8
+
9
+ ```
10
+ bundle install
11
+ rake
12
+ ```
13
+
14
+ Check that the last build succeeded in [Travis CI](https://travis-ci.org/artsy/money_helper) for all supported platforms.
15
+
16
+ Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
17
+
18
+ ```
19
+ ### 0.2.2 (2015/7/10)
20
+ ```
21
+
22
+ Remove the line with "Your contribution here.", since there will be no more contributions to this release.
23
+
24
+ Commit your changes.
25
+
26
+ ```
27
+ git add CHANGELOG.md
28
+ git commit -m "Preparing for release, 0.2.2."
29
+ git push origin master
30
+ ```
31
+
32
+ Release.
33
+
34
+ ```
35
+ $ rake release
36
+
37
+ money_helper 0.2.2 built to pkg/money_helper-0.2.2.gem.
38
+ Tagged v0.2.2.
39
+ Pushed git commits and tags.
40
+ Pushed money_helper 0.2.2 to rubygems.org.
41
+ ```
42
+
43
+ ### Prepare for the Next Version
44
+
45
+ Add the next release to [CHANGELOG.md](CHANGELOG.md).
46
+
47
+ ```
48
+ ### 0.2.3 (Next)
49
+
50
+ * Your contribution here.
51
+ ```
52
+
53
+ Increment the third version number in [lib/version.rb](lib/version.rb).
54
+
55
+ Commit your changes.
56
+
57
+ ```
58
+ git add CHANGELOG.md lib/version.rb
59
+ git commit -m "Preparing for next development iteration, 0.2.3."
60
+ git push origin master
61
+ ```
@@ -0,0 +1,17 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'bundler/gem_tasks'
4
+
5
+ Bundler.setup :default, :development
6
+
7
+ require 'rspec/core'
8
+ require 'rspec/core/rake_task'
9
+
10
+ RSpec::Core::RakeTask.new(:spec) do |spec|
11
+ spec.pattern = FileList['spec/**/*_spec.rb']
12
+ end
13
+
14
+ require 'rubocop/rake_task'
15
+ RuboCop::RakeTask.new
16
+
17
+ task default: %i[rubocop spec]
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gem 'activesupport', '~> 4.0.0'
6
+ gem 'rubocop', '0.59.2'
7
+
8
+ gemspec path: '../'
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gem 'activesupport', '~> 4.1.0'
6
+ gem 'rubocop', '0.59.2'
7
+
8
+ gemspec path: '../'
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gem 'activesupport', '~> 4.2.0'
6
+ gem 'rubocop', '0.59.2'
7
+
8
+ gemspec path: '../'
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gem 'activesupport', '~> 5.0.0'
6
+ gem 'rubocop', '0.59.2'
7
+
8
+ gemspec path: '../'
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gem 'activesupport', '~> 5.1.0'
6
+ gem 'rubocop', '0.59.2'
7
+
8
+ gemspec path: '../'
@@ -0,0 +1,8 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ gem 'activesupport', '~> 5.2.1'
6
+ gem 'rubocop', '0.59.2'
7
+
8
+ gemspec path: '../'
@@ -0,0 +1,11 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source 'http://rubygems.org'
4
+
5
+ git 'git://github.com/rails/rails.git' do
6
+ gem 'activesupport', require: 'active_support'
7
+ end
8
+
9
+ gem 'rubocop', '0.59.2'
10
+
11
+ gemspec path: '../'
@@ -1,15 +1,16 @@
1
- # encoding: UTF-8
1
+ require_relative 'version'
2
2
 
3
3
  require 'active_support/core_ext/object/blank'
4
4
  require 'money'
5
5
 
6
6
  module MoneyHelper
7
+ Money.locale_backend = :currency
7
8
  I18n.enforce_available_locales = false
8
9
 
9
- SYMBOL_ONLY = %w{USD GBP EUR MYR} #don't use ISO code
10
- OK_SYMBOLS = %w{
10
+ SYMBOL_ONLY = %w[USD GBP EUR MYR].freeze # don't use ISO code
11
+ OK_SYMBOLS = %w[
11
12
  $ £ € ¥ 元 р. L ƒ ৳ P R$ K ₡ D ლ ₵ Q G ₹ Rp ₪ ₩ ₭ R RM ₨ ₮ դր. C$ ₦ ₲ ₱ T ฿ T$ m ₴ ₫ ៛ ₺ E ₽
12
- } #ok to include in string
13
+ ].freeze # ok to include in string
13
14
 
14
15
  ##
15
16
  # Formats a single amount in the given currency into a price string. Defaults to USD if currency not
@@ -27,14 +28,15 @@ module MoneyHelper
27
28
  # specific to currency)
28
29
  def self.money_to_text(amount, currency, number_only = false, options = {})
29
30
  return nil unless amount.present?
30
- currency = "USD" if currency.blank?
31
- valid_currency = code_valid?(currency) ? currency : "USD"
31
+
32
+ currency = 'USD' if currency.blank?
33
+ valid_currency = code_valid?(currency) ? currency : 'USD'
32
34
  symbol = symbol_for_code(currency)
33
35
  include_symbol = !number_only && symbol.present? && OK_SYMBOLS.include?(symbol)
34
36
  subunit_factor = Money::Currency.new(valid_currency).subunit_to_unit
35
- money_options = { no_cents: true, symbol_position: :before, symbol: include_symbol }.merge(options)
36
- (number_only || SYMBOL_ONLY.include?(currency) ? "" : currency + " ") +
37
- Money.new(amount*subunit_factor.ceil, valid_currency).format(money_options).delete(' ')
37
+ money_options = { no_cents: true, format: '%u %n', symbol: include_symbol }.merge(options)
38
+ (number_only || SYMBOL_ONLY.include?(currency) ? '' : currency + ' ') +
39
+ Money.new(amount * subunit_factor.ceil, valid_currency).format(money_options).delete(' ')
38
40
  end
39
41
 
40
42
  def self.symbol_with_optional_iso_code(currency = 'USD')
@@ -44,7 +46,7 @@ module MoneyHelper
44
46
  elsif symbol && OK_SYMBOLS.include?(symbol)
45
47
  "#{iso_for_currency(currency)} #{symbol}"
46
48
  else
47
- "#{iso_for_currency(currency)}"
49
+ iso_for_currency(currency).to_s
48
50
  end
49
51
  end
50
52
 
@@ -68,24 +70,23 @@ module MoneyHelper
68
70
  if low.blank? && high.blank?
69
71
  nil
70
72
  elsif low.blank?
71
- "Under " + money_to_text(high, currency)
73
+ 'Under ' + money_to_text(high, currency)
72
74
  elsif high.blank?
73
- money_to_text(low, currency) + " and up"
75
+ money_to_text(low, currency) + ' and up'
74
76
  elsif low == high
75
77
  money_to_text(low, currency)
76
78
  else
77
- [ money_to_text(low, currency), money_to_text(high, currency, true) ].compact.join(delimiter)
79
+ [money_to_text(low, currency), money_to_text(high, currency, true)].compact.join(delimiter)
78
80
  end
79
81
  end
80
82
 
81
- private
82
-
83
83
  def self.code_valid?(code)
84
84
  Money::Currency.stringified_keys.include?(code.downcase)
85
85
  end
86
86
 
87
87
  def self.iso_for_currency(code)
88
88
  return unless code && code_valid?(code)
89
+
89
90
  Money::Currency.new(code).iso_code.tap do |iso_code|
90
91
  iso_code.strip! if iso_code.present?
91
92
  end
@@ -93,6 +94,7 @@ module MoneyHelper
93
94
 
94
95
  def self.symbol_for_code(code)
95
96
  return unless code && code_valid?(code)
97
+
96
98
  Money::Currency.new(code).symbol.tap do |symbol|
97
99
  symbol.strip! if symbol.present?
98
100
  end
@@ -0,0 +1,3 @@
1
+ module MoneyHelper
2
+ VERSION = '1.0.2'.freeze
3
+ end
@@ -0,0 +1,22 @@
1
+ $LOAD_PATH.push File.expand_path('lib', __dir__)
2
+ require 'version'
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = 'money_helper'
6
+ s.version = MoneyHelper::VERSION
7
+ s.summary = 'MoneyHelper international price formatting utility.'
8
+ s.description = 'A simple module to assist in formatting unambiguous prices and price ranges in international currencies in a Roman Script context.'
9
+ s.authors = ['Sahil Yakhmi', 'Joey Aghion', 'Matt Zikherman', 'Sarah Weir']
10
+ s.email = 'matt@artsymail.com'
11
+ s.platform = Gem::Platform::RUBY
12
+ s.required_rubygems_version = '>= 1.3.6'
13
+ s.files = `git ls-files`.split("\n")
14
+ s.test_files = `git ls-files -- spec/*`.split("\n")
15
+ s.require_paths = ['lib']
16
+ s.homepage = 'https://github.com/artsy/money_helper'
17
+ s.add_dependency('activesupport')
18
+ s.add_dependency('money', '~> 6.5')
19
+ s.add_development_dependency('appraisal')
20
+ s.add_development_dependency('rspec', '~> 3')
21
+ s.licenses = ['MIT']
22
+ end
@@ -1,149 +1,147 @@
1
- # encoding: UTF-8
2
-
3
- require 'money_helper'
1
+ require 'spec_helper'
4
2
 
5
3
  describe MoneyHelper do
6
- describe "money_to_text" do
7
- it "includes only symbol for well-recognizable currencies" do
8
- expect(MoneyHelper.money_to_text(30000, "EUR")).to eql("€30.000")
9
- expect(MoneyHelper.money_to_text(30000, "GBP")).to eql("£30,000")
10
- expect(MoneyHelper.money_to_text(30000, "MYR")).to eql("RM30,000")
11
- expect(MoneyHelper.money_to_text(30000, "TRY")).to eql("TRY ₺30.000")
12
- expect(MoneyHelper.money_to_text(30000, "USD")).to eql("$30,000")
13
- end
14
- it "includes ISO code and symbol for ambiguous currencies" do
15
- expect(MoneyHelper.money_to_text(30000, "AUD")).to eql("AUD $30,000")
16
- expect(MoneyHelper.money_to_text(30000, "ARS")).to eql("ARS $30.000")
17
- expect(MoneyHelper.money_to_text(30000, "BBD")).to eql("BBD $30,000")
18
- expect(MoneyHelper.money_to_text(30000, "BMD")).to eql("BMD $30,000")
19
- expect(MoneyHelper.money_to_text(30000, "BND")).to eql("BND $30,000")
20
- expect(MoneyHelper.money_to_text(30000, "BSD")).to eql("BSD $30,000")
21
- expect(MoneyHelper.money_to_text(30000, "BZD")).to eql("BZD $30,000")
22
- expect(MoneyHelper.money_to_text(30000, "CAD")).to eql("CAD $30,000")
23
- expect(MoneyHelper.money_to_text(30000, "CLP")).to eql("CLP $30.000")
24
- expect(MoneyHelper.money_to_text(30000, "COP")).to eql("COP $30.000")
25
- expect(MoneyHelper.money_to_text(30000, "CUC")).to eql("CUC $30,000")
26
- expect(MoneyHelper.money_to_text(30000, "CUP")).to eql("CUP $30,000")
27
- expect(MoneyHelper.money_to_text(30000, "DOP")).to eql("DOP $30,000")
28
- expect(MoneyHelper.money_to_text(30000, "FJD")).to eql("FJD $30,000")
29
- expect(MoneyHelper.money_to_text(30000, "GYD")).to eql("GYD $30,000")
30
- expect(MoneyHelper.money_to_text(30000, "HKD")).to eql("HKD $30,000")
31
- expect(MoneyHelper.money_to_text(30000, "JMD")).to eql("JMD $30,000")
32
- expect(MoneyHelper.money_to_text(30000, "KYD")).to eql("KYD $30,000")
33
- expect(MoneyHelper.money_to_text(30000, "LRD")).to eql("LRD $30,000")
34
- expect(MoneyHelper.money_to_text(30000, "MXN")).to eql("MXN $30,000")
35
- expect(MoneyHelper.money_to_text(30000, "NAD")).to eql("NAD $30,000")
36
- expect(MoneyHelper.money_to_text(30000, "NZD")).to eql("NZD $30,000")
37
- expect(MoneyHelper.money_to_text(30000, "SBD")).to eql("SBD $30,000")
38
- expect(MoneyHelper.money_to_text(30000, "SGD")).to eql("SGD $30,000")
39
- expect(MoneyHelper.money_to_text(30000, "SRD")).to eql("SRD $30,000")
40
- expect(MoneyHelper.money_to_text(30000, "TWD")).to eql("TWD $30,000")
41
- expect(MoneyHelper.money_to_text(30000, "TTD")).to eql("TTD $30,000")
42
- expect(MoneyHelper.money_to_text(30000, "UYU")).to eql("UYU $30.000")
43
- expect(MoneyHelper.money_to_text(30000, "XCD")).to eql("XCD $30,000")
44
- expect(MoneyHelper.money_to_text(30000, "ZWL")).to eql("ZWL $30,000")
4
+ describe 'money_to_text' do
5
+ it 'includes only symbol for well-recognizable currencies' do
6
+ expect(MoneyHelper.money_to_text(30_000, 'EUR')).to eql('€30.000')
7
+ expect(MoneyHelper.money_to_text(30_000, 'GBP')).to eql('£30,000')
8
+ expect(MoneyHelper.money_to_text(30_000, 'MYR')).to eql('RM30,000')
9
+ expect(MoneyHelper.money_to_text(30_000, 'TRY')).to eql('TRY ₺30.000')
10
+ expect(MoneyHelper.money_to_text(30_000, 'USD')).to eql('$30,000')
11
+ end
12
+ it 'includes ISO code and symbol for ambiguous currencies' do
13
+ expect(MoneyHelper.money_to_text(30_000, 'AUD')).to eql('AUD $30,000')
14
+ expect(MoneyHelper.money_to_text(30_000, 'ARS')).to eql('ARS $30.000')
15
+ expect(MoneyHelper.money_to_text(30_000, 'BBD')).to eql('BBD $30,000')
16
+ expect(MoneyHelper.money_to_text(30_000, 'BMD')).to eql('BMD $30,000')
17
+ expect(MoneyHelper.money_to_text(30_000, 'BND')).to eql('BND $30,000')
18
+ expect(MoneyHelper.money_to_text(30_000, 'BSD')).to eql('BSD $30,000')
19
+ expect(MoneyHelper.money_to_text(30_000, 'BZD')).to eql('BZD $30,000')
20
+ expect(MoneyHelper.money_to_text(30_000, 'CAD')).to eql('CAD $30,000')
21
+ expect(MoneyHelper.money_to_text(30_000, 'CLP')).to eql('CLP $30.000')
22
+ expect(MoneyHelper.money_to_text(30_000, 'COP')).to eql('COP $30.000')
23
+ expect(MoneyHelper.money_to_text(30_000, 'CUC')).to eql('CUC $30,000')
24
+ expect(MoneyHelper.money_to_text(30_000, 'CUP')).to eql('CUP $30,000')
25
+ expect(MoneyHelper.money_to_text(30_000, 'DOP')).to eql('DOP $30,000')
26
+ expect(MoneyHelper.money_to_text(30_000, 'FJD')).to eql('FJD $30,000')
27
+ expect(MoneyHelper.money_to_text(30_000, 'GYD')).to eql('GYD $30,000')
28
+ expect(MoneyHelper.money_to_text(30_000, 'HKD')).to eql('HKD $30,000')
29
+ expect(MoneyHelper.money_to_text(30_000, 'JMD')).to eql('JMD $30,000')
30
+ expect(MoneyHelper.money_to_text(30_000, 'KYD')).to eql('KYD $30,000')
31
+ expect(MoneyHelper.money_to_text(30_000, 'LRD')).to eql('LRD $30,000')
32
+ expect(MoneyHelper.money_to_text(30_000, 'MXN')).to eql('MXN $30,000')
33
+ expect(MoneyHelper.money_to_text(30_000, 'NAD')).to eql('NAD $30,000')
34
+ expect(MoneyHelper.money_to_text(30_000, 'NZD')).to eql('NZD $30,000')
35
+ expect(MoneyHelper.money_to_text(30_000, 'SBD')).to eql('SBD $30,000')
36
+ expect(MoneyHelper.money_to_text(30_000, 'SGD')).to eql('SGD $30,000')
37
+ expect(MoneyHelper.money_to_text(30_000, 'SRD')).to eql('SRD $30,000')
38
+ expect(MoneyHelper.money_to_text(30_000, 'TWD')).to eql('TWD $30,000')
39
+ expect(MoneyHelper.money_to_text(30_000, 'TTD')).to eql('TTD $30,000')
40
+ expect(MoneyHelper.money_to_text(30_000, 'UYU')).to eql('UYU $30.000')
41
+ expect(MoneyHelper.money_to_text(30_000, 'XCD')).to eql('XCD $30,000')
42
+ expect(MoneyHelper.money_to_text(30_000, 'ZWL')).to eql('ZWL $30,000')
45
43
 
46
- expect(MoneyHelper.money_to_text(30000, "FKP")).to eql("FKP £30,000")
47
- expect(MoneyHelper.money_to_text(30000, "GIP")).to eql("GIP £30,000")
48
- expect(MoneyHelper.money_to_text(30000, "SDG")).to eql("SDG £30,000")
49
- expect(MoneyHelper.money_to_text(30000, "SHP")).to eql("SHP £30,000")
44
+ expect(MoneyHelper.money_to_text(30_000, 'FKP')).to eql('FKP £30,000')
45
+ expect(MoneyHelper.money_to_text(30_000, 'GIP')).to eql('GIP £30,000')
46
+ expect(MoneyHelper.money_to_text(30_000, 'SDG')).to eql('SDG £30,000')
47
+ expect(MoneyHelper.money_to_text(30_000, 'SHP')).to eql('SHP £30,000')
50
48
 
51
- expect(MoneyHelper.money_to_text(30000, "CNY")).to eql("CNY ¥30,000")
52
- expect(MoneyHelper.money_to_text(30000, "JPY")).to eql("JPY ¥30,000")
49
+ expect(MoneyHelper.money_to_text(30_000, 'CNY')).to eql('CNY ¥30,000')
50
+ expect(MoneyHelper.money_to_text(30_000, 'JPY')).to eql('JPY ¥30,000')
53
51
 
54
- expect(MoneyHelper.money_to_text(30000, "ALL")).to eql("ALL L30,000")
55
- expect(MoneyHelper.money_to_text(30000, "HNL")).to eql("HNL L30,000")
56
- expect(MoneyHelper.money_to_text(30000, "LSL")).to eql("LSL L30,000")
57
- expect(MoneyHelper.money_to_text(30000, "MDL")).to eql("MDL L30,000")
58
- expect(MoneyHelper.money_to_text(30000, "RON")).to eql("RON 30.000")
59
- expect(MoneyHelper.money_to_text(30000, "SZL")).to eql("SZL E30,000")
52
+ expect(MoneyHelper.money_to_text(30_000, 'ALL')).to eql('ALL L30,000')
53
+ expect(MoneyHelper.money_to_text(30_000, 'HNL')).to eql('HNL L30,000')
54
+ expect(MoneyHelper.money_to_text(30_000, 'LSL')).to eql('LSL L30,000')
55
+ expect(MoneyHelper.money_to_text(30_000, 'MDL')).to eql('MDL L30,000')
56
+ expect(MoneyHelper.money_to_text(30_000, 'RON')).to eql('RON 30.000')
57
+ expect(MoneyHelper.money_to_text(30_000, 'SZL')).to eql('SZL E30,000')
60
58
 
61
- expect(MoneyHelper.money_to_text(30000, "ANG")).to eql("ANG ƒ30.000")
62
- expect(MoneyHelper.money_to_text(30000, "AWG")).to eql("AWG ƒ30,000")
59
+ expect(MoneyHelper.money_to_text(30_000, 'ANG')).to eql('ANG ƒ30.000')
60
+ expect(MoneyHelper.money_to_text(30_000, 'AWG')).to eql('AWG ƒ30,000')
63
61
 
64
- expect(MoneyHelper.money_to_text(30000, "BWP")).to eql("BWP P30,000")
65
- expect(MoneyHelper.money_to_text(30000, "MOP")).to eql("MOP P30,000")
62
+ expect(MoneyHelper.money_to_text(30_000, 'BWP')).to eql('BWP P30,000')
63
+ expect(MoneyHelper.money_to_text(30_000, 'MOP')).to eql('MOP P30,000')
66
64
 
67
- expect(MoneyHelper.money_to_text(30000, "CRC")).to eql("CRC ₡30.000")
68
- expect(MoneyHelper.money_to_text(30000, "SVC")).to eql("SVC ₡30,000")
65
+ expect(MoneyHelper.money_to_text(30_000, 'CRC')).to eql('CRC ₡30.000')
66
+ expect(MoneyHelper.money_to_text(30_000, 'SVC')).to eql('SVC ₡30,000')
69
67
 
70
- expect(MoneyHelper.money_to_text(30000, "MUR")).to eql("MUR ₨30,000")
71
- expect(MoneyHelper.money_to_text(30000, "NPR")).to eql("NPR ₨30,000")
72
- expect(MoneyHelper.money_to_text(30000, "PKR")).to eql("PKR ₨30,000")
73
- expect(MoneyHelper.money_to_text(30000, "SCR")).to eql("SCR ₨30,000")
74
- end
75
- it "includes ISO code and symbol for difficult to recognize symbols" do
76
- expect(MoneyHelper.money_to_text(30000, "AMD")).to eql("AMD դր.30,000")
77
- expect(MoneyHelper.money_to_text(30000, "BDT")).to eql("BDT ৳30,000")
78
- expect(MoneyHelper.money_to_text(30000, "BRL")).to eql("BRL R$30.000")
79
- expect(MoneyHelper.money_to_text(30000, "GMD")).to eql("GMD D30,000")
80
- expect(MoneyHelper.money_to_text(30000, "GEL")).to eql("GEL ლ30,000")
81
- expect(MoneyHelper.money_to_text(30000, "GHS")).to eql("GHS ₵30,000")
82
- expect(MoneyHelper.money_to_text(30000, "GTQ")).to eql("GTQ Q30,000")
83
- expect(MoneyHelper.money_to_text(30000, "HTG")).to eql("HTG G30,000")
84
- expect(MoneyHelper.money_to_text(30000, "IDR")).to eql("IDR Rp30.000")
85
- expect(MoneyHelper.money_to_text(30000, "ILS")).to eql("ILS ₪30,000")
86
- expect(MoneyHelper.money_to_text(30000, "INR")).to eql("INR ₹30,000")
87
- expect(MoneyHelper.money_to_text(30000, "KHR")).to eql("KHR ៛30,000")
88
- expect(MoneyHelper.money_to_text(30000, "KPW")).to eql("KPW ₩30,000")
89
- expect(MoneyHelper.money_to_text(30000, "LAK")).to eql("LAK ₭30,000")
90
- expect(MoneyHelper.money_to_text(30000, "MNT")).to eql("MNT ₮30,000")
91
- expect(MoneyHelper.money_to_text(30000, "NIO")).to eql("NIO C$30,000")
92
- expect(MoneyHelper.money_to_text(30000, "NGN")).to eql("NGN ₦30,000")
93
- expect(MoneyHelper.money_to_text(30000, "PGK")).to eql("PGK K30,000")
94
- expect(MoneyHelper.money_to_text(30000, "PHP")).to eql("PHP ₱30,000")
95
- expect(MoneyHelper.money_to_text(30000, "PYG")).to eql("PYG ₲30,000")
96
- expect(MoneyHelper.money_to_text(30000, "RUB")).to eql("RUB ₽30.000")
97
- expect(MoneyHelper.money_to_text(30000, "THB")).to eql("THB ฿30,000")
98
- expect(MoneyHelper.money_to_text(30000, "TOP")).to eql("TOP T$30,000")
99
- expect(MoneyHelper.money_to_text(30000, "TMT")).to eql("TMT T30,000")
100
- expect(MoneyHelper.money_to_text(30000, "UAH")).to eql("UAH ₴30,000")
101
- expect(MoneyHelper.money_to_text(30000, "VND")).to eql("VND ₫30.000")
102
- expect(MoneyHelper.money_to_text(30000, "WST")).to eql("WST T30,000")
103
- expect(MoneyHelper.money_to_text(30000, "ZAR")).to eql("ZAR R30,000")
68
+ expect(MoneyHelper.money_to_text(30_000, 'MUR')).to eql('MUR ₨30,000')
69
+ expect(MoneyHelper.money_to_text(30_000, 'NPR')).to eql('NPR ₨30,000')
70
+ expect(MoneyHelper.money_to_text(30_000, 'PKR')).to eql('PKR ₨30,000')
71
+ expect(MoneyHelper.money_to_text(30_000, 'SCR')).to eql('SCR ₨30,000')
72
+ end
73
+ it 'includes ISO code and symbol for difficult to recognize symbols' do
74
+ expect(MoneyHelper.money_to_text(30_000, 'AMD')).to eql('AMD դր.30,000')
75
+ expect(MoneyHelper.money_to_text(30_000, 'BDT')).to eql('BDT ৳30,000')
76
+ expect(MoneyHelper.money_to_text(30_000, 'BRL')).to eql('BRL R$30.000')
77
+ expect(MoneyHelper.money_to_text(30_000, 'GMD')).to eql('GMD D30,000')
78
+ expect(MoneyHelper.money_to_text(30_000, 'GEL')).to eql('GEL ლ30,000')
79
+ expect(MoneyHelper.money_to_text(30_000, 'GHS')).to eql('GHS ₵30,000')
80
+ expect(MoneyHelper.money_to_text(30_000, 'GTQ')).to eql('GTQ Q30,000')
81
+ expect(MoneyHelper.money_to_text(30_000, 'HTG')).to eql('HTG G30,000')
82
+ expect(MoneyHelper.money_to_text(30_000, 'IDR')).to eql('IDR Rp30.000')
83
+ expect(MoneyHelper.money_to_text(30_000, 'ILS')).to eql('ILS ₪30,000')
84
+ expect(MoneyHelper.money_to_text(30_000, 'INR')).to eql('INR ₹30,000')
85
+ expect(MoneyHelper.money_to_text(30_000, 'KHR')).to eql('KHR ៛30,000')
86
+ expect(MoneyHelper.money_to_text(30_000, 'KPW')).to eql('KPW ₩30,000')
87
+ expect(MoneyHelper.money_to_text(30_000, 'LAK')).to eql('LAK ₭30,000')
88
+ expect(MoneyHelper.money_to_text(30_000, 'MNT')).to eql('MNT ₮30,000')
89
+ expect(MoneyHelper.money_to_text(30_000, 'NIO')).to eql('NIO C$30,000')
90
+ expect(MoneyHelper.money_to_text(30_000, 'NGN')).to eql('NGN ₦30,000')
91
+ expect(MoneyHelper.money_to_text(30_000, 'PGK')).to eql('PGK K30,000')
92
+ expect(MoneyHelper.money_to_text(30_000, 'PHP')).to eql('PHP ₱30,000')
93
+ expect(MoneyHelper.money_to_text(30_000, 'PYG')).to eql('PYG ₲30,000')
94
+ expect(MoneyHelper.money_to_text(30_000, 'RUB')).to eql('RUB ₽30.000')
95
+ expect(MoneyHelper.money_to_text(30_000, 'THB')).to eql('THB ฿30,000')
96
+ expect(MoneyHelper.money_to_text(30_000, 'TOP')).to eql('TOP T$30,000')
97
+ expect(MoneyHelper.money_to_text(30_000, 'TMT')).to eql('TMT T30,000')
98
+ expect(MoneyHelper.money_to_text(30_000, 'UAH')).to eql('UAH ₴30,000')
99
+ expect(MoneyHelper.money_to_text(30_000, 'VND')).to eql('VND ₫30.000')
100
+ expect(MoneyHelper.money_to_text(30_000, 'WST')).to eql('WST T30,000')
101
+ expect(MoneyHelper.money_to_text(30_000, 'ZAR')).to eql('ZAR R30,000')
104
102
  end
105
103
  it "includes only ISO code for currencies that don't have a symbol" do
106
- expect(MoneyHelper.money_to_text(30000, "UZS")).to eql("UZS 30,000")
107
- end
108
- it "includes only ISO code for RTL symbols" do
109
- expect(MoneyHelper.money_to_text(30000, "AFN")).to eql("AFN 30,000")
110
- expect(MoneyHelper.money_to_text(30000, "DZD")).to eql("DZD 30,000")
111
- expect(MoneyHelper.money_to_text(30000, "BHD")).to eql("BHD 30,000")
112
- expect(MoneyHelper.money_to_text(30000, "EGP")).to eql("EGP 30,000")
113
- expect(MoneyHelper.money_to_text(30000, "IRR")).to eql("IRR 30,000")
114
- expect(MoneyHelper.money_to_text(30000, "IQD")).to eql("IQD 30,000")
115
- expect(MoneyHelper.money_to_text(30000, "JOD")).to eql("JOD 30,000")
116
- expect(MoneyHelper.money_to_text(30000, "KWD")).to eql("KWD 30,000")
117
- expect(MoneyHelper.money_to_text(30000, "LBP")).to eql("LBP 30,000")
118
- expect(MoneyHelper.money_to_text(30000, "LYD")).to eql("LYD 30,000")
119
- expect(MoneyHelper.money_to_text(30000, "MAD")).to eql("MAD 30,000")
120
- expect(MoneyHelper.money_to_text(30000, "OMR")).to eql("OMR 30,000")
121
- expect(MoneyHelper.money_to_text(30000, "JOD")).to eql("JOD 30,000")
122
- expect(MoneyHelper.money_to_text(30000, "QAR")).to eql("QAR 30,000")
123
- expect(MoneyHelper.money_to_text(30000, "SAR")).to eql("SAR 30,000")
124
- expect(MoneyHelper.money_to_text(30000, "SYP")).to eql("SYP 30,000")
125
- expect(MoneyHelper.money_to_text(30000, "TND")).to eql("TND 30,000")
126
- expect(MoneyHelper.money_to_text(30000, "AED")).to eql("AED 30,000")
127
- expect(MoneyHelper.money_to_text(30000, "YER")).to eql("YER 30,000")
128
- end
129
- it "defaults to USD when an empty string or nil is passed as the currency" do
130
- expect(MoneyHelper.money_to_text(30000, "")).to eql("$30,000")
131
- expect(MoneyHelper.money_to_text(30000, nil)).to eql("$30,000")
132
- end
133
- it "returns only the formatted numeral when number_only = true" do
134
- expect(MoneyHelper.money_to_text(30000, "EUR", true)).to eql("30.000")
135
- expect(MoneyHelper.money_to_text(30000, "AUD", true)).to eql("30,000")
136
- expect(MoneyHelper.money_to_text(30000, "AMD", true)).to eql("30,000")
137
- expect(MoneyHelper.money_to_text(30000, "AFN", true)).to eql("30,000")
138
- end
139
- it "returns nil if amount passed in is whitespace, empty string, or nil" do
140
- expect(MoneyHelper.money_to_text(" ", "USD")).to be_nil
141
- expect(MoneyHelper.money_to_text("", "USD")).to be_nil
142
- expect(MoneyHelper.money_to_text(nil, "USD")).to be_nil
104
+ expect(MoneyHelper.money_to_text(30_000, 'UZS')).to eql('UZS 30,000')
105
+ end
106
+ it 'includes only ISO code for RTL symbols' do
107
+ expect(MoneyHelper.money_to_text(30_000, 'AFN')).to eql('AFN 30,000')
108
+ expect(MoneyHelper.money_to_text(30_000, 'DZD')).to eql('DZD 30,000')
109
+ expect(MoneyHelper.money_to_text(30_000, 'BHD')).to eql('BHD 30,000')
110
+ expect(MoneyHelper.money_to_text(30_000, 'EGP')).to eql('EGP 30,000')
111
+ expect(MoneyHelper.money_to_text(30_000, 'IRR')).to eql('IRR 30,000')
112
+ expect(MoneyHelper.money_to_text(30_000, 'IQD')).to eql('IQD 30,000')
113
+ expect(MoneyHelper.money_to_text(30_000, 'JOD')).to eql('JOD 30,000')
114
+ expect(MoneyHelper.money_to_text(30_000, 'KWD')).to eql('KWD 30,000')
115
+ expect(MoneyHelper.money_to_text(30_000, 'LBP')).to eql('LBP 30,000')
116
+ expect(MoneyHelper.money_to_text(30_000, 'LYD')).to eql('LYD 30,000')
117
+ expect(MoneyHelper.money_to_text(30_000, 'MAD')).to eql('MAD 30,000')
118
+ expect(MoneyHelper.money_to_text(30_000, 'OMR')).to eql('OMR 30,000')
119
+ expect(MoneyHelper.money_to_text(30_000, 'JOD')).to eql('JOD 30,000')
120
+ expect(MoneyHelper.money_to_text(30_000, 'QAR')).to eql('QAR 30,000')
121
+ expect(MoneyHelper.money_to_text(30_000, 'SAR')).to eql('SAR 30,000')
122
+ expect(MoneyHelper.money_to_text(30_000, 'SYP')).to eql('SYP 30,000')
123
+ expect(MoneyHelper.money_to_text(30_000, 'TND')).to eql('TND 30,000')
124
+ expect(MoneyHelper.money_to_text(30_000, 'AED')).to eql('AED 30,000')
125
+ expect(MoneyHelper.money_to_text(30_000, 'YER')).to eql('YER 30,000')
126
+ end
127
+ it 'defaults to USD when an empty string or nil is passed as the currency' do
128
+ expect(MoneyHelper.money_to_text(30_000, '')).to eql('$30,000')
129
+ expect(MoneyHelper.money_to_text(30_000, nil)).to eql('$30,000')
130
+ end
131
+ it 'returns only the formatted numeral when number_only = true' do
132
+ expect(MoneyHelper.money_to_text(30_000, 'EUR', true)).to eql('30.000')
133
+ expect(MoneyHelper.money_to_text(30_000, 'AUD', true)).to eql('30,000')
134
+ expect(MoneyHelper.money_to_text(30_000, 'AMD', true)).to eql('30,000')
135
+ expect(MoneyHelper.money_to_text(30_000, 'AFN', true)).to eql('30,000')
136
+ end
137
+ it 'returns nil if amount passed in is whitespace, empty string, or nil' do
138
+ expect(MoneyHelper.money_to_text(' ', 'USD')).to be_nil
139
+ expect(MoneyHelper.money_to_text('', 'USD')).to be_nil
140
+ expect(MoneyHelper.money_to_text(nil, 'USD')).to be_nil
143
141
  end
144
142
  it "falls back to ISO code when currency can't be found" do
145
- expect(MoneyHelper.money_to_text(10_000, "ITL")).to eql("ITL 10,000")
146
- expect(MoneyHelper.money_to_text(10_000, "ITL", true)).to eql("10,000")
143
+ expect(MoneyHelper.money_to_text(10_000, 'ITL')).to eql('ITL 10,000')
144
+ expect(MoneyHelper.money_to_text(10_000, 'ITL', true)).to eql('10,000')
147
145
  end
148
146
  it 'allows options to be passed through and cents displayed' do
149
147
  expect(MoneyHelper.money_to_text(10_000.1, 'USD', nil, no_cents: false)).to eq '$10,000.10'
@@ -152,59 +150,59 @@ describe MoneyHelper do
152
150
  end
153
151
  describe 'symbol_with_optional_iso_code' do
154
152
  it 'just includes the symbol for USD GBP EUR and MYR' do
155
- expect(MoneyHelper.symbol_with_optional_iso_code("EUR")).to eql("")
156
- expect(MoneyHelper.symbol_with_optional_iso_code("GBP")).to eql("£")
157
- expect(MoneyHelper.symbol_with_optional_iso_code("MYR")).to eql("RM")
158
- expect(MoneyHelper.symbol_with_optional_iso_code("USD")).to eql("$")
153
+ expect(MoneyHelper.symbol_with_optional_iso_code('EUR')).to eql('')
154
+ expect(MoneyHelper.symbol_with_optional_iso_code('GBP')).to eql('£')
155
+ expect(MoneyHelper.symbol_with_optional_iso_code('MYR')).to eql('RM')
156
+ expect(MoneyHelper.symbol_with_optional_iso_code('USD')).to eql('$')
159
157
  end
160
158
  it 'includes the iso code as well for other currencies' do
161
- expect(MoneyHelper.symbol_with_optional_iso_code("AUD")).to eql("AUD $")
162
- expect(MoneyHelper.symbol_with_optional_iso_code("UZS")).to eql("UZS")
163
- expect(MoneyHelper.symbol_with_optional_iso_code("JPY")).to eql("JPY ¥")
159
+ expect(MoneyHelper.symbol_with_optional_iso_code('AUD')).to eql('AUD $')
160
+ expect(MoneyHelper.symbol_with_optional_iso_code('UZS')).to eql('UZS')
161
+ expect(MoneyHelper.symbol_with_optional_iso_code('JPY')).to eql('JPY ¥')
164
162
  end
165
163
  end
166
- describe "money_range_to_text" do
167
- it "includes no indicator for currency for the upper amount in range" do
168
- expect(MoneyHelper.money_range_to_text(30000, 40000, "USD")).to eql("$30,000 - 40,000")
169
- expect(MoneyHelper.money_range_to_text(30000, 40000, "AUD")).to eql("AUD $30,000 - 40,000")
170
- expect(MoneyHelper.money_range_to_text(30000, 40000, "AMD")).to eql("AMD դր.30,000 - 40,000")
171
- expect(MoneyHelper.money_range_to_text(30000, 40000, "AFN")).to eql("AFN 30,000 - 40,000")
172
- end
173
- it "uses the special range amount delimeter when supplied" do
174
- expect(MoneyHelper.money_range_to_text(30000, 40000, "USD", "-")).to eql("$30,000-40,000")
175
- expect(MoneyHelper.money_range_to_text(30000, 40000, "AUD", "-")).to eql("AUD $30,000-40,000")
176
- expect(MoneyHelper.money_range_to_text(30000, 40000, "AMD", "-")).to eql("AMD դր.30,000-40,000")
177
- expect(MoneyHelper.money_range_to_text(30000, 40000, "AFN", "-")).to eql("AFN 30,000-40,000")
164
+ describe 'money_range_to_text' do
165
+ it 'includes no indicator for currency for the upper amount in range' do
166
+ expect(MoneyHelper.money_range_to_text(30_000, 40_000, 'USD')).to eql('$30,000 - 40,000')
167
+ expect(MoneyHelper.money_range_to_text(30_000, 40_000, 'AUD')).to eql('AUD $30,000 - 40,000')
168
+ expect(MoneyHelper.money_range_to_text(30_000, 40_000, 'AMD')).to eql('AMD դր.30,000 - 40,000')
169
+ expect(MoneyHelper.money_range_to_text(30_000, 40_000, 'AFN')).to eql('AFN 30,000 - 40,000')
170
+ end
171
+ it 'uses the special range amount delimeter when supplied' do
172
+ expect(MoneyHelper.money_range_to_text(30_000, 40_000, 'USD', '-')).to eql('$30,000-40,000')
173
+ expect(MoneyHelper.money_range_to_text(30_000, 40_000, 'AUD', '-')).to eql('AUD $30,000-40,000')
174
+ expect(MoneyHelper.money_range_to_text(30_000, 40_000, 'AMD', '-')).to eql('AMD դր.30,000-40,000')
175
+ expect(MoneyHelper.money_range_to_text(30_000, 40_000, 'AFN', '-')).to eql('AFN 30,000-40,000')
178
176
  end
179
177
  it "prefixes the text 'Under ' when low amount not given" do
180
- expect(MoneyHelper.money_range_to_text(nil, 40000, "USD")).to eql("Under $40,000")
178
+ expect(MoneyHelper.money_range_to_text(nil, 40_000, 'USD')).to eql('Under $40,000')
181
179
  end
182
180
  it "appends the text ' and up' when high amount not given" do
183
- expect(MoneyHelper.money_range_to_text(30000, nil, "USD")).to eql("$30,000 and up")
181
+ expect(MoneyHelper.money_range_to_text(30_000, nil, 'USD')).to eql('$30,000 and up')
184
182
  end
185
- it "treats as a single price when low amount and high amount are identical" do
186
- expect(MoneyHelper.money_range_to_text(30000, 30000, "USD")).to eql("$30,000")
183
+ it 'treats as a single price when low amount and high amount are identical' do
184
+ expect(MoneyHelper.money_range_to_text(30_000, 30_000, 'USD')).to eql('$30,000')
187
185
  end
188
- it "returns nil when both amounts are nil" do
189
- expect(MoneyHelper.money_range_to_text(nil, nil, "USD")).to be_nil
186
+ it 'returns nil when both amounts are nil' do
187
+ expect(MoneyHelper.money_range_to_text(nil, nil, 'USD')).to be_nil
190
188
  end
191
189
  it "falls back to ISO code when currency can't be found" do
192
- expect(MoneyHelper.money_range_to_text(10_000, 20_000, "ITL")).to eql("ITL 10,000 - 20,000")
190
+ expect(MoneyHelper.money_range_to_text(10_000, 20_000, 'ITL')).to eql('ITL 10,000 - 20,000')
193
191
  end
194
192
  end
195
- describe "symbol_with_optional_iso_code" do
196
- it "returns the symbol only if currency is in SYMBOL_ONLY list" do
197
- expect(MoneyHelper.symbol_with_optional_iso_code("EUR")).to eql("")
198
- expect(MoneyHelper.symbol_with_optional_iso_code("USD")).to eql("$")
199
- end
200
- it "returns iso code and symbol if symbol is in OK_SYMBOLS" do
201
- expect(MoneyHelper.symbol_with_optional_iso_code("INR")).to eql("INR ₹")
202
- expect(MoneyHelper.symbol_with_optional_iso_code("KHR")).to eql("KHR ៛")
203
- expect(MoneyHelper.symbol_with_optional_iso_code("KPW")).to eql("KPW ₩")
204
- end
205
- it "returns only the iso code if symbol is not in OK_SYMBOLS" do
206
- expect(MoneyHelper.symbol_with_optional_iso_code("CHF")).to eql("CHF")
207
- expect(MoneyHelper.symbol_with_optional_iso_code("YER")).to eql("YER")
193
+ describe 'symbol_with_optional_iso_code' do
194
+ it 'returns the symbol only if currency is in SYMBOL_ONLY list' do
195
+ expect(MoneyHelper.symbol_with_optional_iso_code('EUR')).to eql('')
196
+ expect(MoneyHelper.symbol_with_optional_iso_code('USD')).to eql('$')
197
+ end
198
+ it 'returns iso code and symbol if symbol is in OK_SYMBOLS' do
199
+ expect(MoneyHelper.symbol_with_optional_iso_code('INR')).to eql('INR ₹')
200
+ expect(MoneyHelper.symbol_with_optional_iso_code('KHR')).to eql('KHR ៛')
201
+ expect(MoneyHelper.symbol_with_optional_iso_code('KPW')).to eql('KPW ₩')
202
+ end
203
+ it 'returns only the iso code if symbol is not in OK_SYMBOLS' do
204
+ expect(MoneyHelper.symbol_with_optional_iso_code('CHF')).to eql('CHF')
205
+ expect(MoneyHelper.symbol_with_optional_iso_code('YER')).to eql('YER')
208
206
  end
209
207
  end
210
208
  end
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..'))
2
+
3
+ require 'rubygems'
4
+ require 'rspec'
5
+
6
+ require 'money_helper'
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe MoneyHelper do
4
+ it 'has a version' do
5
+ expect(MoneyHelper::VERSION).to_not be nil
6
+ end
7
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sahil Yakhmi
@@ -11,59 +11,95 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-03-07 00:00:00.000000000 Z
14
+ date: 2019-04-19 00:00:00.000000000 Z
15
15
  dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activesupport
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
16
30
  - !ruby/object:Gem::Dependency
17
31
  name: money
18
32
  requirement: !ruby/object:Gem::Requirement
19
33
  requirements:
20
- - - ~>
34
+ - - "~>"
21
35
  - !ruby/object:Gem::Version
22
36
  version: '6.5'
23
37
  type: :runtime
24
38
  prerelease: false
25
39
  version_requirements: !ruby/object:Gem::Requirement
26
40
  requirements:
27
- - - ~>
41
+ - - "~>"
28
42
  - !ruby/object:Gem::Version
29
43
  version: '6.5'
30
44
  - !ruby/object:Gem::Dependency
31
- name: activesupport
45
+ name: appraisal
32
46
  requirement: !ruby/object:Gem::Requirement
33
47
  requirements:
34
- - - '>='
48
+ - - ">="
35
49
  - !ruby/object:Gem::Version
36
50
  version: '0'
37
- type: :runtime
51
+ type: :development
38
52
  prerelease: false
39
53
  version_requirements: !ruby/object:Gem::Requirement
40
54
  requirements:
41
- - - '>='
55
+ - - ">="
42
56
  - !ruby/object:Gem::Version
43
57
  version: '0'
44
58
  - !ruby/object:Gem::Dependency
45
59
  name: rspec
46
60
  requirement: !ruby/object:Gem::Requirement
47
61
  requirements:
48
- - - ~>
62
+ - - "~>"
49
63
  - !ruby/object:Gem::Version
50
64
  version: '3'
51
65
  type: :development
52
66
  prerelease: false
53
67
  version_requirements: !ruby/object:Gem::Requirement
54
68
  requirements:
55
- - - ~>
69
+ - - "~>"
56
70
  - !ruby/object:Gem::Version
57
71
  version: '3'
58
72
  description: A simple module to assist in formatting unambiguous prices and price
59
73
  ranges in international currencies in a Roman Script context.
60
- email: matt@artsymail.net
74
+ email: matt@artsymail.com
61
75
  executables: []
62
76
  extensions: []
63
77
  extra_rdoc_files: []
64
78
  files:
79
+ - ".gitignore"
80
+ - ".rubocop.yml"
81
+ - ".rubocop_todo.yml"
82
+ - ".travis.yml"
83
+ - Appraisals
84
+ - CHANGELOG.md
85
+ - Gemfile
86
+ - LICENSE.md
87
+ - README.md
88
+ - RELEASING.md
89
+ - Rakefile
90
+ - gemfiles/activesupport_40.gemfile
91
+ - gemfiles/activesupport_41.gemfile
92
+ - gemfiles/activesupport_42.gemfile
93
+ - gemfiles/activesupport_50.gemfile
94
+ - gemfiles/activesupport_51.gemfile
95
+ - gemfiles/activesupport_52.gemfile
96
+ - gemfiles/activesupport_edge.gemfile
65
97
  - lib/money_helper.rb
98
+ - lib/version.rb
99
+ - money_helper.gemspec
66
100
  - spec/money_helper_spec.rb
101
+ - spec/spec_helper.rb
102
+ - spec/version_spec.rb
67
103
  homepage: https://github.com/artsy/money_helper
68
104
  licenses:
69
105
  - MIT
@@ -74,20 +110,20 @@ require_paths:
74
110
  - lib
75
111
  required_ruby_version: !ruby/object:Gem::Requirement
76
112
  requirements:
77
- - - '>='
113
+ - - ">="
78
114
  - !ruby/object:Gem::Version
79
115
  version: '0'
80
116
  required_rubygems_version: !ruby/object:Gem::Requirement
81
117
  requirements:
82
- - - '>='
118
+ - - ">="
83
119
  - !ruby/object:Gem::Version
84
- version: '0'
120
+ version: 1.3.6
85
121
  requirements: []
86
- rubyforge_project:
87
- rubygems_version: 2.4.6
122
+ rubygems_version: 3.0.3
88
123
  signing_key:
89
124
  specification_version: 4
90
- summary: MoneyHelper international price formatting utility
125
+ summary: MoneyHelper international price formatting utility.
91
126
  test_files:
92
127
  - spec/money_helper_spec.rb
93
- has_rdoc:
128
+ - spec/spec_helper.rb
129
+ - spec/version_spec.rb