<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/dataset/instance_methods.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,3 +4,6 @@
 
   * Birthday!
 
+=== 
+
+* Sub-contexts get instance variables from ancestors
\ No newline at end of file</diff>
      <filename>History.txt</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require 'dataset/version'
+require 'dataset/instance_methods'
 require 'dataset/base'
 require 'dataset/database/base'
 require 'dataset/database/mysql'
@@ -76,13 +77,13 @@ module Dataset
       raise &quot;I don't understand your test framework&quot;
     end
     
-    test_context.extend ClassMethods
+    test_context.extend ContextClassMethods
   end
   
   # Methods that are added to the class that Dataset is included in (the test
   # context class).
   #
-  module ClassMethods
+  module ContextClassMethods
     def self.extended(context_class) # :nodoc:
       context_class.module_eval do
         include InstanceMethods
@@ -99,7 +100,7 @@ module Dataset
     # Dataset::Database::Base).
     def datasets_directory(path)
       Dataset::Resolver.default = Dataset::DirectoryResolver.new(path)
-      Dataset::ClassMethods.datasets_database_dump_path = File.join(path, '/tmp/dataset')
+      Dataset::ContextClassMethods.datasets_database_dump_path = File.join(path, '/tmp/dataset')
     end
     
     def add_dataset(*datasets, &amp;block) # :nodoc:
@@ -114,20 +115,9 @@ module Dataset
       self.dataset_session ||= begin
         database_spec = ActiveRecord::Base.configurations['test'].with_indifferent_access
         database_class = Dataset::Database.const_get(database_spec[:adapter].classify)
-        database = database_class.new(database_spec, Dataset::ClassMethods.datasets_database_dump_path)
+        database = database_class.new(database_spec, Dataset::ContextClassMethods.datasets_database_dump_path)
         Dataset::Session.new(database)
       end
     end
   end
-  
-  module InstanceMethods # :nodoc:
-    def extend_from_dataset_load(load)
-      load.dataset_binding.block_variables.each do |k,v|
-        instance_variable_set(k, v)
-      end
-      self.extend load.dataset_binding.record_methods
-      self.extend load.dataset_binding.model_finders
-      self.extend load.helper_methods
-    end
-  end
 end
\ No newline at end of file</diff>
      <filename>lib/dataset.rb</filename>
    </modified>
    <modified>
      <diff>@@ -121,7 +121,7 @@ module Dataset
   # be available to your test methods. You have to be careful with this in a
   # similar way that you must with an RSpec before :all block. Since the
   # instance variables are pointing to the same instances accross all tests,
-  # things can get weird if you intend to change their state. It's best use if
+  # things can get weird if you intend to change their state. It's best use is
   # for loading objects that you want to read a lot without loading over and
   # over again for each test.
   #
@@ -146,11 +146,12 @@ module Dataset
   #
   # When you need to go beyond the block, create a Dataset::Base subclass!
   class Block &lt; Base
+    include Dataset::InstanceMethods
+    
     def load # :nodoc:
+      dataset_session_binding.install_block_variables(self)
       doload
-      instance_variables.each do |name|
-        dataset_session_binding.block_variables[name] = instance_variable_get(name)
-      end
+      dataset_session_binding.copy_block_variables(self)
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/dataset/base.rb</filename>
    </modified>
    <modified>
      <diff>@@ -41,7 +41,7 @@ module Dataset
     
     def initialize(load)
       @load = load
-      @dataset_binding = SessionBinding.new(load.dataset_binding)
+      @dataset_binding = SessionBinding.new(@load.dataset_binding)
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/dataset/load.rb</filename>
    </modified>
    <modified>
      <diff>@@ -170,6 +170,12 @@ module Dataset
       end
     end
     
+    def copy_block_variables(dataset_block)
+      dataset_block.instance_variables.each do |name|
+        self.block_variables[name] = dataset_block.instance_variable_get(name)
+      end
+    end
+    
     def create_model(record_type, *args)
       insert(Dataset::Record::Model, record_type, *args)
     end
@@ -200,6 +206,12 @@ module Dataset
       end
     end
     
+    def install_block_variables(target)
+      block_variables.each do |k,v|
+        target.instance_variable_set(k,v)
+      end
+    end
+    
     def name_model(record, symbolic_name)
       record_class = record.class.base_class
       @model_finders.create_finder(record_class) unless @symbolic_names_to_ids.has_key?(record_class)</diff>
      <filename>lib/dataset/session_binding.rb</filename>
    </modified>
    <modified>
      <diff>@@ -7,14 +7,14 @@ Plugit.describe do |dataset|
   dataset.environments_root_path = &quot;#{PLUGIT_ROOT}/environments&quot;
   vendor_directory               = &quot;#{PLUGIT_ROOT}/../vendor/plugins&quot;
   
-  dataset.environment :default, 'Edge versions of Rails and RSpec' do |env|
+  dataset.environment :default, 'Released versions of Rails and RSpec' do |env|
     env.library :rails, :export =&gt; &quot;git clone git://github.com/rails/rails.git&quot; do |rails|
-      rails.before_install { `git pull` }
+      rails.after_update { `git fetch origin 2-2-stable:2-2-stable; git co 2-2-stable` }
       rails.load_paths = %w{/activesupport/lib /activerecord/lib /actionpack/lib}
       rails.requires = %w{active_support active_record active_record/fixtures action_controller action_view}
     end
     env.library :rspec, :export =&gt; &quot;git clone git://github.com/dchelimsky/rspec.git&quot; do |rspec|
-      rspec.after_update { `git pull &amp;&amp; mkdir -p #{vendor_directory} &amp;&amp; ln -sF #{File.expand_path('.')} #{vendor_directory + '/rspec'}` }
+      rspec.after_update { `git co -b rspecrelease 1.1.11 &amp;&amp; mkdir -p #{vendor_directory} &amp;&amp; ln -sF #{File.expand_path('.')} #{vendor_directory + '/rspec'}` }
       rspec.requires = %w{spec}
     end
   end</diff>
      <filename>plugit/descriptor.rb</filename>
    </modified>
    <modified>
      <diff>@@ -113,6 +113,23 @@ describe Test::Unit::TestCase do
     value_in_test.should == 'Hello'
   end
   
+  it 'should copy instance variables from block to subclass blocks' do
+    value_in_subclass_block = nil
+    testcase = Class.new(Test::Unit::TestCase) do
+      dataset do
+        @myvar = 'Hello'
+      end
+    end
+    subclass = Class.new(testcase) do
+      dataset do
+        value_in_subclass_block = @myvar
+      end
+    end
+    
+    run_testcase(subclass)
+    value_in_subclass_block.should == 'Hello'
+  end
+  
   it 'should load the dataset when the suite is run' do
     load_count = 0
     dataset = Class.new(Dataset::Base) do</diff>
      <filename>spec/dataset/test_unit_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ namespace :db do
       dataset_names = (ENV['DATASETS'] || 'default').split(',')
       
       context = Class.new do
-        extend Dataset::ClassMethods
+        extend Dataset::ContextClassMethods
         datasets_directory [
           &quot;#{RAILS_ROOT}/spec/datasets&quot;,
           &quot;#{RAILS_ROOT}/test/datasets&quot;</diff>
      <filename>tasks/dataset.rake</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2bfc1c6ebde08bcc1392df113345638ce1b73ff1</id>
    </parent>
  </parents>
  <author>
    <name>Adam Williams</name>
    <email>adam@thewilliams.ws</email>
  </author>
  <url>http://github.com/aiwilliams/dataset/commit/fb5d57260758b7fe3f905f950c2851c60da8561a</url>
  <id>fb5d57260758b7fe3f905f950c2851c60da8561a</id>
  <committed-date>2009-01-02T12:31:14-08:00</committed-date>
  <authored-date>2009-01-02T12:31:14-08:00</authored-date>
  <message>Instance variables created in a dataset block are available in nested contexts</message>
  <tree>0acc14c056c026029073dd27e10b8c80ffd5d9d7</tree>
  <committer>
    <name>Adam Williams</name>
    <email>adam@thewilliams.ws</email>
  </committer>
</commit>
