Skip to content

Commit

Permalink
test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackPrincess committed Oct 1, 2015
1 parent 4fda6c2 commit c3b4f53
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 3 deletions.
39 changes: 39 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# A sample Guardfile
# More info at https://github.com/guard/guard#readme

## Uncomment and set this to only include directories you want to watch
# directories %w(app lib config test spec features) \
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}

## Note: if you are using the `directories` clause above and you are not
## watching the project directory ('.'), then you will want to move
## the Guardfile to a watched dir and symlink it back, e.g.
#
# $ mkdir config
# $ mv Guardfile config/
# $ ln -s config/Guardfile .
#
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"


guard :test do
watch(%r{^test/.+_test\.rb$})
watch('test/test_helper.rb') { 'test' }

# Non-rails
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }

# Rails 4
# watch(%r{^app/(.+)\.rb}) { |m| "test/#{m[1]}_test.rb" }
# watch(%r{^app/controllers/application_controller\.rb}) { 'test/controllers' }
# watch(%r{^app/controllers/(.+)_controller\.rb}) { |m| "test/integration/#{m[1]}_test.rb" }
# watch(%r{^app/views/(.+)_mailer/.+}) { |m| "test/mailers/#{m[1]}_mailer_test.rb" }
# watch(%r{^lib/(.+)\.rb}) { |m| "test/lib/#{m[1]}_test.rb" }

# Rails < 4
# watch(%r{^app/models/(.+)\.rb$}) { |m| "test/unit/#{m[1]}_test.rb" }
# watch(%r{^app/controllers/(.+)\.rb$}) { |m| "test/functional/#{m[1]}_test.rb" }
# watch(%r{^app/views/(.+)/.+\.erb$}) { |m| "test/functional/#{m[1]}_controller_test.rb" }
# watch(%r{^app/views/.+$}) { 'test/integration' }
# watch('app/controllers/application_controller.rb') { ['test/functional', 'test/integration'] }
end
4 changes: 4 additions & 0 deletions administrable.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ Gem::Specification.new do |s|
s.add_dependency 'enum_help'

s.add_development_dependency "sqlite3"
s.add_development_dependency "test-unit"
s.add_development_dependency "test-unit-notify"
s.add_development_dependency "guard"
s.add_development_dependency "guard-test"
end
4 changes: 2 additions & 2 deletions test/administrable/field_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
require 'test_helper'

class Administrable::FieldTest < ActiveSupport::TestCase
class Administrable::FieldTest < Test::Unit::TestCase
test "edit field" do
assert_not Administrable::Field.edit_fields(Company.new).include?('id')
assert_false Administrable::Field.edit_fields(Company.new).include?('id')
assert Administrable::Field.edit_fields(Company.new).include?('name')
end

Expand Down
2 changes: 1 addition & 1 deletion test/administrable_test.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'test_helper'

class AdministrableTest < ActiveSupport::TestCase
class AdministrableTest < Test::Unit::TestCase
test "truth" do
assert_kind_of Module, Administrable
end
Expand Down
11 changes: 11 additions & 0 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,14 @@
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
end

base_dir = File.expand_path(File.join(File.dirname(__FILE__), ".."))
lib_dir = File.join(base_dir, "lib")
test_dir = File.join(base_dir, "test")

$LOAD_PATH.unshift(lib_dir)

require 'test-unit'
require "test/unit/notify"

exit Test::Unit::AutoRunner.run(true, test_dir)

0 comments on commit c3b4f53

Please sign in to comment.