diff --git a/.gitignore b/.gitignore index 5b230d4..8332caf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ doc pkg *.gem -.treasure_map.rb \ No newline at end of file +.treasure_map.rb +.bundle +Gemfile*.lock +vendor/bundle diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..597fe64 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,49 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2015-09-14 16:20:12 -0400 using RuboCop version 0.34.1. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +AllCops: + Exclude: + - 'bin/**/*' + - 'vendor/**/*' + +# Offense count: 5 +Lint/HandleExceptions: + Exclude: + - 'Rakefile' + - 'test/active_record/connection_adapters/unit_record_adapter_test.rb' + - 'test/unit_record/column_test.rb' + - 'test/unit_record/disconnected_active_record_test.rb' + - 'test/unit_record/disconnected_test_case_test.rb' + +# Offense count: 2 +Lint/NestedMethodDefinition: + Exclude: + - 'lib/unit_record/disconnected_fixtures.rb' + +# Offense count: 1 +Lint/RescueException: + Exclude: + - 'test/active_record/connection_adapters/unit_record_adapter_test.rb' + +# Offense count: 1 +Metrics/AbcSize: + Max: 16 + +# Offense count: 55 +# Configuration parameters: AllowURI, URISchemes. +Metrics/LineLength: + Max: 120 + +# Offense count: 2 +# Configuration parameters: CountComments. +Metrics/MethodLength: + Max: 14 + +# Offense count: 17 +Style/Documentation: + Enabled: false diff --git a/CHANGELOG b/CHANGELOG index e443975..a8e41da 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +*0.10.0 + +* Rails 3.0 and Rails 3.2 compatibility + *0.9.1* (April 22, 2009) * Rails 2.3 compatibility @@ -13,7 +17,7 @@ ActiveRecord::Base.disconnect! :strategy => :noop or ActiveRecord::Base.disconnect! :strategy => :raise - + * Implemented as a connection adapter *0.4.1* (December 10th, 2007) diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..32fd11c --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gemspec + +gem 'rails', '~> 3.2.0' diff --git a/Gemfile.rails-3.0 b/Gemfile.rails-3.0 new file mode 100644 index 0000000..c062a3c --- /dev/null +++ b/Gemfile.rails-3.0 @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gemspec + +gem 'rails', '~> 3.0.0' diff --git a/Gemfile.rails-3.1 b/Gemfile.rails-3.1 new file mode 100644 index 0000000..5636d10 --- /dev/null +++ b/Gemfile.rails-3.1 @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gemspec + +gem 'rails', '~> 3.1.0' diff --git a/Gemfile.rails-3.2 b/Gemfile.rails-3.2 new file mode 100644 index 0000000..32fd11c --- /dev/null +++ b/Gemfile.rails-3.2 @@ -0,0 +1,5 @@ +source 'https://rubygems.org' + +gemspec + +gem 'rails', '~> 3.2.0' diff --git a/README.md b/README.md index 4870852..e30211c 100644 --- a/README.md +++ b/README.md @@ -10,15 +10,18 @@ Rationale: [http://www.dcmanges.com/blog/rails-unit-record-test-without-the-data One of the biggest benefits to disconnecting unit tests from the database is having a faster test suite. Here is the benchmark from one of my current projects: - Finished in 19.302702 seconds. - 4920 tests, 7878 assertions, 0 failures, 0 errors +``` +Finished in 19.302702 seconds. +4920 tests, 7878 assertions, 0 failures, 0 errors +``` 4 seconds per 1,000 tests is a good guideline. Installation ------------ - - gem install unit_record +``` +gem install unit_record +``` Usage ----- @@ -26,37 +29,43 @@ Usage Restructuring the Rails Test Directory -------------------------------------- -The Rails test directory typically places testing for models under test/unit and tests for controllers under test/functional. However, we need to change the definition of unit and functional. Controllers can be unit tested (mocking out models and not rendering the view). Models can be functionally tested (hitting the database). Also, each type of test needs its own test\_helper. I recommend restructuring your test directory like this: - - test - test_helper.rb - unit - unit_test_helper.rb - controllers - models - functional - functional_test_helper.rb - controllers - models +The Rails test directory typically places testing for models under `test/unit` and tests for controllers under `test/functional`. However, we need to change the definition of unit and functional. Controllers can be unit tested (mocking out models and not rendering the view). Models can be functionally tested (hitting the database). Also, each type of test needs its own test\_helper. I recommend restructuring your test directory like this: + +``` +test + test_helper.rb + unit + unit_test_helper.rb + controllers + models + functional + functional_test_helper.rb + controllers + models +``` You should move existing functional tests into functional/controllers. You will also need to change the require line at the top of those tests to require the functional\_test\_helper.rb file instead of the test\_helper.rb file. -The functional_test_helper.rb file only needs to require test_helper.rb: +The `functional_test_helper.rb` file only needs to `require test_helper.rb`: - require File.dirname(__FILE__) + "/../test_helper" +```ruby +require File.dirname(__FILE__) + "/../test_helper" +``` For moving unit tests, you have a few options. I recommend moving them to unit/models and then disconnecting your unit tests from the database. Any tests that fail should then be modified to not hit the database or moved to functional/models. Usage ----- -In the test/unit/unit\_test\_helper.rb file you created when restructuring your test directory, you should add these lines: +In the `test/unit/unit\_test\_helper.rb` file you created when restructuring your test directory, you should add these lines: - require File.dirname(__FILE__) + "/../test_helper" - require "unit_record" - ActiveRecord::Base.disconnect! +```ruby +require File.dirname(__FILE__) + "/../test_helper" +require "unit_record" +ActiveRecord::Base.disconnect! +``` -The disconnect! method will do everything necessary to run your unit tests without hitting the database. +The `disconnect!` method will do everything necessary to run your unit tests without hitting the database. Strategy -------- @@ -65,46 +74,58 @@ There are two options for what should happen if you hit the database. You can ei If you want to raise an exception: - ActiveRecord::Base.disconnect! :strategy => :raise +```ruby +ActiveRecord::Base.disconnect! :strategy => :raise - Person.find(:all) - #=> RuntimeError: ActiveRecord is disconnected; database access is unavailable in unit tests. +Person.find(:all) +#=> RuntimeError: ActiveRecord is disconnected; database access is unavailable in unit tests. +``` If you want to no-op: - ActiveRecord::Base.disconnect! :strategy => :noop +```ruby +ActiveRecord::Base.disconnect! :strategy => :noop - Person.find(:all) - #=> [] +Person.find(:all) +#=> [] +``` You can also change strategies within a block: - ActiveRecord::Base.connection.change_strategy(:raise) do - Person.find(:all) - #=> RuntimeError: ActiveRecord is disconnected; database access is unavailable in unit tests. - end +```ruby +ActiveRecord::Base.connection.change_strategy(:raise) do + Person.find(:all) + #=> RuntimeError: ActiveRecord is disconnected; database access is unavailable in unit tests. +end - ActiveRecord::Base.connection.change_strategy(:noop) do - Person.find(:all) - #=> [] - end +ActiveRecord::Base.connection.change_strategy(:noop) do + Person.find(:all) + #=> [] +end +``` Association Stubbing -------------------- One painful aspect of unit testing ActiveRecord classes is setting associations. Because Rails does type checking when setting an association, you'll receive an exception if you try to use a stub in place of the expected class. - Pet.new :owner => stub("person") - #=> ActiveRecord::AssociationTypeMismatch: Person(#16620740) expected, got Mocha::Mock(#11567340) +```ruby +Pet.new :owner => stub("person") +#=> ActiveRecord::AssociationTypeMismatch: Person(#16620740) expected, got Mocha::Mock(#11567340) +``` If you're using mocha, you can have UnitRecord stub associations. To enable association stubbing: - ActiveRecord::Base.disconnect! :stub_associations => true +```ruby +ActiveRecord::Base.disconnect! :stub_associations => true +``` The above example would no longer raise an exception. It would be the equivalent of: - pet = Pet.new - pet.stubs(:owner).returns(stub("person")) +```ruby +pet = Pet.new +pet.stubs(:owner).returns(stub("person")) +``` Note that using this approach, the setter for the association will not work for that instance. diff --git a/Rakefile b/Rakefile index e792aad..041a64f 100644 --- a/Rakefile +++ b/Rakefile @@ -1,95 +1,52 @@ require 'rake' require 'rake/testtask' +require 'spec/rake/spectask' +require 'rubocop/rake_task' -desc "Default: run tests" -task :default => %w[test:multi_verbose spec] +desc 'Default: run tests' +task default: %w(rubocop test) -Rake::TestTask.new("test") do |t| - t.pattern = "test/**/*_test.rb" +RuboCop::RakeTask.new(:rubocop) + +Rake::TestTask.new('test') do |t| + t.pattern = 'test/**/*_test.rb' t.verbose = true end +Spec::Rake::SpecTask.new(:spec) do |t| + t.spec_files = %w(test/sample_spec.rb) +end + begin - require "rcov/rcovtask" - desc "run tests with rcov" + require 'rcov/rcovtask' + desc 'run tests with rcov' Rcov::RcovTask.new do |t| - t.pattern = "test/**/*_test.rb" - t.rcov_opts << ["--no-html", "--exclude 'Library,#{Gem.path.join(',')}'"] + t.pattern = 'test/**/*_test.rb' + t.rcov_opts << ['--no-html', "--exclude 'Library,#{Gem.path.join(',')}'"] t.verbose = true end rescue LoadError end -require "date" - -gem_spec = Gem::Specification.new do |s| - s.name = "unit_record" - s.summary = "UnitRecord enables unit testing without hitting the database." - s.version = "0.9.1" - s.author = "Dan Manges" - s.description = "UnitRecord enables unit testing without hitting the database." - s.email = "daniel.manges@gmail.com" - s.homepage = "http://unit-test-ar.rubyforge.org" - s.rubyforge_project = "unit-test-ar" - - s.has_rdoc = false - - s.autorequire = "unit_record" - s.files = FileList['{lib,test,vendor}/**/*.rb', 'CHANGELOG', 'LICENSE', 'README.markdown', 'Rakefile'].to_a -end - -task :gem => %w[test:multi] do - Gem::Builder.new(gem_spec).build -end - namespace :gemspec do - desc "generates unit-record.gemspec" + desc 'generates unit-record.gemspec' task :generate do - File.open("unit-record.gemspec", "w") do |f| - f.puts "# this file is generated by rake gemspec:generate for github" + File.open('unit-record.gemspec', 'w') do |f| + f.puts '# this file is generated by rake gemspec:generate for github' f.write gem_spec.to_ruby end end end task :readme do - require "rubygems"; gem "BlueCloth"; require "BlueCloth"; require 'tmpdir' + require 'rubygems' + gem 'BlueCloth' + require 'BlueCloth' + require 'tmpdir' file = "#{Dir.tmpdir}/readme.html" - File.open(file, "w") { |f| f.write BlueCloth.new(File.read("README.markdown")).to_html } + File.open(file, 'w') { |f| f.write BlueCloth.new(File.read('README.markdown')).to_html } sh "open #{file}" end -RAILS_VERSIONS = %w[1.2.6 2.0.2 2.1.0 2.1.1 2.2.2 2.3.1] - -namespace :test do - desc "test with multiple versions of rails" - task :multi do - RAILS_VERSIONS.each do |rails_version| - puts "Testing with Rails #{rails_version}" - sh "RAILS_VERSION='#{rails_version}' rake test > /dev/null 2>&1" - end - end - - task :multi_verbose do - (RAILS_VERSIONS - %w[]).each do |rails_version| - task = defined?(Rcov) ? "rcov" : "test" - puts "Testing with Rails #{rails_version}" - sh "RAILS_VERSION='#{rails_version}' rake #{task}" - end - end -end - -begin - gem "rspec" - require "spec/rake/spectask" - Spec::Rake::SpecTask.new(:spec) do |t| - t.spec_files = %w[test/sample_spec.rb] - end -rescue LoadError - task :spec do - puts "== RSpec failed to load" - end -end - -desc "pre-commit task" -task :pc => %w[test:multi spec gemspec:generate] +desc 'pre-commit task' +task pc: %w(test:multi spec gemspec:generate) diff --git a/lib/active_record/connection_adapters/unit_record_adapter.rb b/lib/active_record/connection_adapters/unit_record_adapter.rb index 6f51cf8..73e1aaa 100644 --- a/lib/active_record/connection_adapters/unit_record_adapter.rb +++ b/lib/active_record/connection_adapters/unit_record_adapter.rb @@ -1,101 +1,121 @@ -class ActiveRecord::ConnectionAdapters::UnitRecordAdapter < ::ActiveRecord::ConnectionAdapters::AbstractAdapter - EXCEPTION_MESSAGE = "ActiveRecord is disconnected; database access is unavailable in unit tests." - - def initialize(config = {}) - super - @strategy = config[:strategy] || :raise - @cached_columns = {"schema_info" => []} - end - - def columns(table_name, name = nil)#:nodoc: - @cached_columns[table_name.to_s] || - raise("Columns are not cached for '#{table_name}' - check schema.rb") +class Visitor + def accept(_ast) + '' end +end +module ActiveRecord + module ConnectionAdapters + class UnitRecordAdapter < ::ActiveRecord::ConnectionAdapters::AbstractAdapter + EXCEPTION_MESSAGE = 'ActiveRecord is disconnected; database access is unavailable in unit tests.' + ID = 'id'.freeze + STRATEGIES = [:noop, :raise].freeze - def create_table(table_name, options={}) - table_definition = ActiveRecord::ConnectionAdapters::TableDefinition.new(self) - table_definition.primary_key(options[:primary_key] || "id") unless options[:id] == false - yield table_definition - @cached_columns[table_name.to_s] = - table_definition.columns.map do |c| - ActiveRecord::ConnectionAdapters::Column.new(c.name.to_s, c.default, c.sql_type, c.null) + def initialize(config = {}) + super + @strategy = config[:strategy] || :raise + @cached_columns = { 'schema_info' => [] } end - end - - def native_database_types - # Copied from the MysqlAdapter so ColumnDefinition#sql_type will work - { - :primary_key => "int(11) DEFAULT NULL auto_increment PRIMARY KEY", - :string => { :name => "varchar", :limit => 255 }, - :text => { :name => "text" }, - :integer => { :name => "int", :limit => 11 }, - :float => { :name => "float" }, - :decimal => { :name => "decimal" }, - :datetime => { :name => "datetime" }, - :timestamp => { :name => "datetime" }, - :time => { :name => "time" }, - :date => { :name => "date" }, - :binary => { :name => "blob" }, - :boolean => { :name => "tinyint", :limit => 1 } - } - end - - def change_strategy(new_strategy, &block) - unless [:noop, :raise].include?(new_strategy.to_sym) - raise ArgumentError, "#{new_strategy.inspect} is not a valid strategy - valid values are :noop and :raise" - end - begin - old_strategy = @strategy - @strategy = new_strategy.to_sym - yield - ensure - @strategy = old_strategy - end - end - - def execute(sql, name = nil) - raise_or_noop - end - - def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) - raise_or_noop - end if defined?(Rails::VERSION::MAJOR) && Rails::VERSION::MAJOR == 1 - def select_rows(sql, name = nil) - raise_or_noop [] - end - - def rename_table(table_name, new_name) - raise_or_noop - end - - def change_column(table_name, column_name, type, options = {}) - raise_or_noop - end - - def change_column_default(table_name, column_name, default) - raise_or_noop - end + def columns(table_name, _name = nil) #:nodoc: + @cached_columns[table_name.to_s] || + fail("Columns are not cached for '#{table_name}' - check schema.rb") + end - def rename_column(table_name, column_name, new_column_name) - raise_or_noop - end + def create_table(table_name, options = {}) + table_definition = ActiveRecord::ConnectionAdapters::TableDefinition.new(self) + table_definition.primary_key(options[:primary_key] || ID) unless options[:id] == false + yield table_definition + @cached_columns[table_name.to_s] = + table_definition.columns.map do |c| + ActiveRecord::ConnectionAdapters::Column.new(c.name.to_s, c.default, c.sql_type, c.null) + end + end - def add_foreign_key(table_name, column_names, target_table, key_name, options = {}) - raise_or_noop - end + def primary_key(*_args) + ID + end - def tables - @cached_columns.keys - end + def native_database_types + # Copied from the MysqlAdapter so ColumnDefinition#sql_type will work + { + primary_key: 'int(11) DEFAULT NULL auto_increment PRIMARY KEY', + string: { name: 'varchar', limit: 255 }, + text: { name: 'text' }, + integer: { name: 'int', limit: 11 }, + float: { name: 'float' }, + decimal: { name: 'decimal' }, + datetime: { name: 'datetime' }, + timestamp: { name: 'datetime' }, + time: { name: 'time' }, + date: { name: 'date' }, + binary: { name: 'blob' }, + boolean: { name: 'tinyint', limit: 1 } + } + end - protected - - def raise_or_noop(noop_return_value = nil) - @strategy == :raise ? raise(EXCEPTION_MESSAGE) : noop_return_value - end - - def select(sql, name = nil) - raise_or_noop [] + def change_strategy(new_strategy, &_block) + unless STRATEGIES.include?(new_strategy.to_sym) + fail ArgumentError, "#{new_strategy.inspect} is not a valid strategy - valid values are :noop and :raise" + end + + begin + old_strategy = @strategy + @strategy = new_strategy.to_sym + yield + ensure + @strategy = old_strategy + end + end + + def execute(*_args) + raise_or_noop + end + + def select_rows(*_args) + raise_or_noop [] + end + + def rename_table(*_args) + raise_or_noop + end + + def change_column(*_args) + raise_or_noop + end + + def change_column_default(*_args) + raise_or_noop + end + + def rename_column(*_args) + raise_or_noop + end + + def add_foreign_key(*_args) + raise_or_noop + end + + def tables + @cached_columns.keys + end + + def visitor + Visitor.new + end + + def quote_column_name(column_name) + column_name.to_s + end + + protected + + def raise_or_noop(noop_return_value = nil) + @strategy == :raise ? fail(EXCEPTION_MESSAGE) : noop_return_value + end + + def select(*_args) + raise_or_noop [] + end + end end end diff --git a/lib/unit_record.rb b/lib/unit_record.rb index 4a15435..944d1ca 100644 --- a/lib/unit_record.rb +++ b/lib/unit_record.rb @@ -1,33 +1,34 @@ module UnitRecord def self.rails_version - if defined?(Rails::VERSION::STRING) - Rails::VERSION::STRING - else - nil - end + Rails::VERSION::STRING if defined?(Rails::VERSION::STRING) end def self.base_rails_test_class - if rails_version && rails_version >= "2.3.1" + if rails_version && rails_version >= '2.3.1' ActiveSupport::TestCase - else + elsif defined?(Test::Unit::TestCase) Test::Unit::TestCase + else + Class.new do + def self.disconnect!(*_args) + end + end end end end -require "unit_record/association_stubbing" -require "unit_record/column_extension" -require "unit_record/disconnected_active_record" -require "unit_record/disconnected_test_case" -require "unit_record/disconnected_fixtures" -require "active_record/connection_adapters/unit_record_adapter" +require 'unit_record/association_stubbing' +require 'unit_record/column_extension' +require 'unit_record/disconnected_active_record' +require 'unit_record/disconnected_test_case' +require 'unit_record/disconnected_fixtures' +require 'active_record/connection_adapters/unit_record_adapter' -require "active_record/fixtures" +require 'active_record/fixtures' ActiveRecord::ConnectionAdapters::Column.send :include, UnitRecord::ColumnExtension ActiveRecord::Base.extend UnitRecord::DisconnectedActiveRecord UnitRecord.base_rails_test_class.extend UnitRecord::DisconnectedTestCase -Fixtures.extend UnitRecord::DisconnectedFixtures +Fixtures.extend UnitRecord::DisconnectedFixtures if defined?(Fixtures) ActiveRecord::Base.class_eval do def self.unit_record_connection(config) diff --git a/lib/unit_record/association_stubbing.rb b/lib/unit_record/association_stubbing.rb index 323293c..f80abc9 100644 --- a/lib/unit_record/association_stubbing.rb +++ b/lib/unit_record/association_stubbing.rb @@ -1,39 +1,36 @@ module UnitRecord module AssociationStubbing - - private - - def initialize_with_association_stubbing(attributes = {}) - attributes ||= {} - associations = extract_associations attributes - initialize_without_association_stubbing attributes - stub_associations associations - end - protected - + def extract_associations(attributes = {}) - attributes.inject({}) do |associations,(attr,value)| + attributes.each_with_object({}) do |(attr, value), associations| next associations unless self.class.reflections.keys.include? attr unless value.is_a?(self.class.reflections[attr].klass) associations[attr] = attributes.delete attr end - associations end end - + def stub_associations(associations = {}) - associations.each do |attr,value| - self.stubs(attr).returns(value) + associations.each do |attr, value| + stubs(attr).returns(value) end end def self.included(klass) klass.class_eval do - unless (instance_methods + private_instance_methods).include?("initialize_without_association_stubbing") + unless (instance_methods + private_instance_methods).include?(:initialize_without_association_stubbing) alias_method_chain :initialize, :association_stubbing end end end + + private + + def initialize_with_association_stubbing(attributes = {}) + associations = extract_associations attributes + initialize_without_association_stubbing attributes + stub_associations associations + end end end diff --git a/lib/unit_record/column_extension.rb b/lib/unit_record/column_extension.rb index fb166c5..9d800fb 100644 --- a/lib/unit_record/column_extension.rb +++ b/lib/unit_record/column_extension.rb @@ -1,13 +1,15 @@ module UnitRecord module ColumnExtension + TINY_INT_1 = 'tinyint(1)'.freeze + def self.included(base) base.class_eval do alias_method_chain :simplified_type, :boolean end end - + def simplified_type_with_boolean(field_type) - return :boolean if field_type.to_s.downcase.index("tinyint(1)") + return :boolean if field_type.to_s.downcase.index(TINY_INT_1) simplified_type_without_boolean field_type end diff --git a/lib/unit_record/disconnected_active_record.rb b/lib/unit_record/disconnected_active_record.rb index 6a5af1a..166aac1 100644 --- a/lib/unit_record/disconnected_active_record.rb +++ b/lib/unit_record/disconnected_active_record.rb @@ -6,15 +6,15 @@ def disconnected? def disconnect!(options = {}) return if disconnected? - establish_connection options.merge(:adapter => "unit_record") + establish_connection options.merge(adapter: 'unit_record') if options[:stub_associations] ActiveRecord::Base.send :include, UnitRecord::AssociationStubbing end - Fixtures.disconnect! + Fixtures.disconnect! if defined?(Fixtures) UnitRecord.base_rails_test_class.disconnect! ActiveRecord::Migration.verbose = false ActiveRecord::Base.connection.change_strategy(:noop) do - load(RAILS_ROOT + "/db/schema.rb") + load(Rails.root.join('db', 'schema.rb')) if defined?(Rails) end end end diff --git a/lib/unit_record/disconnected_fixtures.rb b/lib/unit_record/disconnected_fixtures.rb index 4b95acc..296f400 100644 --- a/lib/unit_record/disconnected_fixtures.rb +++ b/lib/unit_record/disconnected_fixtures.rb @@ -2,7 +2,8 @@ module UnitRecord module DisconnectedFixtures def disconnect! (class << self; self; end).class_eval do - def create_fixtures(*args); end + def create_fixtures(*_args); end + def reset_cache; end end end diff --git a/lib/unit_record/disconnected_test_case.rb b/lib/unit_record/disconnected_test_case.rb index 9807073..0035f0f 100644 --- a/lib/unit_record/disconnected_test_case.rb +++ b/lib/unit_record/disconnected_test_case.rb @@ -1,11 +1,12 @@ module UnitRecord module DisconnectedTestCase def disconnect! - self.use_transactional_fixtures = false if defined?(self.use_transactional_fixtures) + self.use_transactional_fixtures = false if defined?(use_transactional_fixtures) class_eval do - def self.fixtures(*args) - raise "Fixtures cannot be used with UnitRecord. ActiveRecord is disconnected; database access is unavailable in unit tests." + def self.fixtures(*_args) + fail 'Fixtures cannot be used with UnitRecord. ' \ + 'ActiveRecord is disconnected; database access is unavailable in unit tests.' end end end diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..768c083 --- /dev/null +++ b/test.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +BUNDLE_GEMFILE=Gemfile.rails-3.2 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.2 bundle exec rake +BUNDLE_GEMFILE=Gemfile.rails-3.1 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.1 bundle exec rake +BUNDLE_GEMFILE=Gemfile.rails-3.0 bundle && BUNDLE_GEMFILE=Gemfile.rails-3.0 bundle exec rake diff --git a/test/active_record/connection_adapters/unit_record_adapter_test.rb b/test/active_record/connection_adapters/unit_record_adapter_test.rb index c68190a..38f1f70 100644 --- a/test/active_record/connection_adapters/unit_record_adapter_test.rb +++ b/test/active_record/connection_adapters/unit_record_adapter_test.rb @@ -1,103 +1,103 @@ -require File.dirname(__FILE__) + "/../../test_helper" +require File.dirname(__FILE__) + '/../../test_helper' functional_tests do - - test "reconnect works" do + test 'reconnect works' do ActiveRecord::Base.connection.reconnect! assert_kind_of ActiveRecord::ConnectionAdapters::UnitRecordAdapter, - ActiveRecord::Base.connection + ActiveRecord::Base.connection end - test "find(:all)" do + test 'all arel' do ActiveRecord::Base.connection.change_strategy(:raise) do - assert_raises(RuntimeError) { Person.find(:all) } + assert_raises(RuntimeError) do + Person.all + end end ActiveRecord::Base.connection.change_strategy(:noop) do - assert_equal [], Person.find(:all) + assert_equal [], Person.all end end - - test "execute raises an exception" do + + test 'execute raises an exception' do assert_raises_disconnected_exception do - ActiveRecord::Base.connection.execute "SELECT 1" + ActiveRecord::Base.connection.execute 'SELECT 1' end end - - test "select_rows raises an exception" do + + test 'select_rows raises an exception' do assert_raises_disconnected_exception do - ActiveRecord::Base.connection.select_rows "SELECT * FROM people" + ActiveRecord::Base.connection.select_rows 'SELECT * FROM people' end end - test "select raises an exception" do + test 'select raises an exception' do assert_raises_disconnected_exception do - ActiveRecord::Base.connection.send :select, "SELECT * FROM people" + ActiveRecord::Base.connection.send :select, 'SELECT * FROM people' end end - - test "rename_table raises an exception" do + + test 'rename_table raises an exception' do assert_raises_disconnected_exception do - ActiveRecord::Base.connection.rename_table "people", "persons" + ActiveRecord::Base.connection.rename_table 'people', 'persons' end end - test "change_column raises an exception" do + test 'change_column raises an exception' do assert_raises_disconnected_exception do - ActiveRecord::Base.connection.change_column "people", "first_name", :string, :null => false + ActiveRecord::Base.connection.change_column 'people', 'first_name', :string, null: false end end - test "change_column_default raises an exception" do + test 'change_column_default raises an exception' do assert_raises_disconnected_exception do - ActiveRecord::Base.connection.change_column_default "people", "first_person", "george" + ActiveRecord::Base.connection.change_column_default 'people', 'first_person', 'george' end end - test "rename_column raises an exception" do + test 'rename_column raises an exception' do assert_raises_disconnected_exception do - ActiveRecord::Base.connection.rename_column "people", "first_name", "name_first" + ActiveRecord::Base.connection.rename_column 'people', 'first_name', 'name_first' end end - test "insert raises an exception" do + test 'insert raises an exception' do assert_raises_disconnected_exception do - ActiveRecord::Base.connection.rename_column "people", "first_name", "name_first" + ActiveRecord::Base.connection.rename_column 'people', 'first_name', 'name_first' end end - - test "initialize can set strategy" do - ActiveRecord::Base.establish_connection :adapter => "unit_record", :strategy => :noop - assert_nil ActiveRecord::Base.connection.execute("SELECT 1") - ActiveRecord::Base.establish_connection :adapter => "unit_record", :strategy => :raise - assert_raises(RuntimeError) { ActiveRecord::Base.connection.execute("SELECT 1") } + + test 'initialize can set strategy' do + ActiveRecord::Base.establish_connection adapter: 'unit_record', strategy: :noop + assert_nil ActiveRecord::Base.connection.execute('SELECT 1') + ActiveRecord::Base.establish_connection adapter: 'unit_record', strategy: :raise + assert_raises(RuntimeError) { ActiveRecord::Base.connection.execute('SELECT 1') } end - test "noop" do + test 'noop' do ActiveRecord::Base.connection.change_strategy(:noop) do - assert_nil ActiveRecord::Base.connection.execute("SELECT 1") - assert_nil ActiveRecord::Base.connection.insert("INSERT INTO ...") - assert_equal [], ActiveRecord::Base.connection.select_rows("SELECT * FROM people") - assert_equal [], ActiveRecord::Base.connection.send(:select, "SELECT * FROM people") - assert_nil ActiveRecord::Base.connection.rename_table("people", "persons") - assert_nil ActiveRecord::Base.connection.change_column("people", "first_name", :string, :null => false) - assert_nil ActiveRecord::Base.connection.change_column_default("people", "first_person", "george") - assert_nil ActiveRecord::Base.connection.rename_column("people", "first_name", "name_first") + assert_nil ActiveRecord::Base.connection.execute('SELECT 1') + assert_equal [], ActiveRecord::Base.connection.select_rows('SELECT * FROM people') + assert_equal [], ActiveRecord::Base.connection.send(:select, 'SELECT * FROM people') + assert_nil ActiveRecord::Base.connection.rename_table('people', 'persons') + assert_nil ActiveRecord::Base.connection.change_column('people', 'first_name', :string, null: false) + assert_nil ActiveRecord::Base.connection.change_column_default('people', 'first_person', 'george') + assert_nil ActiveRecord::Base.connection.rename_column('people', 'first_name', 'name_first') end end - - test "change_strategy raises if invalid strategy" do + + test 'change_strategy raises if invalid strategy' do assert_nothing_raised { ActiveRecord::Base.connection.change_strategy(:noop) {} } assert_nothing_raised { ActiveRecord::Base.connection.change_strategy(:raise) {} } assert_raises(ArgumentError) { ActiveRecord::Base.connection.change_strategy(:bogus) {} } end - def assert_raises_disconnected_exception(&block) + def assert_raises_disconnected_exception(&_block) exception = nil begin yield rescue Exception => exception end assert_not_nil exception - assert_equal "ActiveRecord is disconnected; database access is unavailable in unit tests.", exception.message + assert_equal 'ActiveRecord is disconnected; database access is unavailable in unit tests.', exception.message end end diff --git a/test/db/schema.rb b/test/db/schema.rb index a4b9ea8..c28535a 100644 --- a/test/db/schema.rb +++ b/test/db/schema.rb @@ -1,26 +1,26 @@ -ActiveRecord::Schema.define(:version => 0) do - create_table :preferences, :force => true do |t| +ActiveRecord::Schema.define do + create_table :preferences, force: true do |t| t.column :some_count, :integer - t.column :show_help, :boolean, :default => true + t.column :show_help, :boolean, default: true end - create_table :people, :force => true do |t| + create_table :people, force: true do |t| t.column :first_name, :string t.column :last_name, :string end - - create_table "profiles", :force => true do |t| - t.column "description", :string - t.column "person_id", :integer + + create_table 'profiles', force: true do |t| + t.column 'description', :string + t.column 'person_id', :integer end - - create_table :pets, :force => true do |t| + + create_table :pets, force: true do |t| t.column :name, :string end - - create_table :foofoo, :force => true do |t| + + create_table :foofoo, force: true do |t| t.column :bar, :string end - - add_index "people", ["first_name"] + + add_index 'people', ['first_name'] end diff --git a/test/sample_spec.rb b/test/sample_spec.rb index fae257c..08b8541 100644 --- a/test/sample_spec.rb +++ b/test/sample_spec.rb @@ -1,44 +1,41 @@ -require "rubygems" -gem "rspec", "1.1.11" -require "test/unit" -require "spec" +require 'rubygems' +require 'spec' -$:.unshift(File.dirname(__FILE__) + '/../lib') +$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') -RAILS_ROOT = File.dirname(__FILE__) - -if rails_version = ENV['RAILS_VERSION'] - gem "rails", rails_version +require 'rails/all' +module Rails + class << self + def root + @root ||= Pathname.new(File.dirname(__FILE__)) + end + end end -require "rails/version" + puts "==== Testing with Rails #{Rails::VERSION::STRING} ====" -require 'active_record' -require 'active_record/fixtures' -require "action_controller" -require "action_controller/test_process" -require "unit_record" +require 'unit_record' -if UnitRecord.rails_version >= "2.3" +if UnitRecord.rails_version >= '2.3' ActiveSupport::TestCase.class_eval { include ActiveRecord::TestFixtures } end # Needed because of this line in setup_with_fixtures and teardown_with_fixtures: # return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank? -ActiveRecord::Base.configurations = {"irrelevant" => {:adapter => "stub"}} +ActiveRecord::Base.configurations = { 'irrelevant' => { adapter: 'stub' } } -ActiveRecord::Base.disconnect! :strategy => :raise, :stub_associations => true +ActiveRecord::Base.disconnect! strategy: :raise, stub_associations: true describe UnitRecord do - it "disconnects tests from the database" do + it 'disconnects tests from the database' do lambda do - ActiveRecord::Base.connection.select_value("SELECT 1") + ActiveRecord::Base.connection.select_value('SELECT 1') end.should raise_error end - it "can change strategy to noop" do + it 'can change strategy to noop' do ActiveRecord::Base.connection.change_strategy(:noop) do - ActiveRecord::Base.connection.select_value("SELECT 1").should == nil + ActiveRecord::Base.connection.select_value('SELECT 1').should.nil? end end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 4f57084..b1ed9ee 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -1,73 +1,71 @@ unless defined?(TEST_HELPER_LOADED) -TEST_HELPER_LOADED = true -$:.unshift(File.dirname(__FILE__) + '/../lib') -RAILS_ROOT = File.dirname(__FILE__) + TEST_HELPER_LOADED = true + $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib') -require 'rubygems' -require 'test/unit' + require 'rubygems' + require 'rails/all' -if rails_version = ENV['RAILS_VERSION'] - gem "rails", rails_version -end -require "rails/version" -puts "==== Testing with Rails #{Rails::VERSION::STRING} ====" -require 'active_record' -require 'active_record/fixtures' -require "action_controller" -if Rails::VERSION::MAJOR == 2 - require "action_controller/test_case" -end -require "action_controller/test_process" + module Rails + class << self + def root + @root ||= Pathname.new(File.dirname(__FILE__)) + end + end + end -begin - gem "mocha" - require 'mocha' -rescue LoadError, Gem::LoadError - raise "need mocha to test" -end -$LOAD_PATH << File.dirname(__FILE__) + "/../vendor/dust-0.1.6/lib" -require 'dust' -Test::Unit::TestCase.disallow_setup! + if Rails::VERSION::MAJOR > 3 && Rails::VERSION::MINOR > 0 + if defined?(Bundler) + # If you precompile assets before deploying to production, use this line + Bundler.require(*Rails.groups(assets: %w(development test))) + # If you want your assets lazily compiled in production, use this line + # Bundler.require(:default, :assets, Rails.env) + end + end -$LOAD_PATH << File.dirname(__FILE__) + "/../lib" -require "unit_record" + require 'action_controller/test_case' if Rails::VERSION::MAJOR == 2 -if UnitRecord.rails_version >= "2.3" - require "active_support/test_case" - ActiveSupport::TestCase.class_eval { include ActiveRecord::TestFixtures } -end + require 'dust' + Test::Unit::TestCase.disallow_setup! -UnitRecord.base_rails_test_class.use_transactional_fixtures = true + $LOAD_PATH << File.dirname(__FILE__) + '/../lib' + require 'unit_record' -# Needed because of this line in setup_with_fixtures and teardown_with_fixtures: -# return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank? -ActiveRecord::Base.configurations = {"irrelevant" => {:adapter => "stub"}} + if UnitRecord.rails_version >= '2.3' + require 'active_support/test_case' + ActiveSupport::TestCase.class_eval { include ActiveRecord::TestFixtures } + end -class Preference < ActiveRecord::Base -end + UnitRecord.base_rails_test_class.use_transactional_fixtures = true -class Person < ActiveRecord::Base - has_many :pets - has_one :profile -end + # Needed because of this line in setup_with_fixtures and teardown_with_fixtures: + # return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank? + ActiveRecord::Base.configurations = { 'irrelevant' => { adapter: 'stub' } } -class Profile < ActiveRecord::Base - belongs_to :person -end + class Preference < ActiveRecord::Base + end -class Pet < ActiveRecord::Base - belongs_to :person -end + class Person < ActiveRecord::Base + has_many :pets + has_one :profile + end -class Foo < ActiveRecord::Base - set_table_name :foofoo -end + class Profile < ActiveRecord::Base + belongs_to :person + end -class DoesNotExist < ActiveRecord::Base - set_table_name "table_does_not_exist" -end + class Pet < ActiveRecord::Base + belongs_to :person + end + + class Foo < ActiveRecord::Base + self.table_name = 'foofoo' + end + + class DoesNotExist < ActiveRecord::Base + self.table_name = 'table_does_not_exist' + end -ActiveRecord::Base.disconnect! :strategy => :raise, :stub_associations => true -# make sure calling disconnect multiple times does not cause problems -ActiveRecord::Base.disconnect! :strategy => :raise, :stub_associations => true + ActiveRecord::Base.disconnect! strategy: :raise, stub_associations: true + # make sure calling disconnect multiple times does not cause problems + ActiveRecord::Base.disconnect! strategy: :raise, stub_associations: true end diff --git a/test/unit_record/association_stubbing_test.rb b/test/unit_record/association_stubbing_test.rb index 5edb341..69fc7dc 100644 --- a/test/unit_record/association_stubbing_test.rb +++ b/test/unit_record/association_stubbing_test.rb @@ -1,37 +1,37 @@ -require File.dirname(__FILE__) + "/../test_helper" +require File.dirname(__FILE__) + '/../test_helper' functional_tests do - - test "stubbing a has_many" do + test 'stubbing a has_many' do pets = [stub, stub] - person = Person.new :pets => pets + person = Person.new pets: pets assert_equal pets, person.pets end - - test "stubbing a belongs_to" do + + test 'stubbing a belongs_to' do person = stub - pet = Pet.new :person => person + pet = Pet.new person: person assert_equal person, pet.person end - - test "using correct classes does not stub" do - person = Person.new(:first_name => "Dan") - pet = Pet.new :person => person - pet.person = Person.new(:first_name => "Tom") - assert_equal "Tom", pet.person.first_name + + test 'using correct classes does not stub' do + person = Person.new(first_name: 'Dan') + pet = Pet.new person: person + pet.person = Person.new(first_name: 'Tom') + assert_equal 'Tom', pet.person.first_name end - test "using other than correct classes does stub" do + test 'using other than correct classes does stub' do person = Object.new - def person.first_name; "Dan"; end - pet = Pet.new :person => person - pet.person = Person.new(:first_name => "Tom") - assert_equal "Dan", pet.person.first_name + def person.first_name + 'Dan' + end + pet = Pet.new person: person + pet.person = Person.new(first_name: 'Tom') + assert_equal 'Dan', pet.person.first_name end - - test "multiple includes doesn't hurt" do + + test 'multiple includes does not hurt' do ActiveRecord::Base.send :include, UnitRecord::AssociationStubbing Person.new end - end diff --git a/test/unit_record/column_cacher_test.rb b/test/unit_record/column_cacher_test.rb index 1943747..d683b96 100644 --- a/test/unit_record/column_cacher_test.rb +++ b/test/unit_record/column_cacher_test.rb @@ -1,26 +1,26 @@ -require File.dirname(__FILE__) + "/../test_helper" +require File.dirname(__FILE__) + '/../test_helper' functional_tests do - test "caching columns with no defaults or not nulls" do + test 'caching columns with no defaults or not nulls' do expected = [ - ActiveRecord::ConnectionAdapters::Column.new("id", nil, "int(11) DEFAULT NULL auto_increment PRIMARY KEY", nil), - ActiveRecord::ConnectionAdapters::Column.new("first_name", nil, "varchar(255)", nil), - ActiveRecord::ConnectionAdapters::Column.new("last_name", nil, "varchar(255)", nil) + ActiveRecord::ConnectionAdapters::Column.new('id', nil, 'int(11) DEFAULT NULL auto_increment PRIMARY KEY', nil), + ActiveRecord::ConnectionAdapters::Column.new('first_name', nil, 'varchar(255)', nil), + ActiveRecord::ConnectionAdapters::Column.new('last_name', nil, 'varchar(255)', nil) ] expected[0].primary = true expected[1..-1].each { |column| column.primary = false } assert_equal expected, Person.columns end - - test "caching column with default" do - expected = ActiveRecord::ConnectionAdapters::Column.new("show_help", true, "tinyint(1)", nil) + + test 'caching column with default' do + expected = ActiveRecord::ConnectionAdapters::Column.new('show_help', true, 'tinyint(1)', nil) expected.primary = false - assert_equal expected, Preference.columns.detect { |c| c.name == "show_help" } + assert_equal expected, Preference.columns.detect { |c| c.name == 'show_help' } end - - test "boolean columns" do - expected = ActiveRecord::ConnectionAdapters::Column.new("show_help", true, "tinyint(1)", nil) + + test 'boolean columns' do + expected = ActiveRecord::ConnectionAdapters::Column.new('show_help', true, 'tinyint(1)', nil) expected.primary = false - assert_equal :boolean, Preference.columns.detect { |c| c.name == "show_help" }.type + assert_equal :boolean, Preference.columns.detect { |c| c.name == 'show_help' }.type end end diff --git a/test/unit_record/column_extension_test.rb b/test/unit_record/column_extension_test.rb index 2c67b4f..23c4cbf 100644 --- a/test/unit_record/column_extension_test.rb +++ b/test/unit_record/column_extension_test.rb @@ -1,33 +1,33 @@ -require File.dirname(__FILE__) + "/../test_helper" +require File.dirname(__FILE__) + '/../test_helper' unit_tests do - test "equality" do - column1 = ActiveRecord::ConnectionAdapters::Column.new("name", nil, :string, nil) - column2 = ActiveRecord::ConnectionAdapters::Column.new("name", nil, :string, nil) + test 'equality' do + column1 = ActiveRecord::ConnectionAdapters::Column.new('name', nil, :string, nil) + column2 = ActiveRecord::ConnectionAdapters::Column.new('name', nil, :string, nil) assert_equal column1, column2 end - - test "non-equality on name" do - column1 = ActiveRecord::ConnectionAdapters::Column.new("name", nil, :string, nil) - column2 = ActiveRecord::ConnectionAdapters::Column.new("different name", nil, :string, nil) + + test 'non-equality on name' do + column1 = ActiveRecord::ConnectionAdapters::Column.new('name', nil, :string, nil) + column2 = ActiveRecord::ConnectionAdapters::Column.new('different name', nil, :string, nil) assert column1 != column2 end - - test "non-equality on sql_type" do - column1 = ActiveRecord::ConnectionAdapters::Column.new("name", nil, :string, nil) - column2 = ActiveRecord::ConnectionAdapters::Column.new("name", nil, :text, nil) + + test 'non-equality on sql_type' do + column1 = ActiveRecord::ConnectionAdapters::Column.new('name', nil, :string, nil) + column2 = ActiveRecord::ConnectionAdapters::Column.new('name', nil, :text, nil) assert column1 != column2 end - - test "non-equality on default" do - column1 = ActiveRecord::ConnectionAdapters::Column.new("name", nil, :string, nil) - column2 = ActiveRecord::ConnectionAdapters::Column.new("name", "Dan", :string, nil) + + test 'non-equality on default' do + column1 = ActiveRecord::ConnectionAdapters::Column.new('name', nil, :string, nil) + column2 = ActiveRecord::ConnectionAdapters::Column.new('name', 'Dan', :string, nil) assert column1 != column2 end - - test "non-equality on null" do - column1 = ActiveRecord::ConnectionAdapters::Column.new("name", nil, :string, nil) - column2 = ActiveRecord::ConnectionAdapters::Column.new("name", nil, :string, true) + + test 'non-equality on null' do + column1 = ActiveRecord::ConnectionAdapters::Column.new('name', nil, :string, nil) + column2 = ActiveRecord::ConnectionAdapters::Column.new('name', nil, :string, true) assert column1 != column2 end end diff --git a/test/unit_record/column_test.rb b/test/unit_record/column_test.rb index d91ef78..523706b 100644 --- a/test/unit_record/column_test.rb +++ b/test/unit_record/column_test.rb @@ -1,34 +1,34 @@ -require File.dirname(__FILE__) + "/../test_helper" +require File.dirname(__FILE__) + '/../test_helper' functional_tests do - test "instantiating" do - person = Person.new :first_name => "Dan", :last_name => "Manges" - assert_equal "Dan", person.first_name - assert_equal "Manges", person.last_name + test 'instantiating' do + person = Person.new first_name: 'Dan', last_name: 'Manges' + assert_equal 'Dan', person.first_name + assert_equal 'Manges', person.last_name end - - test "using model with column with a default" do + + test 'using model with column with a default' do record = Preference.new assert_equal true, record.show_help? end - - test "typecasting happens for integer attributes" do + + test 'typecasting happens for integer attributes' do record = Preference.new - record.some_count = "42" + record.some_count = '42' assert_equal 42, record.some_count end - - test "a model with a non-convential table name does not blow up" do + + test 'a model with a non-convential table name does not blow up' do assert_nothing_raised { Foo.columns } end - - test "using attribute on a model with a non-conventional table name" do + + test 'using attribute on a model with a non-conventional table name' do foo = Foo.new - foo.bar = "baz" - assert_equal "baz", foo.bar + foo.bar = 'baz' + assert_equal 'baz', foo.bar end - - test "should get a descriptive error message if no cached columns" do + + test 'should get a descriptive error message if no cached columns' do exception = nil begin DoesNotExist.columns diff --git a/test/unit_record/controller_test.rb b/test/unit_record/controller_test.rb index a711cf2..66f6a1b 100644 --- a/test/unit_record/controller_test.rb +++ b/test/unit_record/controller_test.rb @@ -1,43 +1,27 @@ require File.dirname(__FILE__) + '/../test_helper' +class SampleApplication < Rails::Application +end +SampleApplication.routes.draw do + match '/sample/sample_action', to: 'sample#sample_action' +end + +SampleApplication.routes.draw do + match '/sample/sample_action', to: 'sample#sample_action' +end class SampleController < ActionController::Base + include SampleApplication.routes.url_helpers def sample_action - render :text => "OK" + render text: 'OK' end end -ActionController::Routing::Routes.add_route "/sample/sample_action", :controller => "sample", :action => "sample_action" - -if defined?(ActionController::TestCase) # Rails 2 +class ControllerTest < ActionController::TestCase + tests SampleController - class ControllerTest < ActionController::TestCase - tests SampleController - - test "render" do - get :sample_action - assert_equal "OK", @response.body - end - - if defined?(ActionController::Caching::SqlCache) # SqlCache goes away in Rails 2.3.1 - test "sql caching is enabled" do - assert_equal true, (SampleController < ActionController::Caching::SqlCache) - end - end + test 'render' do + @routes = SampleApplication.routes + get :sample_action + assert_equal 'OK', @response.body end - -else # Rails 1.x - - class ControllerTest < Test::Unit::TestCase - def setup - @controller = SampleController.new - @request = ActionController::TestRequest.new - @response = ActionController::TestResponse.new - end - - test "render" do - get :sample_action - assert_equal "OK", @response.body - end - end - end diff --git a/test/unit_record/disconnected_active_record_test.rb b/test/unit_record/disconnected_active_record_test.rb index 2f2b7ce..0645394 100644 --- a/test/unit_record/disconnected_active_record_test.rb +++ b/test/unit_record/disconnected_active_record_test.rb @@ -1,52 +1,52 @@ -require File.dirname(__FILE__) + "/../test_helper" +require File.dirname(__FILE__) + '/../test_helper' -functional_tests do - test "find_by_sql gives disconnected exception message" do +functional_tests do + test 'find_by_sql gives disconnected exception message' do exception = nil begin - Person.find_by_sql "SELECT * FROM people" + Person.find_by_sql 'SELECT * FROM people' rescue => exception end assert_not_nil exception - assert_equal "ActiveRecord is disconnected; database access is unavailable in unit tests.", exception.message + assert_equal 'ActiveRecord is disconnected; database access is unavailable in unit tests.', exception.message end - - test "connected? is true" do + + test 'connected? is true' do assert_equal true, ActiveRecord::Base.connected? end - - test "disconnected? is true" do + + test 'disconnected? is true' do assert_equal true, ActiveRecord::Base.disconnected? end - - test "inspect does not blow up" do + + test 'inspect does not blow up' do assert_nothing_raised { Person.inspect } end - - test "table_exists?" do + + test 'table_exists?' do assert_equal true, Person.table_exists? if ActiveRecord::Base.connection.respond_to?(:table_exists?) - assert_equal false, ActiveRecord::Base.connection.table_exists?("bogus_table") + assert_equal false, ActiveRecord::Base.connection.table_exists?('bogus_table') end end - - test "setting a has_one association" do + + test 'setting a has_one association' do person = Person.new person.profile = Profile.new end - - test "boolean columns do type casting" do + + test 'boolean columns do type casting' do pref = Preference.new - pref.show_help = "0" + pref.show_help = '0' assert_equal false, pref.send(:read_attribute, :show_help) assert_equal false, pref.show_help assert_equal false, pref.show_help? - pref.show_help = "1" + pref.show_help = '1' assert_equal true, pref.show_help assert_equal true, pref.show_help? end - - test "migrations are not verbose" do + + test 'migrations are not verbose' do assert_equal false, ActiveRecord::Migration.verbose end end diff --git a/test/unit_record/disconnected_fixtures_test.rb b/test/unit_record/disconnected_fixtures_test.rb index e80dcbe..a73792c 100644 --- a/test/unit_record/disconnected_fixtures_test.rb +++ b/test/unit_record/disconnected_fixtures_test.rb @@ -1,7 +1,7 @@ -require File.dirname(__FILE__) + "/../test_helper" +require File.dirname(__FILE__) + '/../test_helper' functional_tests do - test "create_fixtures does nothing" do - assert_nothing_raised { Fixtures.create_fixtures } + test 'create_fixtures does nothing' do + assert_nothing_raised { Fixtures.create_fixtures } if defined?(Fixtures) end end diff --git a/test/unit_record/disconnected_test_case_test.rb b/test/unit_record/disconnected_test_case_test.rb index ba6551c..151767f 100644 --- a/test/unit_record/disconnected_test_case_test.rb +++ b/test/unit_record/disconnected_test_case_test.rb @@ -1,11 +1,11 @@ -require File.dirname(__FILE__) + "/../test_helper" +require File.dirname(__FILE__) + '/../test_helper' functional_tests do - test "use_transactional_fixtures is false" do + test 'use_transactional_fixtures is false' do assert_equal false, UnitRecord.base_rails_test_class.use_transactional_fixtures end - - test "trying to use fixtures gives useful message" do + + test 'trying to use fixtures gives useful message' do exception = nil begin Class.new(UnitRecord.base_rails_test_class) do @@ -14,6 +14,8 @@ rescue => exception end assert_not_nil exception - assert_equal "Fixtures cannot be used with UnitRecord. ActiveRecord is disconnected; database access is unavailable in unit tests.", exception.message + expected_message = 'Fixtures cannot be used with UnitRecord. ' \ + 'ActiveRecord is disconnected; database access is unavailable in unit tests.' + assert_equal expected_message, exception.message end end diff --git a/test/unit_record/unit_record_test.rb b/test/unit_record/unit_record_test.rb index f6ca5b8..0fd8a75 100644 --- a/test/unit_record/unit_record_test.rb +++ b/test/unit_record/unit_record_test.rb @@ -1,14 +1,13 @@ -require File.dirname(__FILE__) + "/../test_helper" +require File.dirname(__FILE__) + '/../test_helper' unit_tests do - if UnitRecord.rails_version > "2.3" - test "test case base class" do + if UnitRecord.rails_version > '2.3' + test 'test case base class' do assert_equal ActiveSupport::TestCase, UnitRecord.base_rails_test_class end else - test "test case base class" do + test 'test case base class' do assert_equal Test::Unit::TestCase, UnitRecord.base_rails_test_class end end - -end \ No newline at end of file +end diff --git a/unit-record.gemspec b/unit-record.gemspec index 49b1d98..a460fce 100644 --- a/unit-record.gemspec +++ b/unit-record.gemspec @@ -2,29 +2,32 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| - s.name = %q{unit_record} - s.version = "0.9.1" + s.name = 'unit_record' + s.version = '0.10.0' - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Dan Manges"] - s.autorequire = %q{unit_record} - s.date = %q{2009-04-22} - s.description = %q{UnitRecord enables unit testing without hitting the database.} - s.email = %q{daniel.manges@gmail.com} - s.files = ["lib/active_record/connection_adapters/unit_record_adapter.rb", "lib/unit_record.rb", "lib/unit_record/disconnected_active_record.rb", "lib/unit_record/disconnected_test_case.rb", "lib/unit_record/column_extension.rb", "lib/unit_record/disconnected_fixtures.rb", "lib/unit_record/association_stubbing.rb", "test/test_helper.rb", "test/active_record/connection_adapters/unit_record_adapter_test.rb", "test/db/schema.rb", "test/sample_spec.rb", "test/unit_record/disconnected_test_case_test.rb", "test/unit_record/column_test.rb", "test/unit_record/column_cacher_test.rb", "test/unit_record/unit_record_test.rb", "test/unit_record/disconnected_active_record_test.rb", "test/unit_record/association_stubbing_test.rb", "test/unit_record/controller_test.rb", "test/unit_record/column_extension_test.rb", "test/unit_record/disconnected_fixtures_test.rb", "vendor/dust-0.1.6/rakefile.rb", "vendor/dust-0.1.6/test/test_helper.rb", "vendor/dust-0.1.6/test/passing_unit_test.rb", "vendor/dust-0.1.6/test/failing_with_helper_unit_test.rb", "vendor/dust-0.1.6/test/failing_with_setup_unit_test.rb", "vendor/dust-0.1.6/test/passing_with_setup_unit_test.rb", "vendor/dust-0.1.6/test/all_tests.rb", "vendor/dust-0.1.6/test/passing_with_helpers_unit_test.rb", "vendor/dust-0.1.6/test/passing_with_helper_unit_test.rb", "vendor/dust-0.1.6/test/functional_test.rb", "vendor/dust-0.1.6/lib/dust.rb", "vendor/dust-0.1.6/lib/definition_error.rb", "vendor/dust-0.1.6/lib/object_extension.rb", "vendor/dust-0.1.6/lib/string_extension.rb", "vendor/dust-0.1.6/lib/array_extension.rb", "vendor/dust-0.1.6/lib/symbol_extension.rb", "vendor/dust-0.1.6/lib/test_case_extension.rb", "vendor/dust-0.1.6/lib/nil_extension.rb", "CHANGELOG", "LICENSE", "README.markdown", "Rakefile"] - s.homepage = %q{http://unit-test-ar.rubyforge.org} - s.require_paths = ["lib"] - s.rubyforge_project = %q{unit-test-ar} - s.rubygems_version = %q{1.3.1} - s.summary = %q{UnitRecord enables unit testing without hitting the database.} + s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version= + s.authors = ['Dan Manges'] + s.autorequire = 'unit_record' + s.date = '2015-05-29' + s.description = 'UnitRecord enables unit testing without hitting the database.' + s.email = 'daniel.manges@gmail.com' + s.files = Dir['lib/**/*rb'].concat(['CHANGELOG', 'LICENSE', 'README.md']) + s.homepage = 'http://unit-test-ar.rubyforge.org' + s.require_paths = ['lib'] + s.rubyforge_project = 'unit-test-ar' + s.rubygems_version = '1.3.1' + s.summary = 'UnitRecord enables unit testing without hitting the database.' + s.add_development_dependency 'rake', '> 0' + s.add_development_dependency 'dust', '0.1.6' + s.add_development_dependency 'test-unit', '3.1.1' + s.add_development_dependency 'rspec', '1.1.11' + s.add_development_dependency 'rubocop', '~> 0.34.1' + s.add_development_dependency 'mocha', '1.1.0' - if s.respond_to? :specification_version then - current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + if s.respond_to? :specification_version s.specification_version = 2 - if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then - else + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') end - else end end diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..6450466 --- /dev/null +++ b/update.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +BUNDLE_GEMFILE=Gemfile.rails-3.2 bundle update +BUNDLE_GEMFILE=Gemfile.rails-3.1 bundle update +BUNDLE_GEMFILE=Gemfile.rails-3.0 bundle update diff --git a/vendor/dust-0.1.6/README b/vendor/dust-0.1.6/README deleted file mode 100644 index 17c9365..0000000 --- a/vendor/dust-0.1.6/README +++ /dev/null @@ -1,35 +0,0 @@ -= Dust - -Dust adds descriptive block syntax test definition. - -by Jay[http://blog.jayfields.com] Fields[http://blog.jayfields.com] - -== Download and Installation - -You can download Dust from here[http://rubyforge.org/projects/dust] or install it with the following command. - - $ gem install dust - -== License - -You may use, copy and redistribute this library under the same terms as Ruby itself (see http://www.ruby-lang.org/en/LICENSE.txt). - -== Examples - - unit_tests do - - test "assert true" do - assert_equal true, true - end - - end - -See the tests for more examples - -== IDE specific files - -You can download TextMate and JEdit Run Focused Test Commands from http://rubyforge.org/projects/dust/ (in Files) - -== Contributors - -Dan Manges, David Vollbracht, Shane Harvie \ No newline at end of file diff --git a/vendor/dust-0.1.6/lib/array_extension.rb b/vendor/dust-0.1.6/lib/array_extension.rb deleted file mode 100644 index 3f60304..0000000 --- a/vendor/dust-0.1.6/lib/array_extension.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Array #:nodoc: - def arrayize - self - end -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/lib/definition_error.rb b/vendor/dust-0.1.6/lib/definition_error.rb deleted file mode 100644 index cea0715..0000000 --- a/vendor/dust-0.1.6/lib/definition_error.rb +++ /dev/null @@ -1,20 +0,0 @@ -module Dust #:nodoc: - # Dust::DefinitionError is raised when you attempt to define a disallowed method within a test file. - # - # Test::Unit::TestCase.disallow_setup! - # - # unit_tests do - # def setup - # ... - # end - # - # test "name" do - # ... - # end - # end - # - # The above code will generate the following error - # Dust::DefinitionError: setup is not allowed on class Units::[TestClassName] - class DefinitionError < StandardError - end -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/lib/dust.rb b/vendor/dust-0.1.6/lib/dust.rb deleted file mode 100644 index 94e6863..0000000 --- a/vendor/dust-0.1.6/lib/dust.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'test/unit' -require File.expand_path(File.dirname(__FILE__) + '/object_extension') -require File.expand_path(File.dirname(__FILE__) + '/array_extension') -require File.expand_path(File.dirname(__FILE__) + '/nil_extension') -require File.expand_path(File.dirname(__FILE__) + '/string_extension') -require File.expand_path(File.dirname(__FILE__) + '/symbol_extension') -require File.expand_path(File.dirname(__FILE__) + '/test_case_extension') -require File.expand_path(File.dirname(__FILE__) + '/definition_error') \ No newline at end of file diff --git a/vendor/dust-0.1.6/lib/nil_extension.rb b/vendor/dust-0.1.6/lib/nil_extension.rb deleted file mode 100644 index 11b519b..0000000 --- a/vendor/dust-0.1.6/lib/nil_extension.rb +++ /dev/null @@ -1,5 +0,0 @@ -class NilClass #:nodoc: - def arrayize - [] - end -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/lib/object_extension.rb b/vendor/dust-0.1.6/lib/object_extension.rb deleted file mode 100644 index de1d587..0000000 --- a/vendor/dust-0.1.6/lib/object_extension.rb +++ /dev/null @@ -1,62 +0,0 @@ -class Object - # call-seq: unit_tests(options={}, &block) - # - # Used to define a block of unit tests. - # - # unit_tests do - # test "verify something" do - # ... - # end - # end - # - # Configuration Options: - # * allow - Allows you to specify the methods that are allowed despite being disallowed. - # See Test::Unit::TestCase.disallow_helpers! or Test::Unit::TestCase.disallow_setup! for more info - def unit_tests(options={}, &block) - do_tests("Units", options, &block) - end - - # call-seq: functional_tests(options={}, &block) - # - # Used to define a block of functional tests. - # - # functional_tests do - # test "verify something" do - # ... - # end - # end - # - # Configuration Options: - # * allow - Allows you to specify the methods that are allowed despite being disallowed. - # See Test::Unit::TestCase.disallow_helpers! or Test::Unit::TestCase.disallow_setup! for more info - def functional_tests(options={}, &block) - do_tests("Functionals", options, &block) - end - - protected - def do_tests(type, options, &block) #:nodoc: - options[:allow] = options[:allow].arrayize - full_path_file_name = eval "__FILE__", block.binding - test_name = File.basename(full_path_file_name, ".rb") - test_class = eval "module #{type}; class #{test_name.to_class_name} < Test::Unit::TestCase; self; end; end" - test_class.class_eval &block - check_for_setup(test_class, options) - check_for_helpers(test_class, options) - end - - def check_for_setup(test_class, options) #:nodoc: - if test_class.instance_methods(false).include?("setup") && Test::Unit::TestCase.disallow_setup? && - !options[:allow].include?(:setup) - raise Dust::DefinitionError.new("setup is not allowed on class #{test_class.name}") - end - end - - def check_for_helpers(test_class, options) #:nodoc: - test_class.instance_methods(false).each do |method_name| - if method_name !~ /^test_/ && Test::Unit::TestCase.disallow_helpers? && !options[:allow].include?(method_name.to_sym) - p method_name.to_sym - raise Dust::DefinitionError.new("helper methods are not allowed on class #{test_class.name}") - end - end - end -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/lib/string_extension.rb b/vendor/dust-0.1.6/lib/string_extension.rb deleted file mode 100644 index 8756ec0..0000000 --- a/vendor/dust-0.1.6/lib/string_extension.rb +++ /dev/null @@ -1,5 +0,0 @@ -class String #:nodoc: - def to_class_name - gsub(/(^|_)(.)/) { $2.upcase } - end -end diff --git a/vendor/dust-0.1.6/lib/symbol_extension.rb b/vendor/dust-0.1.6/lib/symbol_extension.rb deleted file mode 100644 index 1ff9448..0000000 --- a/vendor/dust-0.1.6/lib/symbol_extension.rb +++ /dev/null @@ -1,5 +0,0 @@ -class Symbol #:nodoc: - def arrayize - [self] - end -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/lib/test_case_extension.rb b/vendor/dust-0.1.6/lib/test_case_extension.rb deleted file mode 100644 index 9c6f4b3..0000000 --- a/vendor/dust-0.1.6/lib/test_case_extension.rb +++ /dev/null @@ -1,76 +0,0 @@ -module Test #:nodoc: - module Unit #:nodoc: - class TestCase - # call-seq: disallow_setup! - # - # Used to disallow setup methods in test specifications. - # - # Test::Unit::TestCase.disallow_setup! - # - # A test specification can override this behavior by passing :setup in the :allow options. - # - # unit_tests :allow => :setup do - # def setup - # ... - # end - # - # test "verify something" do - # ... - # end - # end - def self.disallow_setup! - @disallow_setup = true - end - - def self.disallow_setup? #:nodoc: - @disallow_setup - end - - # call-seq: disallow_helpers! - # - # Used to disallow helper methods in test specifications. - # - # Test::Unit::TestCase.disallow_helper! - # - # A test specification can override this behavior by passing the helper name (as a symbol) in the :allow options. - # - # unit_tests :allow => [:create_something, :destroy_something] do - # test "verify something" do - # ... - # end - # - # def create_something - # ... - # end - # - # def destroy_something - # ... - # end - # end - def self.disallow_helpers! - @disallow_helpers = true - end - - def self.disallow_helpers? #:nodoc: - @disallow_helpers - end - - # call-seq: test(name, &block) - # - # Used to define a test and assign it a descriptive name. - # - # unit_tests do - # test "verify something" do - # ... - # end - # end - def self.test(name, &block) - test_name = "test_#{name.gsub(/[\s]/,'_')}".to_sym - raise "#{test_name} is already defined in #{self}" if self.instance_methods.include? test_name.to_s - define_method test_name do - instance_eval &block - end - end - end - end -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/rakefile.rb b/vendor/dust-0.1.6/rakefile.rb deleted file mode 100644 index 81cd5f3..0000000 --- a/vendor/dust-0.1.6/rakefile.rb +++ /dev/null @@ -1,50 +0,0 @@ -require 'rubygems' -require 'rake/gempackagetask' -require 'rake/rdoctask' -require 'rake/contrib/sshpublisher' - -task :default => :test - -task :test do - require File.dirname(__FILE__) + '/test/all_tests.rb' -end - -desc 'Generate RDoc' -Rake::RDocTask.new do |task| - task.main = 'README' - task.title = 'Dust' - task.rdoc_dir = 'doc' - task.options << "--line-numbers" << "--inline-source" - task.rdoc_files.include('README', 'lib/**/*.rb') -end - -desc "Upload RDoc to RubyForge" -task :publish_rdoc => [:rdoc] do - Rake::SshDirPublisher.new("jaycfields@rubyforge.org", "/var/www/gforge-projects/dust", "doc").upload -end - -Gem::manage_gems - -specification = Gem::Specification.new do |s| - s.name = "dust" - s.summary = "Dust is an add on for Test::Unit that allows an alternative test definintion syntax." - s.version = "0.1.6" - s.author = 'Jay Fields' - s.description = "Dust is an add on for Test::Unit that allows an alternative test definintion syntax." - s.email = 'dust-developer@rubyforge.org' - s.homepage = 'http://dust.rubyforge.org' - s.rubyforge_project = 'dust' - - s.has_rdoc = true - s.extra_rdoc_files = ['README'] - s.rdoc_options << '--title' << 'Dust' << '--main' << 'README' << '--line-numbers' - - s.autorequire = 'dust' - s.files = FileList['{lib,test}/**/*.rb', '[A-Z]*$', 'rakefile.rb'].to_a - s.test_file = "test/all_tests.rb" -end - -Rake::GemPackageTask.new(specification) do |package| - package.need_zip = false - package.need_tar = false -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/test/all_tests.rb b/vendor/dust-0.1.6/test/all_tests.rb deleted file mode 100644 index 3697ba5..0000000 --- a/vendor/dust-0.1.6/test/all_tests.rb +++ /dev/null @@ -1 +0,0 @@ -Dir['**/*_test.rb'].each { |test_case| require test_case } \ No newline at end of file diff --git a/vendor/dust-0.1.6/test/failing_with_helper_unit_test.rb b/vendor/dust-0.1.6/test/failing_with_helper_unit_test.rb deleted file mode 100644 index f8363e9..0000000 --- a/vendor/dust-0.1.6/test/failing_with_helper_unit_test.rb +++ /dev/null @@ -1,16 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") - -begin - unit_tests do - Test::Unit::TestCase.disallow_helpers! - def helper_method - end - - test("true"){} - end - raise "shouldn't be here" -rescue Dust::DefinitionError => ex - raise unless ex.message == "helper methods are not allowed on class Units::FailingWithHelperUnitTest" -ensure - Test::Unit::TestCase.class_eval { @disallow_helpers = nil } -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/test/failing_with_setup_unit_test.rb b/vendor/dust-0.1.6/test/failing_with_setup_unit_test.rb deleted file mode 100644 index 1935856..0000000 --- a/vendor/dust-0.1.6/test/failing_with_setup_unit_test.rb +++ /dev/null @@ -1,16 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") - -begin - unit_tests do - Test::Unit::TestCase.disallow_setup! - def setup - end - - test("true"){} - end - raise "shouldn't be here" -rescue Dust::DefinitionError => ex - raise unless ex.message == "setup is not allowed on class Units::FailingWithSetupUnitTest" -ensure - Test::Unit::TestCase.class_eval { @disallow_setup = nil } -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/test/functional_test.rb b/vendor/dust-0.1.6/test/functional_test.rb deleted file mode 100644 index 64fedd2..0000000 --- a/vendor/dust-0.1.6/test/functional_test.rb +++ /dev/null @@ -1,12 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") - -functional_tests do - test "assert true" do - assert_equal true, true - end - - test "class name is Functionals::FunctionalTest" do - assert_equal "Functionals::FunctionalTest", self.class.name - end - -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/test/passing_unit_test.rb b/vendor/dust-0.1.6/test/passing_unit_test.rb deleted file mode 100644 index 7362bb7..0000000 --- a/vendor/dust-0.1.6/test/passing_unit_test.rb +++ /dev/null @@ -1,11 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") - -unit_tests do - test "assert true" do - assert_equal true, true - end - - test "class name is Units::PassingUnitTest" do - assert_equal "Units::PassingUnitTest", self.class.name - end -end \ No newline at end of file diff --git a/vendor/dust-0.1.6/test/passing_with_helper_unit_test.rb b/vendor/dust-0.1.6/test/passing_with_helper_unit_test.rb deleted file mode 100644 index d6208df..0000000 --- a/vendor/dust-0.1.6/test/passing_with_helper_unit_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") - -Test::Unit::TestCase.disallow_helpers! -unit_tests :allow => :helper do - def helper - end - - test("true"){} -end -Test::Unit::TestCase.class_eval { @disallow_helpers = nil } \ No newline at end of file diff --git a/vendor/dust-0.1.6/test/passing_with_helpers_unit_test.rb b/vendor/dust-0.1.6/test/passing_with_helpers_unit_test.rb deleted file mode 100644 index eaaafb1..0000000 --- a/vendor/dust-0.1.6/test/passing_with_helpers_unit_test.rb +++ /dev/null @@ -1,13 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") - -Test::Unit::TestCase.disallow_helpers! -unit_tests :allow => [:helper, :helper2] do - def helper - end - - def helper2 - end - - test("true"){} -end -Test::Unit::TestCase.class_eval { @disallow_helpers = nil } \ No newline at end of file diff --git a/vendor/dust-0.1.6/test/passing_with_setup_unit_test.rb b/vendor/dust-0.1.6/test/passing_with_setup_unit_test.rb deleted file mode 100644 index 5f2de9c..0000000 --- a/vendor/dust-0.1.6/test/passing_with_setup_unit_test.rb +++ /dev/null @@ -1,10 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + "/test_helper") - -Test::Unit::TestCase.disallow_setup! -unit_tests :allow => :setup do - def setup - end - - test("true"){} -end -Test::Unit::TestCase.class_eval { @disallow_setup = nil } \ No newline at end of file diff --git a/vendor/dust-0.1.6/test/test_helper.rb b/vendor/dust-0.1.6/test/test_helper.rb deleted file mode 100644 index 30b300c..0000000 --- a/vendor/dust-0.1.6/test/test_helper.rb +++ /dev/null @@ -1 +0,0 @@ -require File.dirname(__FILE__) + '/../lib/dust'