Skip to content

Commit

Permalink
Don't try to create the same table twice. The DB really doesn't like …
Browse files Browse the repository at this point in the history
…that. :) [#4]
  • Loading branch information
marnen committed Dec 4, 2009
1 parent 9e5d142 commit 895e9fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/ruby/data_table_model.rb
Expand Up @@ -10,7 +10,7 @@ def initialize(filename)

# Yes, this is a placeholder table. We'll make this more flexible shortly.
cols = column_count
@db.create_table :table do
@db.create_table? :table do
primary_key :id
1.upto(cols).each do |c|
String "column_#{c}"
Expand Down
6 changes: 6 additions & 0 deletions spec/data_table_model_spec.rb
Expand Up @@ -25,6 +25,12 @@
it "should give a new table two columns" do
DataTableModel.new(File.join @tmpdir, 'Columns').column_count.should == 2
end

it "should not try to create a data table that already exists" do
filename = File.join @tmpdir, 'Duplicate table'
DataTableModel.new filename
lambda {DataTableModel.new filename}.should_not raise_error
end
end

describe "instance methods" do
Expand Down

0 comments on commit 895e9fa

Please sign in to comment.