Skip to content

Commit

Permalink
a few fixes in doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Oct 19, 2010
1 parent 6a4ccf2 commit 896f4cd
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 27 deletions.
2 changes: 1 addition & 1 deletion dryml/lib/dryml.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def call_render(view, local_assigns, identifier)

def page_renderer(view, identifier, local_names=[], controller_name=nil)
controller_name ||= view.controller.controller_name
prepare_view!(view)
# prepare_view!(view)
if identifier =~ /#{ID_SEPARATOR}/
identifier = identifier.split(ID_SEPARATOR).first
@cache[identifier] ||= make_renderer_class("", "", local_names, taglibs_for(controller_name))
Expand Down
3 changes: 1 addition & 2 deletions hobo/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ Rake::TestTask.new(:test) { |t|
namespace "test" do
desc "Run the doctests"
task :doctest do |t|
files=Dir['doctest/*.rdoctest'].map {|f| File.expand_path(f)}.join(' ')
# note, tests in doctest/hobo/ are out of date
files=Dir['doctests/**/*.rdoctest'].map {|f| File.expand_path(f)}.join(' ')
exit(1) if !system("#{RUBYDOCTEST} #{files}")
end
end
Expand Down
1 change: 0 additions & 1 deletion hobo/doctests/hobo/lifecycles.rdoctest
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,3 @@ Requester cancels
=> "destroy"


>> FileUtils.rm_rf TEST_APP_ROOT
5 changes: 0 additions & 5 deletions hobo/doctests/hobo/model.rdoctest
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,4 @@ This provides a shortcut to the corresponding
>> Post.view_hints
=> PostHints

Cleanup
{.hidden}

>> FileUtils.rm_rf TEST_APP_ROOT
{.hidden}

9 changes: 4 additions & 5 deletions hobo/doctests/hobo/multi_model_forms.rdoctest
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ Contents
:host => "localhost",
:username => mysql_user,
:password => mysql_password)
>> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../../hobo_fields/lib')
>> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../../hobo_support/lib')
>> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../../hobo/lib')
>> $:.unshift File.expand_path('../../../../hobo_support/lib', __FILE__)
>> $:.unshift File.expand_path('../../../../hobo_fields/lib', __FILE__)
>> $:.unshift File.expand_path('../../../../dryml/lib', __FILE__)
>> $:.unshift File.expand_path('../../../lib', __FILE__)
>> gem 'will_paginate', ">= 3.0.pre"
>> require 'will_paginate'
>> require 'hobo_support'
>> require 'hobo_fields'
>> require 'hobo'
>> ActiveRecord::Base.logger = ActiveSupport::BufferedLogger.new(StringIO.new(''))
>>
Expand Down
9 changes: 4 additions & 5 deletions hobo/doctests/hobo/scopes.rdoctest
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,16 @@ We also need to get ActiveRecord set up with a database connection
Some load path manipulation:
{.hidden}

>> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../../hobo_fields/lib')
>> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../../hobo_support/lib')
>> $:.unshift File.join(File.expand_path(File.dirname(__FILE__)), '../../../hobo/lib')
>> $:.unshift File.expand_path('../../../../hobo_support/lib', __FILE__)
>> $:.unshift File.expand_path('../../../../hobo_fields/lib', __FILE__)
>> $:.unshift File.expand_path('../../../../dryml/lib', __FILE__)
>> $:.unshift File.expand_path('../../../lib', __FILE__)
{.hidden}

And we'll require hobo:
{.hidden}

>> require 'will_paginate'
>> require 'hobo_support'
>> require 'hobo_fields'
>> require 'hobo'
{.hidden}

Expand Down
3 changes: 2 additions & 1 deletion hobo/doctests/prepare_testapp.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'fileutils'
system %(rake test:prepare_testapp)
FileUtils.chdir '/tmp/hobo_testapp'
TESTAPP_PATH = '/tmp/hobo_testapp'
FileUtils.chdir TESTAPP_PATH
require 'config/environment'
require 'rails/generators'
Rails::Generators.configure!
Expand Down
4 changes: 2 additions & 2 deletions hobo_fields/test/migration_generator_comments.rdoctest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Our test requires to prepare the testapp for a different environment:

doctest_require: ENV["RAILS_ENV"] = 'mysql_test'; 'prepare_testapp'

>> system "cd #{TEST_APP_ROOT} && rake db:setup"
>> system "cd #{TESTAPP_PATH} && rake db:setup"
=> true

>> p Rails.env
Expand Down Expand Up @@ -71,5 +71,5 @@ Cleanup

>> nuke_model_class(Product)
>> ActiveRecord::Base.connection.execute "drop table `products`;"
>> system "cd #{TEST_APP_ROOT} && rake db:drop RAILS_ENV=mysql_test"
>> system "cd #{TESTAPP_PATH} && rake db:drop RAILS_ENV=mysql_test"
{.hidden}
3 changes: 2 additions & 1 deletion hobo_fields/test/prepare_testapp.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
require 'fileutils'
system %(rake test:prepare_testapp)
FileUtils.chdir '/tmp/hobo_fields_testapp'
TESTAPP_PATH = '/tmp/hobo_fields_testapp'
FileUtils.chdir TESTAPP_PATH
require 'config/environment'
require 'rails/generators'
Rails::Generators.configure!
Expand Down
2 changes: 1 addition & 1 deletion hobo_support/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} -S rubydoctest"
namespace "test" do
desc "Run the doctests"
task :doctest do |t|
files=Dir['test/*.rdoctest','test/hobo_support/*.rdoctest'].map {|f| File.expand_path(f)}.join(' ')
files=Dir['test/**/*.rdoctest'].map {|f| File.expand_path(f)}.join(' ')
exit(1) if !system("#{RUBYDOCTEST} --single #{files}")
end
end
2 changes: 2 additions & 0 deletions hobo_support/lib/hobo_support/common_tasks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ module HoboSupport
task :prepare_testapp, :force do |t, args|
if args.force || !File.directory?(TESTAPP_PATH)
remove_entry_secure( TESTAPP_PATH, true )
# hobodev = %(HOBODEV=#{ENV["HOBODEV"]}) if ENV["HOBODEV"]
# sh %(export #{hobodev})
sh %(#{BIN} new #{TESTAPP_PATH} --skip-wizard)
chdir TESTAPP_PATH
sh %(echo "gem 'irt', :group => :console" >> Gemfile) # to make the bundler happy
Expand Down
4 changes: 1 addition & 3 deletions hobo_support/test/hobosupport.rdoctest
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ HoboSupport is a mixed bag of core ruby extensions that have been extracted from
doctest_require: '../lib/hobo_support'
{.hidden}

>> HoboSupport::VERSION
=> "1.3.0.pre6"

## Contents

Expand All @@ -34,7 +32,7 @@ Like `is_a?` but multiple types to be checked in one go

## Method call extensions

We have the "." operator to call methods on objects. These extensions introduce two "special dots".
We have the "." operator to call methods on objects. These extensions introduce two "special dots".

### `Object#_?`

Expand Down

0 comments on commit 896f4cd

Please sign in to comment.