Skip to content

Commit

Permalink
test for empty default
Browse files Browse the repository at this point in the history
  • Loading branch information
funny-falcon committed Jul 21, 2012
1 parent 910c699 commit 0c38c7c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 29 deletions.
33 changes: 6 additions & 27 deletions Rakefile
@@ -1,17 +1,17 @@
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'

#desc 'Default: run unit tests.'
#task :default => :test
require 'rdoc/task'

desc 'Test the postgres_arrays plugin.'
Rake::TestTask.new(:test) do |t|
task :test do
Dir.chdir(File.dirname(__FILE__)) do
Process.wait2 spawn('rspec spec')
end
end

task :default do
# nothing
end

desc 'Generate documentation for the postgres_arrays plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
Expand All @@ -20,24 +20,3 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_files.include('README')
rdoc.rdoc_files.include('lib/**/*.rb')
end

begin
require 'jeweler'
Jeweler::Tasks.new do |gemspec|
gemspec.name = "ar_pg_array"
gemspec.summary = "Use power of PostgreSQL Arrays in ActiveRecord"
gemspec.description = "ar_pg_array includes support of PostgreSQL's int[], float[], text[], timestamptz[] etc. into ActiveRecord. You could define migrations for array columns, query on array columns."
gemspec.email = "funny.falcon@gmail.com"
gemspec.homepage = "http://github.com/funny-falcon/activerecord-postgresql-arrays"
gemspec.authors = ["Sokolov Yura aka funny_falcon"]
gemspec.add_dependency('activerecord', '>= 3.0.6', '<4.0')
gemspec.rubyforge_project = 'ar-pg-array'
end
Jeweler::GemcutterTasks.new
Jeweler::RubyforgeTasks.new do |rubyforge|

end
rescue LoadError
puts "Jeweler not available. Install it with: gem install jeweler"
end

1 change: 1 addition & 0 deletions spec/fixtures/schema.rb
Expand Up @@ -20,6 +20,7 @@
t.float_array :floats, :default => [1.0, 1.2]
t.decimal_array :decimals, :default => [1.0, 1.2]
t.text_array :texts, :default => [nil, 'Text', 'NULL', 'Text with nil', 'Text with , nil, !"\\', 'nil']
t.integer_array :empty_def, :default => []
end

create_table "unrelateds", :force => true do |t|
Expand Down
14 changes: 12 additions & 2 deletions spec/pg_array_spec.rb
Expand Up @@ -82,11 +82,21 @@ def ab
bulk.texts.should == [nil, 'Text', 'NULL', 'Text with nil', 'Text with , nil, !"\\', 'nil']
map_times(bulk.times).should ==
map_times(parse_times(%w{2010-01-01 2010-02-01}))
bulk.empty_def.should == []
end

it "should be able to insert" do
bulk = Bulk.new
bulk.save
bulki = Bulk.new
bulki.save
bulk = Bulk.find(bulki.id)
bulk.ints.should == [1, 2]
bulk.strings.should == %w{as so}
bulk.floats.should == [1.0, 1.2]
bulk.decimals.should == [1.0, 1.2]
bulk.texts.should == [nil, 'Text', 'NULL', 'Text with nil', 'Text with , nil, !"\\', 'nil']
map_times(bulk.times).should ==
map_times(parse_times(%w{2010-01-01 2010-02-01}))
bulk.empty_def.should == []
bulk.destroy
end

Expand Down

0 comments on commit 0c38c7c

Please sign in to comment.