westarete-activerecord_null_object 0.0.0 → 0.0.1
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.
- data/VERSION +1 -1
- data/activerecord_null_object.gemspec +54 -0
- data/lib/null_object.rb +4 -0
- data/spec/belongs_to_spec.rb +16 -0
- data/spec/null_object_spec.rb +12 -0
- metadata +3 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.1
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{activerecord_null_object}
|
5
|
+
s.version = "0.0.1"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Scott Woods"]
|
9
|
+
s.date = %q{2009-08-15}
|
10
|
+
s.description = %q{}
|
11
|
+
s.email = %q{info@westarete.com}
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"README"
|
14
|
+
]
|
15
|
+
s.files = [
|
16
|
+
".gitignore",
|
17
|
+
"MIT-LICENSE",
|
18
|
+
"README",
|
19
|
+
"Rakefile",
|
20
|
+
"VERSION",
|
21
|
+
"activerecord_null_object.gemspec",
|
22
|
+
"init.rb",
|
23
|
+
"lib/activerecord_null_object.rb",
|
24
|
+
"lib/null_object.rb",
|
25
|
+
"spec/belongs_to_spec.rb",
|
26
|
+
"spec/database.yml",
|
27
|
+
"spec/null_object_spec.rb",
|
28
|
+
"spec/schema.rb",
|
29
|
+
"spec/spec.opts",
|
30
|
+
"spec/spec_helper.rb"
|
31
|
+
]
|
32
|
+
s.has_rdoc = true
|
33
|
+
s.homepage = %q{http://github.com/westarete/activerecord_null_object/}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.1}
|
37
|
+
s.summary = %q{Implements the Null Object Pattern for nil values in ActiveRecord associations.}
|
38
|
+
s.test_files = [
|
39
|
+
"spec/belongs_to_spec.rb",
|
40
|
+
"spec/null_object_spec.rb",
|
41
|
+
"spec/schema.rb",
|
42
|
+
"spec/spec_helper.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 2
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
+
else
|
51
|
+
end
|
52
|
+
else
|
53
|
+
end
|
54
|
+
end
|
data/lib/null_object.rb
CHANGED
data/spec/belongs_to_spec.rb
CHANGED
@@ -18,6 +18,14 @@ describe Comment do
|
|
18
18
|
@comment.author.should be_nil
|
19
19
|
end
|
20
20
|
|
21
|
+
it "should return true for comment.author.nil?" do
|
22
|
+
@comment.author.nil?.should be_true
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return false for comment.author.present?" do
|
26
|
+
@comment.author.present?.should be_false
|
27
|
+
end
|
28
|
+
|
21
29
|
it "should return nil for the author's name" do
|
22
30
|
@comment.author.name.should be_nil
|
23
31
|
end
|
@@ -33,6 +41,14 @@ describe Comment do
|
|
33
41
|
@comment.author.kind_of?(NullAuthor).should_not be_true
|
34
42
|
end
|
35
43
|
|
44
|
+
it "should return false for comment.author.nil?" do
|
45
|
+
@comment.author.nil?.should be_false
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should return true for comment.author.present?" do
|
49
|
+
@comment.author.present?.should be_true
|
50
|
+
end
|
51
|
+
|
36
52
|
it "should return the author's name" do
|
37
53
|
@comment.author.name.should == 'James Baker'
|
38
54
|
end
|
data/spec/null_object_spec.rb
CHANGED
@@ -18,6 +18,18 @@ describe NullAuthor do
|
|
18
18
|
@null_author.nil?.should be_true
|
19
19
|
@null_author.should be_nil
|
20
20
|
end
|
21
|
+
|
22
|
+
it "should be empty" do
|
23
|
+
@null_author.empty?.should be_true
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should be blank" do
|
27
|
+
@null_author.blank?.should be_true
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should not be present" do
|
31
|
+
@null_author.present?.should be_false
|
32
|
+
end
|
21
33
|
|
22
34
|
describe "#id" do
|
23
35
|
it "should return nil" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: westarete-activerecord_null_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Woods
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-15 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -27,6 +27,7 @@ files:
|
|
27
27
|
- README
|
28
28
|
- Rakefile
|
29
29
|
- VERSION
|
30
|
+
- activerecord_null_object.gemspec
|
30
31
|
- init.rb
|
31
32
|
- lib/activerecord_null_object.rb
|
32
33
|
- lib/null_object.rb
|