formtastic 3.1.1 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ module Formtastic
23
23
  self.deprecation = Formtastic::Deprecation.new('4.0', 'Formtastic')
24
24
 
25
25
  if defined?(::Rails) && Util.deprecated_version_of_rails?
26
- deprecation.warn("Support for Rails < 4.0.4 will be dropped ")
26
+ deprecation.warn("Support for Rails < #{Util.minimum_version_of_rails} will be dropped")
27
27
  end
28
28
 
29
29
  # @public
@@ -20,33 +20,37 @@ module Formtastic
20
20
  text
21
21
  end
22
22
  end
23
-
23
+
24
24
  def rails3?
25
- rails_version >= Gem::Version.new("3.0.0") &&
26
- rails_version < Gem::Version.new("4.0.0")
25
+ match?(rails_version, "~> 3.0")
27
26
  end
28
27
 
29
28
  def rails4?
30
- rails_version >= Gem::Version.new("4.0.0") &&
31
- rails_version < Gem::Version.new("5.0.0")
29
+ match?(rails_version, "~> 4.0")
32
30
  end
33
-
31
+
34
32
  def rails4_0?
35
- rails_version >= Gem::Version.new("4.0.0") &&
36
- rails_version < Gem::Version.new("4.1.0")
33
+ match?(rails_version, "~> 4.0.0")
37
34
  end
38
35
 
39
36
  def rails4_1?
40
- rails_version >= Gem::Version.new("4.1.0") &&
41
- rails_version < Gem::Version.new("4.2.0")
37
+ match?(rails_version, "~> 4.1.0")
42
38
  end
43
-
39
+
44
40
  def deprecated_version_of_rails?
45
- rails_version < Gem::Version.new("4.1.0")
41
+ match?(rails_version, "< #{minimum_version_of_rails}")
42
+ end
43
+
44
+ def minimum_version_of_rails
45
+ "4.1.0"
46
46
  end
47
47
 
48
48
  def rails_version
49
- Gem::Version.new(::Rails::VERSION::STRING)
49
+ ::Rails::VERSION::STRING
50
+ end
51
+
52
+ def match?(version, dependency)
53
+ Gem::Dependency.new("formtastic", dependency).match?("formtastic", version)
50
54
  end
51
55
 
52
56
  end
@@ -1,3 +1,3 @@
1
1
  module Formtastic
2
- VERSION = "3.1.1"
2
+ VERSION = "3.1.2"
3
3
  end
@@ -4,60 +4,60 @@ require 'spec_helper'
4
4
  describe 'Formtastic::Util' do
5
5
 
6
6
  describe '.deprecated_version_of_rails?' do
7
-
7
+
8
8
  subject { Formtastic::Util.deprecated_version_of_rails? }
9
-
9
+
10
10
  context '4.0.0' do
11
- before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("4.0.0") } }
11
+ before { allow(Formtastic::Util).to receive(:rails_version) { "4.0.0" } }
12
12
  it 'should be true' do
13
13
  expect(subject).to be_truthy
14
14
  end
15
15
  end
16
16
 
17
17
  context '4.0.3' do
18
- before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("4.0.3") } }
18
+ before { allow(Formtastic::Util).to receive(:rails_version) { "4.0.3" } }
19
19
  it 'should be true' do
20
20
  expect(subject).to be_truthy
21
21
  end
22
22
  end
23
23
 
24
24
  context '4.0.4' do
25
- before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("4.0.4") } }
25
+ before { allow(Formtastic::Util).to receive(:rails_version) { "4.0.4" } }
26
26
  it 'should be false' do
27
27
  expect(subject).to be_truthy
28
28
  end
29
29
  end
30
30
 
31
31
  context '4.0.5' do
32
- before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("4.0.5") } }
32
+ before { allow(Formtastic::Util).to receive(:rails_version) { "4.0.5" } }
33
33
  it 'should be false' do
34
34
  expect(subject).to be_truthy
35
35
  end
36
36
  end
37
37
 
38
38
  context '4.1.0' do
39
- before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("4.1.1") } }
39
+ before { allow(Formtastic::Util).to receive(:rails_version) { "4.1.0" } }
40
40
  it 'should be false' do
41
41
  expect(subject).to be_falsey
42
42
  end
43
43
  end
44
44
 
45
45
  context '4.1.1' do
46
- before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("4.1.1") } }
46
+ before { allow(Formtastic::Util).to receive(:rails_version) { "4.1.1" } }
47
47
  it 'should be false' do
48
48
  expect(subject).to be_falsey
49
49
  end
50
50
  end
51
51
 
52
52
  context '4.2.0' do
53
- before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("4.1.1") } }
53
+ before { allow(Formtastic::Util).to receive(:rails_version) { "4.2.0" } }
54
54
  it 'should be false' do
55
55
  expect(subject).to be_falsey
56
56
  end
57
57
  end
58
58
 
59
59
  context '5.0.0' do
60
- before { allow(Formtastic::Util).to receive(:rails_version) { Gem::Version.new("5.0.0") } }
60
+ before { allow(Formtastic::Util).to receive(:rails_version) { "5.0.0" } }
61
61
  it 'should be true' do
62
62
  expect(subject).to be_falsey
63
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formtastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.1
4
+ version: 3.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-22 00:00:00.000000000 Z
12
+ date: 2014-11-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack