Skip to content

Commit

Permalink
test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Asmuth committed Aug 17, 2011
1 parent 287e587 commit 7bbb80d
Show file tree
Hide file tree
Showing 9 changed files with 104 additions and 43 deletions.
38 changes: 1 addition & 37 deletions .gitignore
@@ -1,42 +1,6 @@
# rcov generated
coverage

# rdoc generated
rdoc

# yard generated
doc
.yardoc

# bundler
.bundle

# jeweler generated
pkg

# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
#
# * Create a file at ~/.gitignore
# * Include files you want ignored
# * Run: git config --global core.excludesfile ~/.gitignore
#
# After doing this, these files will be ignored in all your git projects,
# saving you from having to 'pollute' every project you touch with them
#
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
#
# For MacOS:
#
#.DS_Store
#
# For TextMate
#*.tmproj
#tmtags
#
# For emacs:
#*~
#\#*
#.\#*
#
# For vim:
#*.swp
db/*.sqlite
10 changes: 4 additions & 6 deletions Gemfile
@@ -1,13 +1,11 @@
source "http://rubygems.org"
# Add dependencies required to use your gem here.
# Example:
# gem "activesupport", ">= 2.3.5"

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
gem "activerecord"

group :development do
gem 'sqlite3-ruby'
gem "rspec"
gem "shoulda", ">= 0"
gem "bundler", "~> 1.0.0"
gem "jeweler", "~> 1.5.2"
gem "rcov", ">= 0"
end
47 changes: 47 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,47 @@
GEM
remote: http://rubygems.org/
specs:
activemodel (3.0.8)
activesupport (= 3.0.8)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.8)
activemodel (= 3.0.8)
activesupport (= 3.0.8)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activesupport (3.0.8)
arel (2.0.10)
builder (2.1.2)
diff-lcs (1.1.2)
git (1.2.5)
i18n (0.5.0)
jeweler (1.5.2)
bundler (~> 1.0.0)
git (>= 1.2.5)
rake
rake (0.9.2)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
shoulda (2.11.3)
sqlite3 (1.3.3)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
tzinfo (0.3.29)

PLATFORMS
ruby

DEPENDENCIES
activerecord
bundler (~> 1.0.0)
jeweler (~> 1.5.2)
rspec
shoulda
sqlite3-ruby
19 changes: 19 additions & 0 deletions Rakefile
Expand Up @@ -20,3 +20,22 @@ Jeweler::Tasks.new do |gem|
gem.authors = ["Paul Asmuth"]
end

require 'rspec'
require 'rspec/core/rake_task'
desc "Run all examples"
task RSpec::Core::RakeTask.new('spec')

desc "Create test-database (db/test.sqlite)"
task :create_test_database do
require ::File.expand_path('../spec/spec_helper.rb', __FILE__)
begin
ActiveRecord::Migration.class_eval do
drop_table :my_metrics
end
rescue; end
ActiveRecord::Migration.class_eval do
create_table :my_metrics do |t|
t.text :data
end
end
end
1 change: 1 addition & 0 deletions db/empty
@@ -0,0 +1 @@

3 changes: 3 additions & 0 deletions lib/fnordmetric.rb
@@ -0,0 +1,3 @@
module FnordMetric; end

require "fnordmetric/base"
3 changes: 3 additions & 0 deletions lib/fnordmetric/base.rb
@@ -0,0 +1,3 @@
class FnordMetric::Base

end
12 changes: 12 additions & 0 deletions spec/base_spec.rb
@@ -0,0 +1,12 @@
require ::File.expand_path('../spec_helper.rb', __FILE__)

describe "base" do


it "should create a new data point" do
old_count = MyMetric.datapoints.count
MyMetric.create_datapoint(:foo => 1, :bar => 5)
MyMetric.datapoints.count.should == old_count + 1
end

end
14 changes: 14 additions & 0 deletions spec/spec_helper.rb
@@ -0,0 +1,14 @@
require 'rubygems'
require 'rspec'

require 'active_record'
ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ::File.expand_path('../../db/test.sqlite', __FILE__))

$: << ::File.expand_path('../../lib', __FILE__)

require "fnordmetric"

class MyMetric < FnordMetric::Base


end

0 comments on commit 7bbb80d

Please sign in to comment.