Skip to content

Commit

Permalink
attempting to get this running again
Browse files Browse the repository at this point in the history
  • Loading branch information
saturnflyer committed Feb 20, 2013
1 parent 9143cb3 commit d5f1e1e
Show file tree
Hide file tree
Showing 12 changed files with 231 additions and 132 deletions.
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source "https://rubygems.org"

gemspec
140 changes: 140 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
PATH
remote: .
specs:
dataset (1.4.0.radiant)
activerecord
activesupport

GEM
remote: https://rubygems.org/
specs:
actionmailer (3.2.12)
actionpack (= 3.2.12)
mail (~> 2.4.4)
actionpack (3.2.12)
activemodel (= 3.2.12)
activesupport (= 3.2.12)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
rack (~> 1.4.5)
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.2.1)
activemodel (3.2.12)
activesupport (= 3.2.12)
builder (~> 3.0.0)
activerecord (3.2.12)
activemodel (= 3.2.12)
activesupport (= 3.2.12)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
activeresource (3.2.12)
activemodel (= 3.2.12)
activesupport (= 3.2.12)
activesupport (3.2.12)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
builder (3.0.4)
capybara (2.0.2)
mime-types (>= 1.16)
nokogiri (>= 1.3.3)
rack (>= 1.0.0)
rack-test (>= 0.5.4)
selenium-webdriver (~> 2.0)
xpath (~> 1.0.0)
childprocess (0.3.8)
ffi (~> 1.0, >= 1.0.11)
cucumber (1.2.1)
builder (>= 2.1.2)
diff-lcs (>= 1.1.3)
gherkin (~> 2.11.0)
json (>= 1.4.6)
cucumber-rails (1.3.0)
capybara (>= 1.1.2)
cucumber (>= 1.1.8)
nokogiri (>= 1.5.0)
diff-lcs (1.1.3)
erubis (2.7.0)
ffi (1.3.1)
gherkin (2.11.6)
json (>= 1.7.6)
hike (1.2.1)
i18n (0.6.1)
journey (1.0.4)
json (1.7.7)
mail (2.4.4)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.21)
multi_json (1.6.1)
nokogiri (1.5.6)
polyglot (0.3.3)
rack (1.4.5)
rack-cache (1.2)
rack (>= 0.4)
rack-ssl (1.3.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rails (3.2.12)
actionmailer (= 3.2.12)
actionpack (= 3.2.12)
activerecord (= 3.2.12)
activeresource (= 3.2.12)
activesupport (= 3.2.12)
bundler (~> 1.0)
railties (= 3.2.12)
railties (3.2.12)
actionpack (= 3.2.12)
activesupport (= 3.2.12)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0)
rake (10.0.3)
rdoc (3.12.1)
json (~> 1.4)
rspec (2.12.0)
rspec-core (~> 2.12.0)
rspec-expectations (~> 2.12.0)
rspec-mocks (~> 2.12.0)
rspec-core (2.12.2)
rspec-expectations (2.12.1)
diff-lcs (~> 1.1.3)
rspec-mocks (2.12.2)
rubyzip (0.9.9)
selenium-webdriver (2.29.0)
childprocess (>= 0.2.5)
multi_json (~> 1.0)
rubyzip
websocket (~> 1.0.4)
sprockets (2.2.2)
hike (~> 1.2)
multi_json (~> 1.0)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
sqlite3 (1.3.7)
thor (0.17.0)
tilt (1.3.3)
treetop (1.4.12)
polyglot
polyglot (>= 0.3.1)
tzinfo (0.3.35)
websocket (1.0.7)
xpath (1.0.0)
nokogiri (~> 1.3)

PLATFORMS
ruby

DEPENDENCIES
cucumber-rails
dataset!
rack
rails
rake
rspec
sqlite3
14 changes: 4 additions & 10 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
# require File.join(File.dirname(__FILE__), 'plugit/descriptor')
require 'rubygems'
require 'spec/rake/spectask'

task :default => :spec

desc "Run all specs"
Spec::Rake::SpecTask.new do |t|
t.spec_files = FileList['spec/**/*_spec.rb']
t.spec_opts = ['--options', 'spec/spec.opts']
end
require 'rspec'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
11 changes: 8 additions & 3 deletions dataset.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ Gem::Specification.new do |gem|
gem.version = '1.4.0.radiant'
gem.date = Time.now.strftime('%Y-%m-%d')

gem.add_dependency 'activesupport', '>= 2.3.0'
gem.add_dependency 'activerecord', '>= 2.3.0'
# gem.add_development_dependency 'rspec', '~> 1.2.9'
gem.add_development_dependency 'rails'
gem.add_dependency 'activesupport'
gem.add_dependency 'activerecord'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec'
gem.add_development_dependency 'sqlite3'
gem.add_development_dependency 'cucumber-rails'
gem.add_development_dependency 'rack'

gem.summary = 'A simple API for creating and finding sets of data in your database, built on ActiveRecord.'
# gem.description = "Longer description."
Expand Down
28 changes: 14 additions & 14 deletions lib/dataset/base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Dataset

# The superclass of your Dataset classes.
#
# It is recommended that you create a dataset using the Dataset::Block
Expand All @@ -25,11 +25,11 @@ def helpers(&method_definitions)
end
@helper_methods.module_eval &method_definitions
end

def helper_methods # :nodoc:
@helper_methods
end

# Allows a subsclass to declare which datasets it uses.
#
# Dataset is designed to promote 'design by composition', rather than
Expand All @@ -54,16 +54,16 @@ def helper_methods # :nodoc:
# C uses B
# A uses C
# B, C, A is the load order
#
#
def uses(*datasets)
@used_datasets = datasets
end

def used_datasets # :nodoc:
@used_datasets
end
end

# Invoked once before a collection of tests is run. If you use a dataset
# in multiple test classes, it will be called once for each of them -
# remember that the database will be cleared at the beginning of running a
Expand All @@ -74,15 +74,15 @@ def used_datasets # :nodoc:
#
def load; end
end

# The easiest way to create some data before a suite of tests is run is by
# using a Dataset::Block. An example works wonders:
#
# class PeopleTest < Test::Unit::TestCase
# dataset do
# create_record :person, :billy, :name => 'Billy'
# end
#
#
# def test_name
# assert_equal 'Billy', people(:billy).name
# end
Expand All @@ -98,17 +98,17 @@ def load; end
#
# describe Something do
# dataset :a => Dataset :a is loaded (at the right time)
#
#
# it 'should whatever'
# end
#
#
# describe More do
# dataset :b => Dataset :b is loaded. :a data is still there
#
#
# it 'should'
# end
# end
#
#
# describe Another do => Database is restored to :a, without re-running :a logic
# it 'should'
# end
Expand Down Expand Up @@ -136,7 +136,7 @@ def load; end
# id = create_record :person, :second_admin, :name => 'Admin Three'
# create_record :organization_administratorship, :organization_id => organization_id(:first_bank), :person_id => id
# end
#
#
# def test_admins
# assert organizations(:first_bank).admins.include?(people(:second_admin))
# end
Expand All @@ -147,7 +147,7 @@ def load; end
# When you need to go beyond the block, create a Dataset::Base subclass!
class Block < Base
include Dataset::InstanceMethods

def load # :nodoc:
dataset_session_binding.install_block_variables(self)
doload
Expand Down
28 changes: 14 additions & 14 deletions lib/dataset/record/fixture.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,36 @@

module Dataset
module Record # :nodoc:

class Fixture # :nodoc:
attr_reader :meta, :symbolic_name, :session_binding

def initialize(meta, attributes, symbolic_name, session_binding)
@meta = meta
@attributes = attributes.stringify_keys
@symbolic_name = symbolic_name || object_id
@session_binding = session_binding

install_default_attributes!
end

def create
record_class.connection.insert_fixture to_fixture, meta.table_name
id
end

def id
@attributes['id']
end

def record_class
meta.record_class
end

def to_fixture
::Fixture.new(to_hash, meta.class_name)
to_hash
end

def to_hash
hash = @attributes.dup
hash[meta.inheritance_column] = meta.sti_name if meta.inheriting_record?
Expand All @@ -41,22 +41,22 @@ def to_hash
end
hash
end

def install_default_attributes!
@attributes['id'] ||= symbolic_name.to_s.hash.abs
install_timestamps!
end

def install_timestamps!
meta.timestamp_columns.each do |column|
@attributes[column.name] = now(column) unless @attributes.key?(column.name)
end
end

def now(column)
(ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now).to_s(:db)
end

private
def add_reflection_attributes(hash, name, reflection)
value = hash.delete(name)
Expand All @@ -68,6 +68,6 @@ def add_reflection_attributes(hash, name, reflection)
end
end
end

end
end
Loading

0 comments on commit d5f1e1e

Please sign in to comment.