unit_record 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,4 +1,8 @@
1
- *HEAD
1
+ *0.9.1*
2
+
3
+ * Rails 2.3 compatibility
4
+
5
+ *0.9.0*
2
6
 
3
7
  * Add association stubbing with mocha
4
8
 
data/Rakefile CHANGED
@@ -25,7 +25,7 @@ require "date"
25
25
  gem_spec = Gem::Specification.new do |s|
26
26
  s.name = "unit_record"
27
27
  s.summary = "UnitRecord enables unit testing without hitting the database."
28
- s.version = "0.9.0"
28
+ s.version = "0.9.1"
29
29
  s.author = "Dan Manges"
30
30
  s.description = "UnitRecord enables unit testing without hitting the database."
31
31
  s.email = "daniel.manges@gmail.com"
@@ -59,7 +59,7 @@ task :readme do
59
59
  sh "open #{file}"
60
60
  end
61
61
 
62
- RAILS_VERSIONS = %w[1.2.6 2.0.2 2.1.0 2.1.1 2.2.2]
62
+ RAILS_VERSIONS = %w[1.2.6 2.0.2 2.1.0 2.1.1 2.2.2 2.3.2]
63
63
 
64
64
  namespace :test do
65
65
  desc "test with multiple versions of rails"
@@ -71,8 +71,9 @@ namespace :test do
71
71
  end
72
72
 
73
73
  task :multi_verbose do
74
- (RAILS_VERSIONS - %w[2.2.2]).each do |rails_version|
74
+ (RAILS_VERSIONS - %w[]).each do |rails_version|
75
75
  task = defined?(Rcov) ? "rcov" : "test"
76
+ puts "Testing with Rails #{rails_version}"
76
77
  sh "RAILS_VERSION='#{rails_version}' rake #{task}"
77
78
  end
78
79
  end
@@ -1,3 +1,16 @@
1
+ module UnitRecord
2
+ def self.rails_version
3
+ Rails::VERSION::STRING
4
+ end
5
+
6
+ def self.base_rails_test_class
7
+ if rails_version >= "2.3.1"
8
+ ActiveSupport::TestCase
9
+ else
10
+ Test::Unit::TestCase
11
+ end
12
+ end
13
+ end
1
14
  require "unit_record/association_stubbing"
2
15
  require "unit_record/column_extension"
3
16
  require "unit_record/disconnected_active_record"
@@ -9,7 +22,7 @@ require "active_record/fixtures"
9
22
 
10
23
  ActiveRecord::ConnectionAdapters::Column.send :include, UnitRecord::ColumnExtension
11
24
  ActiveRecord::Base.extend UnitRecord::DisconnectedActiveRecord
12
- Test::Unit::TestCase.extend UnitRecord::DisconnectedTestCase
25
+ UnitRecord.base_rails_test_class.extend UnitRecord::DisconnectedTestCase
13
26
  Fixtures.extend UnitRecord::DisconnectedFixtures
14
27
 
15
28
  ActiveRecord::Base.class_eval do
@@ -11,7 +11,7 @@ module UnitRecord
11
11
  ActiveRecord::Base.send :include, UnitRecord::AssociationStubbing
12
12
  end
13
13
  Fixtures.disconnect!
14
- Test::Unit::TestCase.disconnect!
14
+ UnitRecord.base_rails_test_class.disconnect!
15
15
  ActiveRecord::Migration.verbose = false
16
16
  ActiveRecord::Base.connection.change_strategy(:noop) do
17
17
  load(RAILS_ROOT + "/db/schema.rb")
@@ -19,6 +19,10 @@ require "action_controller/test_process"
19
19
 
20
20
  require "unit_record"
21
21
 
22
+ if UnitRecord.rails_version >= "2.3"
23
+ ActiveSupport::TestCase.class_eval { include ActiveRecord::TestFixtures }
24
+ end
25
+
22
26
  # Needed because of this line in setup_with_fixtures and teardown_with_fixtures:
23
27
  # return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
24
28
  ActiveRecord::Base.configurations = {"irrelevant" => {:adapter => "stub"}}
@@ -32,7 +32,12 @@ Test::Unit::TestCase.disallow_setup!
32
32
  $LOAD_PATH << File.dirname(__FILE__) + "/../lib"
33
33
  require "unit_record"
34
34
 
35
- Test::Unit::TestCase.use_transactional_fixtures = true
35
+ if UnitRecord.rails_version >= "2.3"
36
+ require "active_support/test_case"
37
+ ActiveSupport::TestCase.class_eval { include ActiveRecord::TestFixtures }
38
+ end
39
+
40
+ UnitRecord.base_rails_test_class.use_transactional_fixtures = true
36
41
 
37
42
  # Needed because of this line in setup_with_fixtures and teardown_with_fixtures:
38
43
  # return unless defined?(ActiveRecord::Base) && !ActiveRecord::Base.configurations.blank?
@@ -18,8 +18,10 @@ if defined?(ActionController::TestCase) # Rails 2
18
18
  assert_equal "OK", @response.body
19
19
  end
20
20
 
21
- test "sql caching is enabled" do
22
- assert_equal true, (SampleController < ActionController::Caching::SqlCache)
21
+ if defined?(ActionController::Caching::SqlCache) # SqlCache goes away in Rails 2.3.1
22
+ test "sql caching is enabled" do
23
+ assert_equal true, (SampleController < ActionController::Caching::SqlCache)
24
+ end
23
25
  end
24
26
  end
25
27
 
@@ -2,13 +2,13 @@ require File.dirname(__FILE__) + "/../test_helper"
2
2
 
3
3
  functional_tests do
4
4
  test "use_transactional_fixtures is false" do
5
- assert_equal false, Test::Unit::TestCase.use_transactional_fixtures
5
+ assert_equal false, UnitRecord.base_rails_test_class.use_transactional_fixtures
6
6
  end
7
7
 
8
8
  test "trying to use fixtures gives useful message" do
9
9
  exception = nil
10
10
  begin
11
- Class.new(Test::Unit::TestCase) do
11
+ Class.new(UnitRecord.base_rails_test_class) do
12
12
  fixtures :users
13
13
  end
14
14
  rescue => exception
@@ -0,0 +1,14 @@
1
+ require File.dirname(__FILE__) + "/../test_helper"
2
+
3
+ unit_tests do
4
+ if UnitRecord.rails_version > "2.3"
5
+ test "test case base class" do
6
+ assert_equal ActiveSupport::TestCase, UnitRecord.base_rails_test_class
7
+ end
8
+ else
9
+ test "test case base class" do
10
+ assert_equal Test::Unit::TestCase, UnitRecord.base_rails_test_class
11
+ end
12
+ end
13
+
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unit_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Manges
@@ -9,7 +9,7 @@ autorequire: unit_record
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-15 00:00:00 -06:00
12
+ date: 2009-04-22 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -23,42 +23,43 @@ extra_rdoc_files: []
23
23
 
24
24
  files:
25
25
  - lib/active_record/connection_adapters/unit_record_adapter.rb
26
- - lib/unit_record/association_stubbing.rb
27
- - lib/unit_record/column_extension.rb
26
+ - lib/unit_record.rb
28
27
  - lib/unit_record/disconnected_active_record.rb
29
- - lib/unit_record/disconnected_fixtures.rb
30
28
  - lib/unit_record/disconnected_test_case.rb
31
- - lib/unit_record.rb
29
+ - lib/unit_record/column_extension.rb
30
+ - lib/unit_record/disconnected_fixtures.rb
31
+ - lib/unit_record/association_stubbing.rb
32
+ - test/test_helper.rb
32
33
  - test/active_record/connection_adapters/unit_record_adapter_test.rb
33
34
  - test/db/schema.rb
34
35
  - test/sample_spec.rb
35
- - test/test_helper.rb
36
- - test/unit_record/association_stubbing_test.rb
37
- - test/unit_record/column_cacher_test.rb
38
- - test/unit_record/column_extension_test.rb
36
+ - test/unit_record/disconnected_test_case_test.rb
39
37
  - test/unit_record/column_test.rb
40
- - test/unit_record/controller_test.rb
38
+ - test/unit_record/column_cacher_test.rb
39
+ - test/unit_record/unit_record_test.rb
41
40
  - test/unit_record/disconnected_active_record_test.rb
41
+ - test/unit_record/association_stubbing_test.rb
42
+ - test/unit_record/controller_test.rb
43
+ - test/unit_record/column_extension_test.rb
42
44
  - test/unit_record/disconnected_fixtures_test.rb
43
- - test/unit_record/disconnected_test_case_test.rb
44
- - vendor/dust-0.1.6/lib/array_extension.rb
45
- - vendor/dust-0.1.6/lib/definition_error.rb
45
+ - vendor/dust-0.1.6/rakefile.rb
46
+ - vendor/dust-0.1.6/test/test_helper.rb
47
+ - vendor/dust-0.1.6/test/passing_unit_test.rb
48
+ - vendor/dust-0.1.6/test/failing_with_helper_unit_test.rb
49
+ - vendor/dust-0.1.6/test/failing_with_setup_unit_test.rb
50
+ - vendor/dust-0.1.6/test/passing_with_setup_unit_test.rb
51
+ - vendor/dust-0.1.6/test/all_tests.rb
52
+ - vendor/dust-0.1.6/test/passing_with_helpers_unit_test.rb
53
+ - vendor/dust-0.1.6/test/passing_with_helper_unit_test.rb
54
+ - vendor/dust-0.1.6/test/functional_test.rb
46
55
  - vendor/dust-0.1.6/lib/dust.rb
47
- - vendor/dust-0.1.6/lib/nil_extension.rb
56
+ - vendor/dust-0.1.6/lib/definition_error.rb
48
57
  - vendor/dust-0.1.6/lib/object_extension.rb
49
58
  - vendor/dust-0.1.6/lib/string_extension.rb
59
+ - vendor/dust-0.1.6/lib/array_extension.rb
50
60
  - vendor/dust-0.1.6/lib/symbol_extension.rb
51
61
  - vendor/dust-0.1.6/lib/test_case_extension.rb
52
- - vendor/dust-0.1.6/rakefile.rb
53
- - vendor/dust-0.1.6/test/all_tests.rb
54
- - vendor/dust-0.1.6/test/failing_with_helper_unit_test.rb
55
- - vendor/dust-0.1.6/test/failing_with_setup_unit_test.rb
56
- - vendor/dust-0.1.6/test/functional_test.rb
57
- - vendor/dust-0.1.6/test/passing_unit_test.rb
58
- - vendor/dust-0.1.6/test/passing_with_helper_unit_test.rb
59
- - vendor/dust-0.1.6/test/passing_with_helpers_unit_test.rb
60
- - vendor/dust-0.1.6/test/passing_with_setup_unit_test.rb
61
- - vendor/dust-0.1.6/test/test_helper.rb
62
+ - vendor/dust-0.1.6/lib/nil_extension.rb
62
63
  - CHANGELOG
63
64
  - LICENSE
64
65
  - README.markdown