memory_test_fix 1.2.2 → 1.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9edd3156a490243468c8f7cc900f0f78ef05cbe4
4
- data.tar.gz: 0ca43175ce12f05cc8ade8c63eebf4a496acc44f
3
+ metadata.gz: 252c0ff8d21e91bac9b707e0bd0ff6ab9ecde051
4
+ data.tar.gz: c1b83cc9680a2665b5083dbd2e8e860881ed0bec
5
5
  SHA512:
6
- metadata.gz: 0490f360784f09d80c3276ba47696011ec4b894bcf297e03a493bba0fd9c8c4a7bd4478e348d165389eb4e2b7d5cd7fa0fbf082a38e7f5f9d82bce9f8c40df9d
7
- data.tar.gz: fd54cfd80904a988b68b5ef0421cc90f163d70f8c558e9308a30c4d18f53f59f5194e52a46d0666cd97d818734eb42f55b968e58eabcec8d9798ac470e0b080a
6
+ metadata.gz: 164c1dc344d34eb5e08196dda871bcebdf50ef02f2bd15e9e64ace618694a0d8875775948477b1271381613501a127128404ea7f8030847db724c233a769b0a9
7
+ data.tar.gz: ce6eb129ccc64d38c679080cafe86381afde8852b8a493db98cf17bfe2d5db7821a2fd7a9352ad11ffdd301d9f4e86a9cf33befd356a457844e43a7dbdafe96c
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.3.0 / 2015-09-07
4
+
5
+ * Drop support for Rails 3.2
6
+ * Support use of Spring
7
+
3
8
  ## 1.2.2 / 2014-09-09
4
9
 
5
10
  * Make dependency declaration match set of supported Rails versions
data/README.md CHANGED
@@ -44,11 +44,11 @@ You can also use this with other (testing) environments, not just 'test'.
44
44
 
45
45
  ## Rails Versions
46
46
 
47
- This gem is compatible with Rails 4 and Rails 3.2. If you're using an older
48
- version of Rails, your first priority should be upgrading Rails. If that's not
49
- an option, you can use version 1.1.0 of this gem with Rails 3.1 or 3.0. If
50
- you're using Rails 2.3, use version 0.2.2. If you're using an even older
51
- version of Rails, use version 0.1.3.
47
+ This gem is compatible with Rails 4. If you're using an older version of Rails,
48
+ your first priority should be upgrading Rails. If that's not an option, you can
49
+ use version 1.2.2 of this gem with Rails 3.2. If you're using Rails 3.1 or 3.0,
50
+ use version 1.1.0 of this gem. If you're using Rails 2.3, use version 0.2.2. If
51
+ you're using an even older version of Rails, use version 0.1.3.
52
52
 
53
53
  ## Authors
54
54
 
@@ -1,5 +1,9 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- gem 'rails', '~> 4.2.0.beta1'
3
+ gem 'rails', '~> 4.2.0'
4
4
  gem 'sqlite3'
5
5
  gem 'memory_test_fix', path: '../..'
6
+
7
+ group :development, :test do
8
+ gem 'spring'
9
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError
5
+ end
6
+ require_relative '../config/boot'
7
+ require 'rake'
8
+ Rake.application.run
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # This file loads spring without using Bundler, in order to be fast.
4
+ # It gets overwritten when you run the `spring binstub` command.
5
+
6
+ unless defined?(Spring)
7
+ require "rubygems"
8
+ require "bundler"
9
+
10
+ if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
11
+ Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq }
12
+ gem "spring", match[1]
13
+ require "spring/binstub"
14
+ end
15
+ end
@@ -8,5 +8,6 @@ Bundler.require(*Rails.groups)
8
8
 
9
9
  module RailsTestApp
10
10
  class Application < Rails::Application
11
+ config.active_record.raise_in_transactional_callbacks = true
11
12
  end
12
13
  end
@@ -1,4 +1,5 @@
1
1
  Rails.application.configure do
2
2
  config.eager_load = false
3
+ config.active_support.test_order = :random
3
4
  config.active_support.deprecation = :stderr
4
5
  end
@@ -3,7 +3,7 @@ class CreateFoos < ActiveRecord::Migration
3
3
  create_table :foos do |t|
4
4
  t.string :name
5
5
 
6
- t.timestamps
6
+ t.timestamps null: false
7
7
  end
8
8
  end
9
9
 
@@ -13,10 +13,10 @@
13
13
 
14
14
  ActiveRecord::Schema.define(version: 20140830065127) do
15
15
 
16
- create_table "foos", force: true do |t|
17
- t.string "name", limit: 255
18
- t.datetime "created_at"
19
- t.datetime "updated_at"
16
+ create_table "foos", force: :cascade do |t|
17
+ t.string "name"
18
+ t.datetime "created_at", null: false
19
+ t.datetime "updated_at", null: false
20
20
  end
21
21
 
22
22
  end
@@ -13,3 +13,9 @@ if defined?(Rails)
13
13
  end
14
14
  end
15
15
  end
16
+
17
+ if defined?(Spring)
18
+ Spring.after_fork do
19
+ MemoryTestFix::SchemaLoader.init_schema
20
+ end
21
+ end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "memory_test_fix"
3
- spec.version = "1.2.2"
3
+ spec.version = "1.3.0"
4
4
 
5
5
  spec.authors = ["Matijs van Zuijlen",
6
6
  "Chris Roos",
@@ -29,8 +29,8 @@ Gem::Specification.new do |spec|
29
29
  spec.rdoc_options = ["--main", "README.md"]
30
30
  spec.extra_rdoc_files = ["README.md"]
31
31
 
32
- spec.add_runtime_dependency("railties", ">= 3.2.0", "< 4.99.0")
33
- spec.add_runtime_dependency("activerecord", ">= 3.2.0", "< 4.99.0")
32
+ spec.add_runtime_dependency("railties", ">= 4.0.0", "< 4.99.0")
33
+ spec.add_runtime_dependency("activerecord", ">= 4.0.0", "< 4.99.0")
34
34
  spec.add_development_dependency("rake", "~> 10.2")
35
35
  spec.add_development_dependency("minitest", "~> 5.2")
36
36
  spec.add_development_dependency("rspec", "~> 3.1")
@@ -2,7 +2,7 @@ require 'test_helper'
2
2
  require 'yaml'
3
3
 
4
4
  def in_clean_bundler_environment(*args)
5
- system(*%w(/usr/bin/env RUBYOPT= BUNDLE_BIN_PATH= BUNDLE_GEMFILE=) + args)
5
+ system(*%w(/usr/bin/env -u RUBYOPT -u BUNDLE_BIN_PATH -u BUNDLE_GEMFILE) + args)
6
6
  end
7
7
 
8
8
  def update_bundle(label)
@@ -12,10 +12,10 @@ def update_bundle(label)
12
12
  raise "Unable to initialize test environment for #{label}"
13
13
  end
14
14
 
15
- def run_tests
15
+ def run_tests(command_array = %w(bundle exec rake))
16
16
  result = false
17
17
  out, err = capture_subprocess_io do
18
- result = in_clean_bundler_environment(*%w(bundle exec rake))
18
+ result = in_clean_bundler_environment(*command_array)
19
19
  end
20
20
  # If the command failed, make it print any error messages
21
21
  err.must_equal "" unless result
@@ -35,6 +35,10 @@ BASE_CONFIG = {
35
35
  }
36
36
  }
37
37
 
38
+ MIGRATING_CONFIG = BASE_CONFIG.dup.tap do |config|
39
+ config["test"] = config["test"].merge("migrate" => true)
40
+ end
41
+
38
42
  def create_db_config_without_migrations
39
43
  File.open 'config/database.yml', 'w' do |f|
40
44
  f.puts YAML.dump(BASE_CONFIG)
@@ -43,24 +47,23 @@ end
43
47
 
44
48
  def create_db_config_with_migrations
45
49
  File.open 'config/database.yml', 'w' do |f|
46
- f.puts YAML.dump BASE_CONFIG.merge(test: { migrate: true })
50
+ f.puts YAML.dump(MIGRATING_CONFIG)
47
51
  end
48
52
  end
49
53
 
50
54
  VERSIONS = [
51
- ["Rails 3.2", 'rails32_app'],
52
- ["Rails 4.0", 'rails40_app'],
53
- ["Rails 4.1", 'rails41_app'],
54
- ["Rails 4.2", 'rails42_app'],
55
+ ["Rails 4.0", 'rails40_app', false],
56
+ ["Rails 4.1", 'rails41_app', false],
57
+ ["Rails 4.2", 'rails42_app', true],
55
58
  ]
56
59
 
57
- VERSIONS.each do |label, appdir|
60
+ VERSIONS.each do |label, appdir, binstubs|
58
61
  Dir.chdir "fixtures/#{appdir}" do
59
62
  update_bundle label
60
63
  end
61
64
 
62
65
  describe "A #{label} app using memory_test_fix" do
63
- it "can run its tests without a real db" do
66
+ it "can run its tests in-memory without migrations" do
64
67
  Dir.chdir "fixtures/#{appdir}" do
65
68
  create_db_config_without_migrations
66
69
  out = run_tests
@@ -74,6 +77,30 @@ VERSIONS.each do |label, appdir|
74
77
  create_db_config_with_migrations
75
78
  out = run_tests
76
79
  out.must_match(/Creating sqlite :memory: database/)
80
+ out.wont_match(/initialize_schema_migrations_table/)
81
+ end
82
+ end
83
+
84
+ if binstubs
85
+ describe 'when using spring' do
86
+ let(:command_array) { %w(bin/rake) }
87
+ it "can run its tests in-memory without migrations" do
88
+ Dir.chdir "fixtures/#{appdir}" do
89
+ create_db_config_without_migrations
90
+ out = run_tests command_array
91
+ out.must_match(/Creating sqlite :memory: database/)
92
+ out.must_match(/initialize_schema_migrations_table/)
93
+ end
94
+ end
95
+
96
+ it "can run its tests in-memory with migrations" do
97
+ Dir.chdir "fixtures/#{appdir}" do
98
+ create_db_config_with_migrations
99
+ out = run_tests command_array
100
+ out.must_match(/Creating sqlite :memory: database/)
101
+ out.wont_match(/initialize_schema_migrations_table/)
102
+ end
103
+ end
77
104
  end
78
105
  end
79
106
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: memory_test_fix
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matijs van Zuijlen
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2014-09-09 00:00:00.000000000 Z
17
+ date: 2015-09-07 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: railties
@@ -22,7 +22,7 @@ dependencies:
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: 3.2.0
25
+ version: 4.0.0
26
26
  - - "<"
27
27
  - !ruby/object:Gem::Version
28
28
  version: 4.99.0
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirements:
33
33
  - - ">="
34
34
  - !ruby/object:Gem::Version
35
- version: 3.2.0
35
+ version: 4.0.0
36
36
  - - "<"
37
37
  - !ruby/object:Gem::Version
38
38
  version: 4.99.0
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 3.2.0
45
+ version: 4.0.0
46
46
  - - "<"
47
47
  - !ruby/object:Gem::Version
48
48
  version: 4.99.0
@@ -52,7 +52,7 @@ dependencies:
52
52
  requirements:
53
53
  - - ">="
54
54
  - !ruby/object:Gem::Version
55
- version: 3.2.0
55
+ version: 4.0.0
56
56
  - - "<"
57
57
  - !ruby/object:Gem::Version
58
58
  version: 4.99.0
@@ -111,19 +111,6 @@ files:
111
111
  - Gemfile
112
112
  - README.md
113
113
  - Rakefile
114
- - fixtures/rails32_app/Gemfile
115
- - fixtures/rails32_app/Rakefile
116
- - fixtures/rails32_app/app/models/foo.rb
117
- - fixtures/rails32_app/config/application.rb
118
- - fixtures/rails32_app/config/boot.rb
119
- - fixtures/rails32_app/config/environment.rb
120
- - fixtures/rails32_app/config/environments/test.rb
121
- - fixtures/rails32_app/db/migrate/20140830065127_create_foos.rb
122
- - fixtures/rails32_app/db/schema.rb
123
- - fixtures/rails32_app/script/rails
124
- - fixtures/rails32_app/test/fixtures/foos.yml
125
- - fixtures/rails32_app/test/test_helper.rb
126
- - fixtures/rails32_app/test/unit/foo_test.rb
127
114
  - fixtures/rails40_app/Gemfile
128
115
  - fixtures/rails40_app/Rakefile
129
116
  - fixtures/rails40_app/app/models/foo.rb
@@ -154,6 +141,8 @@ files:
154
141
  - fixtures/rails42_app/Gemfile
155
142
  - fixtures/rails42_app/Rakefile
156
143
  - fixtures/rails42_app/app/models/foo.rb
144
+ - fixtures/rails42_app/bin/rake
145
+ - fixtures/rails42_app/bin/spring
157
146
  - fixtures/rails42_app/config/application.rb
158
147
  - fixtures/rails42_app/config/boot.rb
159
148
  - fixtures/rails42_app/config/environment.rb
@@ -197,7 +186,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
186
  version: '0'
198
187
  requirements: []
199
188
  rubyforge_project:
200
- rubygems_version: 2.2.2
189
+ rubygems_version: 2.4.5.1
201
190
  signing_key:
202
191
  specification_version: 4
203
192
  summary: Use SQLite3 in-memory database for Rails tests.
@@ -1,5 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gem 'rails', '~> 3.2.3'
4
- gem 'sqlite3'
5
- gem 'memory_test_fix', path: '../..'
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Rails32App::Application.load_tasks
@@ -1,2 +0,0 @@
1
- class Foo < ActiveRecord::Base
2
- end
@@ -1,14 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails'
4
- require 'active_record/railtie'
5
- require 'rails/test_unit/railtie'
6
-
7
- Bundler.require(:default, Rails.env) if defined?(Bundler)
8
-
9
- module Rails32App
10
- class Application < Rails::Application
11
- config.encoding = "utf-8"
12
- config.filter_parameters += [:password, :ssn]
13
- end
14
- end
@@ -1,6 +0,0 @@
1
- require 'rubygems'
2
- # Set up gems listed in the Gemfile.
3
- if File.exist?(File.expand_path('../../Gemfile', __FILE__))
4
- require 'bundler'
5
- Bundler.setup
6
- end
@@ -1,5 +0,0 @@
1
- # Load the rails application
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the rails application
5
- Rails32App::Application.initialize!
@@ -1,3 +0,0 @@
1
- Rails32App::Application.configure do
2
- config.active_support.deprecation = :stderr
3
- end
@@ -1,13 +0,0 @@
1
- class CreateFoos < ActiveRecord::Migration
2
- def self.up
3
- create_table :foos do |t|
4
- t.string :name
5
-
6
- t.timestamps
7
- end
8
- end
9
-
10
- def self.down
11
- drop_table :foos
12
- end
13
- end
@@ -1,22 +0,0 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended to check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(:version => 20140830065127) do
15
-
16
- create_table "foos", :force => true do |t|
17
- t.string "name"
18
- t.datetime "created_at", :null => false
19
- t.datetime "updated_at", :null => false
20
- end
21
-
22
- end
@@ -1,9 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
-
4
- ENV_PATH = File.expand_path('../../config/environment', __FILE__)
5
- BOOT_PATH = File.expand_path('../../config/boot', __FILE__)
6
- APP_PATH = File.expand_path('../../config/application', __FILE__)
7
-
8
- require BOOT_PATH
9
- require 'rails/commands'
@@ -1,7 +0,0 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
-
3
- one:
4
- name: Foo one
5
-
6
- two:
7
- name: Foo two
@@ -1,13 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
- require File.expand_path('../../config/environment', __FILE__)
3
- require 'rails/test_help'
4
-
5
- class ActiveSupport::TestCase
6
- # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
7
- #
8
- # Note: You'll currently still have to declare fixtures explicitly in integration tests
9
- # -- they do not yet inherit this setting
10
- fixtures :all
11
-
12
- # Add more helper methods to be used by all tests here...
13
- end
@@ -1,13 +0,0 @@
1
- require 'test_helper'
2
-
3
- class FooTest < ActiveSupport::TestCase
4
- test "Foos have names" do
5
- assert_equal 'Foo one', foos(:one).name
6
- end
7
-
8
- test "Foos can be stored" do
9
- foo = Foo.new(name: 'A third')
10
- foo.save!
11
- assert_equal 'A third', Foo.find(foo.id).name
12
- end
13
- end