attr_symbol 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,8 +10,8 @@ begin
10
10
  gem.email = "jwinky+gems@gmail.com"
11
11
  gem.homepage = "http://github.com/jwinky/attr_symbol"
12
12
  gem.authors = ["Justin Wienckowski"]
13
- gem.add_development_dependency "shoulda", ">= 0"
14
- gem.add_development_dependency "activerecord", ">= 0"
13
+ gem.add_development_dependency "shoulda", ">= 2.11.3"
14
+ gem.add_dependency "activerecord", ">= 2.3.5"
15
15
  end
16
16
  Jeweler::GemcutterTasks.new
17
17
  rescue LoadError
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/attr_symbol.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{attr_symbol}
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Justin Wienckowski"]
@@ -42,15 +42,15 @@ Gem::Specification.new do |s|
42
42
  s.specification_version = 3
43
43
 
44
44
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
- s.add_development_dependency(%q<shoulda>, [">= 0"])
46
- s.add_development_dependency(%q<activerecord>, [">= 0"])
45
+ s.add_development_dependency(%q<shoulda>, [">= 2.11.3"])
46
+ s.add_runtime_dependency(%q<activerecord>, [">= 2.3.5"])
47
47
  else
48
- s.add_dependency(%q<shoulda>, [">= 0"])
49
- s.add_dependency(%q<activerecord>, [">= 0"])
48
+ s.add_dependency(%q<shoulda>, [">= 2.11.3"])
49
+ s.add_dependency(%q<activerecord>, [">= 2.3.5"])
50
50
  end
51
51
  else
52
- s.add_dependency(%q<shoulda>, [">= 0"])
53
- s.add_dependency(%q<activerecord>, [">= 0"])
52
+ s.add_dependency(%q<shoulda>, [">= 2.11.3"])
53
+ s.add_dependency(%q<activerecord>, [">= 2.3.5"])
54
54
  end
55
55
  end
56
56
 
data/lib/attr_symbol.rb CHANGED
@@ -17,7 +17,7 @@ module ActiveRecord::AttrSymbol
17
17
  end
18
18
 
19
19
  define_method("#{attr}=") do |value|
20
- self[attr] = value.try(:to_s)
20
+ self[attr] = value.blank? ? nil : value.try(:to_s)
21
21
  end
22
22
  end
23
23
  end
@@ -12,7 +12,7 @@ class TestAttrSymbol < Test::Unit::TestCase
12
12
  context "Setting attribute 'foo'" do
13
13
  subject { Thing.new }
14
14
 
15
- context "to a string value" do
15
+ context "to a non-blank string value" do
16
16
  setup { subject.foo = "bar" }
17
17
  should("store the string 'bar' in the attribute") do
18
18
  assert_equal "bar", subject[:foo]
@@ -32,6 +32,26 @@ class TestAttrSymbol < Test::Unit::TestCase
32
32
  end
33
33
  end
34
34
 
35
+ context "to an empty string value" do
36
+ setup { subject.foo = "" }
37
+ should("store nil in the attribute") do
38
+ assert_equal nil, subject[:foo]
39
+ end
40
+ should("return nil from the accessor") do
41
+ assert_equal nil, subject.foo
42
+ end
43
+ end
44
+
45
+ context "to a blank string value" do
46
+ setup { subject.foo = " " }
47
+ should("store nil in the attribute") do
48
+ assert_equal nil, subject[:foo]
49
+ end
50
+ should("return nil from the accessor") do
51
+ assert_equal nil, subject.foo
52
+ end
53
+ end
54
+
35
55
  context "to nil" do
36
56
  setup { subject.foo = nil }
37
57
  should("store nil in the attribute") do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attr_symbol
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 2
10
- version: 0.0.2
9
+ - 3
10
+ version: 0.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Justin Wienckowski
@@ -26,10 +26,12 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 37
30
30
  segments:
31
- - 0
32
- version: "0"
31
+ - 2
32
+ - 11
33
+ - 3
34
+ version: 2.11.3
33
35
  type: :development
34
36
  version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
@@ -40,11 +42,13 @@ dependencies:
40
42
  requirements:
41
43
  - - ">="
42
44
  - !ruby/object:Gem::Version
43
- hash: 3
45
+ hash: 9
44
46
  segments:
45
- - 0
46
- version: "0"
47
- type: :development
47
+ - 2
48
+ - 3
49
+ - 5
50
+ version: 2.3.5
51
+ type: :runtime
48
52
  version_requirements: *id002
49
53
  description: Attributes marked with the attr_symbol method can be set using strings or symbols, but when accessed will always return symbols.
50
54
  email: jwinky+gems@gmail.com