bigrecord 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,10 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
- require File.expand_path(File.join(File.dirname(__FILE__), 'abstract_base_spec'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), 'attributes_spec'))
3
3
 
4
4
  describe BigRecord::Base do
5
5
  it_should_behave_like "BigRecord::AbstractBase"
6
6
 
7
- describe '#columns' do
7
+ describe 'column functionality' do
8
8
 
9
9
  before(:all) do
10
10
  # Grab the columns from a simple BigRecord model
@@ -1,5 +1,5 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
- require File.expand_path(File.join(File.dirname(__FILE__), 'abstract_base_spec'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), 'attributes_spec'))
3
3
 
4
4
  describe BigRecord::Embedded do
5
5
 
@@ -29,6 +29,16 @@ describe BigRecord::Base do
29
29
  Zoo.find(id).should == [zoo]
30
30
  end
31
31
 
32
+ it "should be invoked when #all and #first are called" do
33
+ zoo = Zoo.new
34
+
35
+ Zoo.should_receive(:find).with(:all).and_return([zoo])
36
+ Zoo.all.should == [zoo]
37
+
38
+ Zoo.should_receive(:find).with(:first).and_return(zoo)
39
+ Zoo.first.should == zoo
40
+ end
41
+
32
42
  end
33
43
 
34
44
  end
@@ -76,11 +76,11 @@ describe BigRecord::Base do
76
76
  Book.new.should respond_to(:save!)
77
77
  end
78
78
 
79
- describe '.save and .save!' do
79
+ describe 'save and delete functionality' do
80
80
 
81
81
  describe 'with a new resource' do
82
82
 
83
- it 'should create new entries in the data store' do
83
+ it 'should create new entries in the data store and delete them' do
84
84
  # Create a new object
85
85
  book = Book.new( :title => "I Am Legend",
86
86
  :author => "Richard Matheson",
@@ -99,6 +99,15 @@ describe BigRecord::Base do
99
99
  book2.title.should == "I Am Legend"
100
100
  book2.author.should == "Richard Matheson"
101
101
  book2.description.should == "The most clever and riveting vampire novel since Dracula."
102
+
103
+ # Verify that we can destroy this
104
+ lambda {
105
+ book2.destroy
106
+ }.should_not raise_error
107
+
108
+ lambda {
109
+ verify_delete = Book.find(book.id)
110
+ }.should raise_error
102
111
  end
103
112
 
104
113
  it 'should raise an exception with .save! if a record was not saved or true if successful' do
@@ -188,7 +197,7 @@ describe BigRecord::Base do
188
197
 
189
198
  end
190
199
 
191
- describe 'attribute functionality' do
200
+ describe 'attribute functionality on records' do
192
201
 
193
202
  it "should return a list of attribute names with .attribute_names" do
194
203
  (Book.new.attribute_names & ["attribute:author", "attribute:description", "attribute:links", "attribute:title"]).should == ["attribute:author", "attribute:description", "attribute:links", "attribute:title"]
@@ -250,7 +259,7 @@ describe BigRecord::Base do
250
259
  book.save.should be_true
251
260
 
252
261
  book.update_attribute(:description, "One of the Ten All-Time Best Novels of Vampirism.")
253
-
262
+ book.reload
254
263
  book.description.should == "One of the Ten All-Time Best Novels of Vampirism."
255
264
  end
256
265
 
@@ -0,0 +1,44 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'spec_helper'))
2
+
3
+ describe BigRecord::Base do
4
+
5
+ before(:all) do
6
+ Book.delete_all
7
+ @titles = ["I Am Legend", "The Beach", "Neuromancer"]
8
+ id1 = Book.create(:title => @titles[0], :author => "Richard Matheson").id
9
+ id2 = Book.create(:title => @titles[1], :author => "Alex Garland").id
10
+ id3 = Book.create(:title => @titles[2], :author => "William Gibson").id
11
+ @ids = [id1, id2, id3]
12
+ end
13
+
14
+ after(:all) do
15
+ Book.delete_all
16
+ end
17
+
18
+ describe "scanner functionality" do
19
+
20
+ it "should retrieve all records with find" do
21
+ books = Book.find(:all)
22
+ books.size.should == 3
23
+
24
+ @titles.each do |title|
25
+ books.map(&:title).should include(title)
26
+ end
27
+
28
+ @ids.each do |id|
29
+ books.map(&:id).should include(id)
30
+ end
31
+ end
32
+
33
+ it "should retrieve all record with scan" do
34
+ count = 0
35
+ Book.scan do |book|
36
+ count += 1
37
+ @titles.include?(book.title).should be_true
38
+ end
39
+ count.should == 3
40
+ end
41
+
42
+ end
43
+
44
+ end
data/tasks/gem.rb CHANGED
@@ -13,7 +13,6 @@ begin
13
13
 
14
14
  gemspec.add_development_dependency "rspec"
15
15
  gemspec.add_dependency "uuidtools", ">= 2.0.0"
16
- gemspec.add_dependency "bigrecord-driver"
17
16
  gemspec.add_dependency "activesupport"
18
17
  gemspec.add_dependency "activerecord"
19
18
  end
data/tasks/rdoc.rb CHANGED
@@ -8,7 +8,7 @@ begin
8
8
  end
9
9
 
10
10
  desc 'Generate documentation for BigRecord.'
11
- task :rdoc => :yardoc
11
+ task :rdoc => :yard
12
12
  rescue LoadError
13
13
  puts "yard not available. Install it with: sudo gem install yard"
14
14
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigrecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - openplaces.org
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-25 00:00:00 -05:00
12
+ date: 2009-12-01 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -32,16 +32,6 @@ dependencies:
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.0.0
34
34
  version:
35
- - !ruby/object:Gem::Dependency
36
- name: bigrecord-driver
37
- type: :runtime
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- version: "0"
44
- version:
45
35
  - !ruby/object:Gem::Dependency
46
36
  name: activesupport
47
37
  type: :runtime
@@ -161,18 +151,20 @@ files:
161
151
  - spec/lib/zoo.rb
162
152
  - spec/spec.opts
163
153
  - spec/spec_helper.rb
164
- - spec/unit/abstract_base_spec.rb
165
154
  - spec/unit/adapters/abstract_adapter_spec.rb
166
155
  - spec/unit/adapters/adapter_shared_spec.rb
167
156
  - spec/unit/adapters/hbase_adapter_spec.rb
168
157
  - spec/unit/ar_associations_spec.rb
169
- - spec/unit/base_spec.rb
158
+ - spec/unit/attributes_spec.rb
170
159
  - spec/unit/br_associations_spec.rb
160
+ - spec/unit/callback_spec.rb
161
+ - spec/unit/columns_spec.rb
171
162
  - spec/unit/embedded_spec.rb
172
163
  - spec/unit/find_spec.rb
173
164
  - spec/unit/hash_helper_spec.rb
174
165
  - spec/unit/migration_spec.rb
175
166
  - spec/unit/model_spec.rb
167
+ - spec/unit/scanner_spec.rb
176
168
  - spec/unit/validations_spec.rb
177
169
  - tasks/bigrecord_tasks.rake
178
170
  - tasks/data_store.rb