Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 4181 Bytes
1 | require 'activesupport' |
2 | require 'activerecord' |
3 | |
4 | require 'dataset/version' |
5 | require 'dataset/instance_methods' |
6 | require 'dataset/base' |
7 | require 'dataset/database/base' |
8 | require 'dataset/database/mysql' |
9 | require 'dataset/database/sqlite3' |
10 | require 'dataset/database/postgresql' |
11 | require 'dataset/collection' |
12 | require 'dataset/load' |
13 | require 'dataset/resolver' |
14 | require 'dataset/session' |
15 | require 'dataset/session_binding' |
16 | require 'dataset/record/meta' |
17 | require 'dataset/record/fixture' |
18 | require 'dataset/record/model' |
19 | |
20 | # == Quick Start |
21 | # |
22 | # Write a test. If you want some data in your database, create a dataset. |
23 | # Start simple. |
24 | # |
25 | # describe States do |
26 | # dataset do |
27 | # [%w(Colorado CO), %w(North\ Carolina NC), %w(South\ Carolina SC)].each do |name,abbrev| |
28 | # create_record :state, abbrev.downcase, :name => name, :abbrev => abbrev |
29 | # end |
30 | # end |
31 | # |
32 | # it 'should have an abbreviated name' |
33 | # states(:nc).abbrev.should be('NC') |
34 | # end |
35 | # |
36 | # it 'should have a name' |
37 | # states(:nc).name.should be('North Carolin') |
38 | # end |
39 | # end |
40 | # |
41 | # Notice that you won't be using _find_id_ or _find_model_ in your tests. You |
42 | # use methods like _states_ and _state_id_, as in the example above. |
43 | # |
44 | # When you find that you're seeing patterns in the data you are creating, pull it into a class. |
45 | # |
46 | # spec/datasets/states.rb |
47 | # class StatesDataset < Dataset::Base |
48 | # def load |
49 | # # create useful data |
50 | # end |
51 | # end |
52 | # |
53 | # spec/models/state.rb |
54 | # describe State do |
55 | # dataset :states |
56 | # end |
57 | # |
58 | # == Installation |
59 | # |
60 | # Dataset is installed into your testing environment by requiring the library, |
61 | # then including it into the class that will be the context of your test |
62 | # methods. |
63 | # |
64 | # require 'dataset' |
65 | # class Test::Unit::TestCase |
66 | # include Dataset |
67 | # datasets_directory "#{RAILS_ROOT}/test/datasets" |
68 | # end |
69 | # |
70 | # Note that should you desire your Dataset::Base subclasses be |
71 | # auto-discovered, you can set the _datasets_directory_. |
72 | # |
73 | module Dataset |
74 | def self.included(test_context) # :nodoc: |
75 | if test_context.name =~ /World\Z/ |
76 | require 'dataset/extensions/cucumber' |
77 | elsif test_context.name =~ /TestCase\Z/ |
78 | require 'dataset/extensions/test_unit' |
79 | elsif test_context.name =~ /ExampleGroup\Z/ |
80 | require 'dataset/extensions/rspec' |
81 | else |
82 | raise "I don't understand your test framework" |
83 | end |
84 | |
85 | test_context.extend ContextClassMethods |
86 | end |
87 | |
88 | # Methods that are added to the class that Dataset is included in (the test |
89 | # context class). |
90 | # |
91 | module ContextClassMethods |
92 | def self.extended(context_class) # :nodoc: |
93 | context_class.module_eval do |
94 | include InstanceMethods |
95 | superclass_delegating_accessor :dataset_session |
96 | end |
97 | end |
98 | |
99 | mattr_accessor :datasets_database_dump_path |
100 | self.datasets_database_dump_path = File.expand_path(RAILS_ROOT + '/tmp/dataset') if defined?(RAILS_ROOT) |
101 | |
102 | # Replaces the default Dataset::Resolver with one that will look for |
103 | # dataset class definitions in the specified directory. Captures of the |
104 | # database will be stored in a subdirectory 'tmp' (see |
105 | # Dataset::Database::Base). |
106 | def datasets_directory(path) |
107 | Dataset::Resolver.default = Dataset::DirectoryResolver.new(path) |
108 | Dataset::ContextClassMethods.datasets_database_dump_path = File.join(path, '/tmp/dataset') |
109 | end |
110 | |
111 | def add_dataset(*datasets, &block) # :nodoc: |
112 | dataset_session = dataset_session_in_hierarchy |
113 | datasets.each { |dataset| dataset_session.add_dataset(self, dataset) } |
114 | dataset_session.add_dataset(self, Class.new(Dataset::Block) { |
115 | define_method :doload, block |
116 | }) unless block.nil? |
117 | end |
118 | |
119 | def dataset_session_in_hierarchy # :nodoc: |
120 | self.dataset_session ||= begin |
121 | database_spec = ActiveRecord::Base.configurations['test'].with_indifferent_access |
122 | database_class = Dataset::Database.const_get(database_spec[:adapter].classify) |
123 | database = database_class.new(database_spec, Dataset::ContextClassMethods.datasets_database_dump_path) |
124 | Dataset::Session.new(database) |
125 | end |
126 | end |
127 | end |
128 | end |