Skip to content

Commit

Permalink
Merge branch 'irt_testing'
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Jan 8, 2012
2 parents a902750 + 777c3d9 commit 3c0ebff
Show file tree
Hide file tree
Showing 29 changed files with 49 additions and 129 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ dryml/lib/doc
doc
dryml/doc
.yardoc
.rvmrc
Gemfile
Gemfile.lock
2 changes: 1 addition & 1 deletion hobo/hobo.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Gem::Specification.new do |s|

s.add_development_dependency('rubydoctest', [">= 0"])
s.add_development_dependency('shoulda', [">= 0"])
s.add_development_dependency('irt', [">= 0.7.5"])
s.add_development_dependency('irt', [">= 1.2.10"])

s.executables = ["hobo"]
s.files = `git ls-files -x #{name}/* -z`.split("\0")
Expand Down
11 changes: 4 additions & 7 deletions hobo/test/irt/generators/admin_subsite.irt
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
require File.expand_path('../helper.rb', __FILE__)


invoke 'hobo:assets', %w[ -q ]
invoke 'hobo:admin_subsite', %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
test/functional/admin_site_controller_test.rb
public/stylesheets/admin.css
app/controllers/admin/users_controller.rb
app/helpers/admin/users_helper.rb
test/unit/helpers/admin/users_helper_test.rb
app/views/taglibs/admin_site.dryml
]
test_value_eql? true
Expand All @@ -19,7 +14,9 @@ file_include? "app/views/taglibs/application.dryml",
%(<extend tag="page">
<old-page merge>
<footer:>
<a href="&admin_users_url" if="&current_user.administrator?">Admin</a>
<a href="&admin_users_url" if="&current_user.administrator?">
<t key="hobo.admin.subsite_name">Admin</t>
</a>
</footer:>
</old-page>
</extend>
Expand Down
3 changes: 0 additions & 3 deletions hobo/test/irt/generators/assets.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


desc "hobo:assets invoke"
invoke 'hobo:assets', %w(-q)

Expand Down
3 changes: 0 additions & 3 deletions hobo/test/irt/generators/controller.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


invoke 'hobo:controller' , %w(houses -q)

eval_file '../partials/_house_controller_tests.rb'
5 changes: 0 additions & 5 deletions hobo/test/irt/generators/front_controller.irt
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
require File.expand_path('../helper.rb', __FILE__)


invoke 'hobo:front_controller', %w[ -q ]
desc "All files exist"
files_exist? %w[ app/controllers/front_controller.rb
app/helpers/front_helper.rb
test/unit/helpers/front_helper_test.rb
test/functional/front_controller_test.rb
app/views/front/index.dryml ]
test_value_eql? true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
irt_at_exit{git_reset_app}
IRT::Directives.irt_at_exit {git_reset_app}

def invoke(*args)
Rails::Generators.invoke *args
Expand All @@ -20,7 +20,7 @@ def file_exclude?(path, *strings)
def file_content(path, action, *strings)
f = File.read(path)
wrong = strings.send(action) do |s|
re = s.is_a?(Regexp) ? s : /#{Regexp.escape(s)}/
re = s.is_a?(Regexp) ? s : /#{Regexp.escape(s)}/m
!(f =~ re)
end
wrong.empty? || wrong
Expand Down
13 changes: 1 addition & 12 deletions hobo/test/irt/generators/model.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


invoke 'hobo:model', %w(house alpha:string -q)

eval_file '../partials/_house_model_tests.rb'
Expand All @@ -9,10 +6,7 @@ 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
test/unit/nest/ed_test.rb
test/fixtures/nest/eds.yml
app/viewhints/nest/ed_hints.rb ]
app/models/nest.rb ]
test_value_eql? true

desc "Nested injection matches"
Expand All @@ -21,8 +15,3 @@ file_include? 'app/models/nest/ed.rb',
'fields do',
/alpha\s+\:string/
test_value_eql? true

desc "Nested hint content matches"
file_include? 'app/viewhints/nest/ed_hints.rb',
'class Nest::EdHints'
test_value_eql? true
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
desc "Account Model files exist"
files_exist? %w[ app/models/account.rb
app/models/account.rb
test/unit/account_test.rb
test/fixtures/accounts.yml
app/viewhints/account_hints.rb
]
test_value_eql? true

Expand All @@ -14,8 +11,3 @@
/name\s+\:string/ ,
/email_address\s+\:email_address/
test_value_eql? true

desc "Nested hint content matches"
file_include? 'app/viewhints/account_hints.rb',
'class AccountHints'
test_value_eql? true
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
desc "All controller files exists"
files_exist? %w[ app/controllers/accounts_controller.rb
app/helpers/accounts_helper.rb
test/unit/helpers/accounts_helper_test.rb
test/functional/accounts_controller_test.rb
]
test_value_eql? true

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
desc "All files exists"
files_exist? %w[ app/models/user.rb
app/models/user.rb
test/unit/user_test.rb
test/fixtures/users.yml
app/viewhints/user_hints.rb
]
test_value_eql? true

Expand All @@ -14,8 +11,3 @@
/name\s+:string/,
/email_address\s+:email_address/
test_value_eql? true

desc "Hint content matches"
file_include? 'app/viewhints/user_hints.rb',
'class UserHints'
test_value_eql? true
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
desc "All user controller files exists"
files_exist? %w[ app/controllers/users_controller.rb
app/helpers/users_helper.rb
test/unit/helpers/users_helper_test.rb
test/functional/users_controller_test.rb
]
test_value_eql? true

Expand Down
2 changes: 0 additions & 2 deletions hobo/test/irt/generators/partials/_house_controller_tests.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
desc "All controller files exists"
files_exist? %w[ app/controllers/houses_controller.rb
app/helpers/houses_helper.rb
test/unit/helpers/houses_helper_test.rb
test/functional/houses_controller_test.rb
]

test_value_eql? true
Expand Down
10 changes: 1 addition & 9 deletions hobo/test/irt/generators/partials/_house_model_tests.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
desc "All Model files exists"
files_exist? %w[ app/models/house.rb
test/unit/house_test.rb
test/fixtures/houses.yml
app/viewhints/house_hints.rb ]
files_exist? %w[ app/models/house.rb ]
test_value_eql? true

desc "Model injection matches"
Expand All @@ -11,8 +8,3 @@
'fields do',
/alpha\s+\:string/
test_value_eql? true

desc "Hint content matches"
file_include? 'app/viewhints/house_hints.rb',
'class HouseHints'
test_value_eql? true
7 changes: 5 additions & 2 deletions hobo/test/irt/generators/partials/_subsite_taglib_admin.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
desc "Taglib admin file matches"
file_include?( "app/views/taglibs/subs_site.dryml", tags, admin_tag ) &&
desc "Taglib admin file matches inclusions"
file_include?( "app/views/taglibs/subs_site.dryml", tags, admin_tag )
test_value_eql? true

desc "Taglib admin file matches exclusions"
file_exclude?("app/views/taglibs/subs_site.dryml", invite_only)
test_value_eql? true
2 changes: 1 addition & 1 deletion hobo/test/irt/generators/partials/_subsite_taglib_noopt.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
desc "Taglib file matches"
file_include?("app/views/taglibs/subs_site.dryml", tags) &&
file_include?("app/views/taglibs/subs_site.dryml", tags) === true &&
file_exclude?("app/views/taglibs/subs_site.dryml", admin_tag, invite_only)
test_value_eql? true
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<stylesheet name="subs"/>
</append-stylesheets:>
<footer:>
<a href="#{base_url}/">View Site</a> |
<a href="#{base_url}/"><t key="hobo.subsite.back_link">View Site</t></a>
</footer:>
</old-page>
</extend>'
Expand Down
4 changes: 1 addition & 3 deletions hobo/test/irt/generators/partials/_user_mailer_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
desc "User Mailer files exist"
files_exist? %w[ app/mailers/user_mailer.rb
app/views/user_mailer/forgot_password.erb
test/functional/user_mailer_test.rb
]
test_value_eql? true

desc "user_mailer.rb file content"
file_include? 'app/mailers/user_mailer.rb',
'class UserMailer',
'def set_variables'
'class UserMailer'
test_value_eql? true

desc "forgot_password.erb file content"
Expand Down
3 changes: 0 additions & 3 deletions hobo/test/irt/generators/rapid.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


desc "hobo:rapid invoke"
invoke 'hobo:rapid', %w(-q)

Expand Down
3 changes: 0 additions & 3 deletions hobo/test/irt/generators/resource.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


invoke 'hobo:resource' , %w(house alpha:string -q)

eval_file '../partials/_house_controller_tests.rb'
Expand Down
20 changes: 8 additions & 12 deletions hobo/test/irt/generators/subsite.irt
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
require File.expand_path('../helper.rb', __FILE__)


invoke 'hobo:subsite', %w[ subs -q]
invoke 'hobo:subsite', %w[ subs --make-front-site=false -q]
desc "Subsite files exist"
files_exist? %w[ app/controllers/subs/subs_site_controller.rb
test/functional/subs_site_controller_test.rb
app/views/taglibs/subs_site.dryml ]
test_value_eql? true

Expand All @@ -27,26 +23,26 @@ desc "Subsite with make-front-site files exist"
files_exist? %w[ app/views/taglibs/front_site.dryml
app/views/taglibs/application.dryml
app/controllers/subs/subs_site_controller.rb
test/functional/subs_site_controller_test.rb
app/views/taglibs/subs_site.dryml ]
test_value_eql? true


git_reset_app
invoke 'hobo:subsite', %w[ subs -q --admin]

invoke 'hobo:assets', %w[ -q ]
invoke 'hobo:admin_subsite', %w[ subs -q --make-front-site=false]
eval_file '../partials/_subsite_taglib_admin.rb'

git_reset_app
invoke 'hobo:subsite', %w[ subs -q --admin --invite-only]
invoke 'hobo:assets', %w[ -q ]
invoke 'hobo:admin_subsite', %w[ subs --make-front-site=false -q --invite-only]
eval_file '../partials/_subsite_taglib_admin_invite_only.rb'

git_reset_app
invoke 'hobo:subsite', %w[ subs --user-resource-name=account -q --admin --invite-only]
invoke 'hobo:assets', %w[ -q ]
invoke 'hobo:admin_subsite', %w[ subs --make-front-site=false --user-resource-name=account -q --invite-only]
user_resource_name = 'Account'
eval_file '../partials/_subsite_taglib_variables.rb'
eval_file '../partials/_subsite_taglib_admin_invite_only.rb'





18 changes: 0 additions & 18 deletions hobo/test/irt/generators/subsite_taglib.irt
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
require File.expand_path('../helper.rb', __FILE__)


user_resource_name = 'User'
eval_file '../partials/_subsite_taglib_variables.rb'

invoke 'hobo:subsite_taglib', %w[ subs -q]
eval_file '../partials/_subsite_taglib_noopt.rb'

git_reset_app
invoke 'hobo:subsite_taglib', %w[ subs -q --admin]
eval_file '../partials/_subsite_taglib_admin.rb'

git_reset_app
invoke 'hobo:subsite_taglib', %w[ subs -q --admin --invite-only]
eval_file '../partials/_subsite_taglib_admin_invite_only.rb'

git_reset_app
invoke 'hobo:subsite_taglib', %w[ subs --user-resource-name=account -q --admin --invite-only]
user_resource_name = 'Account'
eval_file '../partials/_subsite_taglib_variables.rb'
eval_file '../partials/_subsite_taglib_admin_invite_only.rb'

7 changes: 2 additions & 5 deletions hobo/test/irt/generators/test_framework.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


desc "test_unit: default no-changes'"
invoke 'hobo:test_framework', %w(test_unit)
file_exclude? 'config/application.rb',
Expand Down Expand Up @@ -41,7 +38,7 @@ file_include? 'config/application.rb',
test_value_eql? true

desc "rspec Gemfile injection"
file_include? 'Gemfile', %(gem "rspec-rails", ">= 2.0.0.beta.10", :group => :test)
file_include? 'Gemfile', %(gem "rspec-rails", ">= 2.5.0", :group => [:test, :development])
test_value_eql? true

git_reset_app
Expand All @@ -55,7 +52,7 @@ file_include? 'config/application.rb',
test_value_eql? true

desc "rspec_with_shoulda Gemfile injection"
file_include? 'Gemfile', %(gem "rspec-rails", ">= 2.0.0.beta.10", :group => :test),
file_include? 'Gemfile', %(gem "rspec-rails", ">= 2.5.0", :group => [:test, :development]),
%(gem "shoulda", :group => :test)
test_value_eql? true

Expand Down
3 changes: 0 additions & 3 deletions hobo/test/irt/generators/user_controller.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


invoke 'hobo:user_controller', %w[-q]

eval_file '../partials/_default_users_controller_tests.rb'
Expand Down
3 changes: 0 additions & 3 deletions hobo/test/irt/generators/user_mailer.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


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

eval_file '../partials/_user_mailer_tests.rb'
Expand Down
3 changes: 0 additions & 3 deletions hobo/test/irt/generators/user_model.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


invoke 'hobo:user_model', %w(-q)

eval_file '../partials/_default_user_model_tests.rb'
Expand Down
3 changes: 0 additions & 3 deletions hobo/test/irt/generators/user_resource.irt
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
require File.expand_path('../helper.rb', __FILE__)


invoke 'hobo:user_resource' , %w(-q)

eval_file '../partials/_default_users_controller_tests.rb'
Expand Down
9 changes: 6 additions & 3 deletions hobo/test/irt/readme.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
In order to run the tests, you need git and irt installed, then run:

$ rake irt_test_all
$ rake test:irt

or if you are testing a local repo of hobo, from the hobo repo root:
or if you are testing a local repo of hobo, you need to set the:

$ rake HOBO_DEV_ROOT=. irt_test_all
$ export HOBODEV=<hobo_repo_root_path>

With HOBODEV set, if you are using rvm, the <hobo_repo_root_path>/.rvmrc file will be duplicated into
the created testapp, so your test will use the same rvm settings.

0 comments on commit 3c0ebff

Please sign in to comment.