Skip to content

Commit

Permalink
update hobo unit tests to run under Rails 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanlarsen committed Jul 11, 2012
1 parent 2d2ea32 commit 4337165
Show file tree
Hide file tree
Showing 15 changed files with 32 additions and 44 deletions.
2 changes: 1 addition & 1 deletion hobo/Rakefile
Expand Up @@ -14,7 +14,7 @@ require 'hobo'

include Rake::DSL

RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
RUBY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
RUBYDOCTEST = ENV['RUBYDOCTEST'] || "#{RUBY} -S rubydoctest"

GEM_ROOT = File.expand_path('../', __FILE__)
Expand Down
21 changes: 16 additions & 5 deletions hobo/test/doctest/hobo/scopes.rdoctest
Expand Up @@ -36,7 +36,8 @@ Nobody but the computer needs to read the rest of this section.

Let's set up a few models for our testing:

>>
>> File.open("#{Rails.root}/app/models/person.rb", "w") do |f|
f.write("""
class Person < ActiveRecord::Base
hobo_model

Expand All @@ -55,19 +56,29 @@ Let's set up a few models for our testing:
has_many :friendships
has_many :friends, :through => :friendships
end

>>
""")
end
>> File.open("#{Rails.root}/app/models/friendship.rb", "w") do |f|
f.write("""
class Friendship < ActiveRecord::Base
hobo_model
fields
belongs_to :person
belongs_to :friend, :class_name => "Person"
belongs_to :friend, :class_name => 'Person'
end
""")
end

Generate a migration and run it:
{.hidden}

>> ActiveRecord::Migration.class_eval(Generators::Hobo::Migration::Migrator.run[0])
>> File.open("m.txt", "w") {|f| f.write("m\n\n")}
>> system("rails g hobo:migration < m.txt")
>> ActionDispatch::Reloader.cleanup!
>> ActionDispatch::Reloader.prepare!
>> Person.connection.clear_cache!
>> Person.connection.schema_cache.clear!
>> Person.reset_column_information
>> Person.columns.*.name
=> ["id", "name", "born_at", "code", "male", "created_at", "updated_at", "state"]
{.hidden}
Expand Down
3 changes: 2 additions & 1 deletion hobo/test/doctest/prepare_testapp.rb
Expand Up @@ -7,5 +7,6 @@
FileUtils.chdir TESTAPP_PATH
require "#{TESTAPP_PATH}/config/environment"
require 'rails/generators'
Rails::Generators.configure!
Rails::Generators.configure!(Rails.application.config.generators)


6 changes: 1 addition & 5 deletions hobo/test/irt/generators/admin_subsite.irt
@@ -1,9 +1,5 @@
invoke 'hobo:assets', %w[ -q ]
invoke 'hobo:admin_subsite', %w[ -q --make-front-site=false ]
desc "Admin Subsite files exist"
files_exist? %w[ app/controllers/admin/admin_site_controller.rb
app/controllers/admin/users_controller.rb
app/helpers/admin/users_helper.rb
app/views/taglibs/admin_site.dryml
]
files_exist? %w( app/controllers/admin/admin_site_controller.rb app/controllers/admin/users_controller.rb app/helpers/admin/users_helper.rb app/views/taglibs/admin_site.dryml )
test_value_eql? true
8 changes: 1 addition & 7 deletions hobo/test/irt/generators/assets.irt
@@ -1,11 +1,5 @@
desc "hobo:assets invoke"
invoke 'hobo:assets', %w(-q)

files_exist? %w[ app/views/taglibs/application.dryml
app/assets/stylesheets/application.css
app/assets/stylesheets/front.css
app/assets/javascripts/application.js
app/assets/javascripts/front.js
app/models/guest.rb
]
files_exist? %w( app/views/taglibs/application.dryml app/assets/stylesheets/application.css app/assets/stylesheets/front.css app/assets/javascripts/application.js app/assets/javascripts/front.js app/models/guest.rb )
test_value_eql? true
4 changes: 1 addition & 3 deletions hobo/test/irt/generators/front_controller.irt
@@ -1,8 +1,6 @@
invoke 'hobo:front_controller', %w[ -q ]
desc "All files exist"
files_exist? %w[ app/controllers/front_controller.rb
app/helpers/front_helper.rb
app/views/front/index.dryml ]
files_exist? %w( app/controllers/front_controller.rb app/helpers/front_helper.rb app/views/front/index.dryml )
test_value_eql? true

desc "public/index.html removed"
Expand Down
3 changes: 1 addition & 2 deletions hobo/test/irt/generators/model.irt
Expand Up @@ -5,8 +5,7 @@ eval_file '../partials/_house_model_tests.rb'
invoke 'hobo:model', %w(nest/ed alpha:string -q)

desc "Nested files exist"
files_exist? %w[ app/models/nest/ed.rb
app/models/nest.rb ]
files_exist? %w( app/models/nest/ed.rb app/models/nest.rb )
test_value_eql? true

desc "Nested injection matches"
Expand Down
@@ -1,7 +1,5 @@
desc "Account Model files exist"
files_exist? %w[ app/models/account.rb
app/models/account.rb
]
files_exist? %w(app/models/account.rb)
test_value_eql? true

desc "Account Model injection matches"
Expand Down
@@ -1,7 +1,5 @@
desc "All controller files exists"
files_exist? %w[ app/controllers/accounts_controller.rb
app/helpers/accounts_helper.rb
]
files_exist? %w( app/controllers/accounts_controller.rb app/helpers/accounts_helper.rb )
test_value_eql? true


Expand Down
@@ -1,7 +1,5 @@
desc "All files exists"
files_exist? %w[ app/models/user.rb
app/models/user.rb
]
files_exist? %w( app/models/user.rb )
test_value_eql? true

desc "User Model injection matches"
Expand Down
@@ -1,7 +1,5 @@
desc "All user controller files exists"
files_exist? %w[ app/controllers/users_controller.rb
app/helpers/users_helper.rb
]
files_exist? %w( app/controllers/users_controller.rb app/helpers/users_helper.rb )
test_value_eql? true


Expand Down
4 changes: 1 addition & 3 deletions hobo/test/irt/generators/partials/_house_controller_tests.rb
@@ -1,7 +1,5 @@
desc "All controller files exists"
files_exist? %w[ app/controllers/houses_controller.rb
app/helpers/houses_helper.rb
]
files_exist? %w( app/controllers/houses_controller.rb app/helpers/houses_helper.rb )

test_value_eql? true

Expand Down
4 changes: 1 addition & 3 deletions hobo/test/irt/generators/partials/_user_mailer_tests.rb
@@ -1,8 +1,6 @@

desc "User Mailer files exist"
files_exist? %w[ app/mailers/user_mailer.rb
app/views/user_mailer/forgot_password.erb
]
files_exist? ["app/mailers/user_mailer.rb", "app/views/user_mailer/forgot_password.erb"]
test_value_eql? true

desc "user_mailer.rb file content"
Expand Down
3 changes: 1 addition & 2 deletions hobo/test/irt/generators/subsite.irt
@@ -1,7 +1,6 @@
invoke 'hobo:subsite', %w[ subs --make-front-site=false -q]
desc "Subsite files exist"
files_exist? %w[ app/controllers/subs/subs_site_controller.rb
app/views/taglibs/subs_site.dryml ]
files_exist? %w( app/controllers/subs/subs_site_controller.rb app/views/taglibs/subs_site.dryml )
test_value_eql? true

desc "SiteController matches"
Expand Down
2 changes: 2 additions & 0 deletions hobo/test/irt/generators/user_mailer.irt
@@ -1,3 +1,5 @@
git_reset_app

invoke 'hobo:user_mailer', %w[ user -q ]

eval_file '../partials/_user_mailer_tests.rb'
Expand Down

0 comments on commit 4337165

Please sign in to comment.