currency_select 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 6b9b941851e10ef31425af48bafb08196b7389f5
4
+ data.tar.gz: 0d67fa20e92859ffcb84fff09d20f5322756fdbb
5
+ SHA512:
6
+ metadata.gz: 83a415abda8afb50de6f119596d50f2e564f5289334f4066a42d788a5b2b02985cc62a7b90c525824ec79373febb5d16e0f20a500b2bf34d09c6ecbd5a6201c8
7
+ data.tar.gz: 8e852040bf40eec82ced27f0ee9a2370d4e30e6eb5d3234e76d2dee07890a0389412a594d10485472ef5c46812fdd93f70175459db190b1cbf41e6b62bdac85c
data/Gemfile CHANGED
@@ -1,3 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'money', '~> 5.1.1'
3
+ gem 'money'
data/Gemfile.lock CHANGED
@@ -2,11 +2,11 @@ GEM
2
2
  remote: https://rubygems.org/
3
3
  specs:
4
4
  i18n (0.6.4)
5
- money (5.1.1)
5
+ money (6.0.0)
6
6
  i18n (~> 0.6.0)
7
7
 
8
8
  PLATFORMS
9
9
  ruby
10
10
 
11
11
  DEPENDENCIES
12
- money (~> 5.1.1)
12
+ money
data/README.rdoc CHANGED
@@ -5,6 +5,13 @@ a HTML select list of available currencies.
5
5
 
6
6
  The list of currencies are provided by the {Money}[http://money.rubyforge.org/] gem.
7
7
 
8
+ = Installation
9
+
10
+ Add the following to your Gemfile
11
+
12
+ gem 'currency_select', github: 'tanordheim/currency_select'
13
+
14
+
8
15
  = Example
9
16
 
10
17
  currency_select("user", "currency")
@@ -5,13 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "currency_select"
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Trond Arve Nordheim"]
12
- s.date = "2013-08-05"
12
+ s.date = "2015-01-22"
13
13
  s.description = "Adds a currency_select helper to Ruby on Rails projects"
14
14
  s.email = "tanordheim@gmail.com"
15
+ s.license = "MIT"
15
16
  s.extra_rdoc_files = [
16
17
  "LICENSE",
17
18
  "README.rdoc"
@@ -27,24 +28,26 @@ Gem::Specification.new do |s|
27
28
  "currency_select.gemspec",
28
29
  "lib/currency_select.rb",
29
30
  "rails/init.rb",
30
- "test/helper.rb",
31
- "test/test_currency_select.rb"
31
+ "spec/currency_select_spec.rb",
32
+ "spec/spec_helper.rb"
32
33
  ]
33
34
  s.homepage = "http://github.com/tanordheim/currency_select"
34
35
  s.require_paths = ["lib"]
35
36
  s.rubygems_version = "1.8.23"
36
37
  s.summary = "Currency Select plugin for Rails"
37
38
 
39
+ s.add_development_dependency 'rspec'
40
+
38
41
  if s.respond_to? :specification_version then
39
42
  s.specification_version = 3
40
43
 
41
44
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
42
- s.add_runtime_dependency(%q<money>, ["~> 5.1.1"])
45
+ s.add_runtime_dependency(%q<money>, [">= 0"])
43
46
  else
44
- s.add_dependency(%q<money>, ["~> 5.1.1"])
47
+ s.add_dependency(%q<money>, [">= 0"])
45
48
  end
46
49
  else
47
- s.add_dependency(%q<money>, ["~> 5.1.1"])
50
+ s.add_dependency(%q<money>, [">= 0"])
48
51
  end
49
52
  end
50
53
 
@@ -5,7 +5,7 @@ module CurrencySelect
5
5
 
6
6
  CURRENCIES = Money::Currency::table.inject([]) do |array, (id, currency)|
7
7
  array << [ "#{currency[:name]} - #{currency[:iso_code]}", id ]
8
- end.sort_by { |currency| currency.first.parameterize } unless const_defined?("CURRENCIES")
8
+ end.sort_by { |currency| currency.first } unless const_defined?("CURRENCIES")
9
9
 
10
10
  # Returns an array with ISO codes and currency names for <tt>option</tt>
11
11
  # tags.
@@ -0,0 +1,76 @@
1
+ require 'spec_helper'
2
+ require 'action_view'
3
+ require 'currency_select'
4
+
5
+ module ActionView
6
+ module Helpers
7
+
8
+ describe CurrencySelect do
9
+ include TagHelper
10
+
11
+ class User
12
+ attr_accessor :currency_code
13
+ end
14
+
15
+ let(:user) { User.new }
16
+ let(:template) { ActionView::Base.new }
17
+ let(:select_tag) do
18
+ "<select id=\"user_currency_code\" name=\"user[currency_code]\">"
19
+ end
20
+
21
+ let(:selected_eur_option) do
22
+ if defined?(Tags::Base)
23
+ content_tag(:option, 'Euro - EUR', selected: :selected, value: 'eur')
24
+ else
25
+ "<option value=\"eur\" selected=\"selected\">Euro - EUR</option>"
26
+ end
27
+ end
28
+
29
+ let(:builder) do
30
+ if defined?(Tags::Base)
31
+ FormBuilder.new(:user, user, template, {})
32
+ else
33
+ FormBuilder.new(:user, user, template, {}, Proc.new { })
34
+ end
35
+ end
36
+
37
+ describe "currency_select" do
38
+ let(:tag) { builder.currency_select(:currency_code) }
39
+
40
+ it "creates a select tag" do
41
+ tag.should include(select_tag)
42
+ end
43
+
44
+ it "creates option tags for each currency" do
45
+ ::CurrencySelect.currencies_array.each do |name, code|
46
+ tag.should include(content_tag(:option, name, value: code))
47
+ end
48
+ end
49
+
50
+ it "selects the value of currency_code" do
51
+ user.currency_code = 'eur'
52
+ t = builder.currency_select(:currency_code)
53
+ t.should include(selected_eur_option)
54
+ end
55
+
56
+ it "does not mark two currencies as selected" do
57
+ user.currency_code = "usd"
58
+ str = "<option value=\"us\" selected=\"selected\">United States</option>".html_safe
59
+ tag.should_not include(str)
60
+ end
61
+
62
+ describe "priority currencies" do
63
+ let(:tag) { builder.currency_select(:currency_code, ['eur']) }
64
+
65
+ it "inserts the priority currencies at the top" do
66
+ tag.should include("#{select_tag}<option value=\"eur")
67
+ end
68
+
69
+ it "inserts a divider" do
70
+ tag.should include("<option value=\"\" disabled=\"disabled\">-------------</option>")
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,7 @@
1
+ RSpec.configure do |config|
2
+ # Run specs in random order to surface order dependencies. If you find an
3
+ # order dependency and want to debug it, you can fix the order by providing
4
+ # the seed, which is printed after each run.
5
+ # --seed 1234
6
+ config.order = 'random'
7
+ end
metadata CHANGED
@@ -1,32 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: currency_select
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
5
- prerelease:
4
+ version: 0.1.5
6
5
  platform: ruby
7
6
  authors:
8
7
  - Trond Arve Nordheim
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-05 00:00:00.000000000 Z
11
+ date: 2015-01-22 00:00:00.000000000 Z
13
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
14
27
  - !ruby/object:Gem::Dependency
15
28
  name: money
16
29
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
30
  requirements:
19
- - - ~>
31
+ - - '>='
20
32
  - !ruby/object:Gem::Version
21
- version: 5.1.1
33
+ version: '0'
22
34
  type: :runtime
23
35
  prerelease: false
24
36
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
37
  requirements:
27
- - - ~>
38
+ - - '>='
28
39
  - !ruby/object:Gem::Version
29
- version: 5.1.1
40
+ version: '0'
30
41
  description: Adds a currency_select helper to Ruby on Rails projects
31
42
  email: tanordheim@gmail.com
32
43
  executables: []
@@ -45,29 +56,29 @@ files:
45
56
  - currency_select.gemspec
46
57
  - lib/currency_select.rb
47
58
  - rails/init.rb
48
- - test/helper.rb
49
- - test/test_currency_select.rb
59
+ - spec/currency_select_spec.rb
60
+ - spec/spec_helper.rb
50
61
  homepage: http://github.com/tanordheim/currency_select
51
- licenses: []
62
+ licenses:
63
+ - MIT
64
+ metadata: {}
52
65
  post_install_message:
53
66
  rdoc_options: []
54
67
  require_paths:
55
68
  - lib
56
69
  required_ruby_version: !ruby/object:Gem::Requirement
57
- none: false
58
70
  requirements:
59
- - - ! '>='
71
+ - - '>='
60
72
  - !ruby/object:Gem::Version
61
73
  version: '0'
62
74
  required_rubygems_version: !ruby/object:Gem::Requirement
63
- none: false
64
75
  requirements:
65
- - - ! '>='
76
+ - - '>='
66
77
  - !ruby/object:Gem::Version
67
78
  version: '0'
68
79
  requirements: []
69
80
  rubyforge_project:
70
- rubygems_version: 1.8.23
81
+ rubygems_version: 2.0.14
71
82
  signing_key:
72
83
  specification_version: 3
73
84
  summary: Currency Select plugin for Rails
data/test/helper.rb DELETED
@@ -1,10 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
-
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- $LOAD_PATH.unshift(File.dirname(__FILE__))
7
- require 'currency_select'
8
-
9
- class Test::Unit::TestCase
10
- end
@@ -1,7 +0,0 @@
1
- require 'helper'
2
-
3
- class TestCurrencySelect < Test::Unit::TestCase
4
- should "probably rename this file and start testing for real" do
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end