Skip to content

Commit

Permalink
Get ready for specs to work
Browse files Browse the repository at this point in the history
  • Loading branch information
Sutto committed Apr 6, 2009
1 parent 1b00282 commit c36bbac
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 28 deletions.
4 changes: 1 addition & 3 deletions README.textile
Expand Up @@ -6,9 +6,7 @@ Firstly, Clone this repo and then change to the top level directory.

Next, run the following commands to prepare your database:

@./couchdb-setup/reset-database@

@./couchdb-setup/import-views@
@./couchdb-setup/initialize-database@

Now, to use the irc bot, you'll need two things:

Expand Down
19 changes: 12 additions & 7 deletions couchdb-setup/import-views → couchdb-setup/initialize-database
Expand Up @@ -2,10 +2,14 @@
require 'rubygems'
require 'couchrest'

puts "Importing views..."
puts "Importing views..." unless ENV['SILENTIMPORT']

db_uri = ARGV[0] || File.read(File.join(File.dirname(__FILE__), "..", "database_uri")).strip

puts "Using database: #{db_uri}" unless ENV['SILENTIMPORT']

db_uri = File.read(File.join(File.dirname(__FILE__), "..", "database_uri")).strip
db = CouchRest.database!(db_uri)
db.recreate!

view_files = Dir[File.join(File.dirname(__FILE__), "views", "*", "*.*.js")]
views = {}
Expand All @@ -17,9 +21,10 @@ view_files.each do |vf|
end
end

docs = []

views.each do |design, options|
if (doc = db.get("_design/#{design}") rescue nil)
db.delete_doc(doc)
end
db.save_doc({"_id" => "_design/#{design}", :views => views[design]}) unless ENV['SKIPADD']
end
docs << {"_id" => "_design/#{design}", :views => views[design]}
end

db.bulk_save(docs) unless ENV['SKIPADD']
8 changes: 0 additions & 8 deletions couchdb-setup/reset-database

This file was deleted.

1 change: 0 additions & 1 deletion irc-bot/handlers/couch_logger.rb
@@ -1,5 +1,4 @@
require 'couchrest'
require 'stringex'

class CouchLogger < Marvin::LoggingHandler

Expand Down
3 changes: 0 additions & 3 deletions web-app/spec/application_spec.rb
Expand Up @@ -12,7 +12,4 @@ def app
last_response.should be_ok
end

specify 'should have more specs' do
pending
end
end
16 changes: 10 additions & 6 deletions web-app/spec/spec_helper.rb
Expand Up @@ -12,13 +12,17 @@

require 'application'

ENV['SILENTIMPORT'] = 'true'
SiteConfig.db_uri += "-test"

def reset_database!
system File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "couchdb-setup", "initialize-database")), SiteConfig.db_uri
end

Spec::Runner.configure do |config|

config.before(:each) do
begin
CouchRest.delete((SiteConfig.url_base_db || '') + SiteConfig.db_name)
rescue RestClient::ResourceNotFound
ensure
CouchRest.database!((SiteConfig.url_base_db || '') + SiteConfig.db_name)
end
reset_database!
end

end

0 comments on commit c36bbac

Please sign in to comment.