memory_test_fix 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +55 -0
- data/Gemfile +3 -0
- data/Rakefile +19 -0
- data/fixtures/rails32_app/Gemfile +5 -0
- data/fixtures/rails32_app/Rakefile +6 -0
- data/fixtures/rails32_app/app/models/foo.rb +2 -0
- data/fixtures/rails32_app/config/application.rb +14 -0
- data/fixtures/rails32_app/config/boot.rb +6 -0
- data/fixtures/rails32_app/config/environment.rb +5 -0
- data/fixtures/rails32_app/config/environments/test.rb +3 -0
- data/fixtures/rails32_app/db/migrate/20140830065127_create_foos.rb +13 -0
- data/fixtures/rails32_app/db/schema.rb +22 -0
- data/fixtures/rails32_app/script/rails +9 -0
- data/fixtures/rails32_app/test/fixtures/foos.yml +7 -0
- data/fixtures/rails32_app/test/test_helper.rb +13 -0
- data/fixtures/rails32_app/test/unit/foo_test.rb +13 -0
- data/fixtures/rails40_app/Gemfile +5 -0
- data/fixtures/rails40_app/Rakefile +6 -0
- data/fixtures/rails40_app/app/models/foo.rb +2 -0
- data/fixtures/rails40_app/config/application.rb +14 -0
- data/fixtures/rails40_app/config/boot.rb +4 -0
- data/fixtures/rails40_app/config/environment.rb +5 -0
- data/fixtures/rails40_app/config/environments/test.rb +3 -0
- data/fixtures/rails40_app/db/migrate/20140830065127_create_foos.rb +13 -0
- data/fixtures/rails40_app/db/schema.rb +22 -0
- data/fixtures/rails40_app/test/fixtures/foos.yml +7 -0
- data/fixtures/rails40_app/test/test_helper.rb +13 -0
- data/fixtures/rails40_app/test/unit/foo_test.rb +13 -0
- data/fixtures/rails41_app/Gemfile +5 -0
- data/fixtures/rails41_app/Rakefile +6 -0
- data/fixtures/rails41_app/app/models/foo.rb +2 -0
- data/fixtures/rails41_app/config/application.rb +12 -0
- data/fixtures/rails41_app/config/boot.rb +4 -0
- data/fixtures/rails41_app/config/environment.rb +5 -0
- data/fixtures/rails41_app/config/environments/development.rb +3 -0
- data/fixtures/rails41_app/config/environments/production.rb +3 -0
- data/fixtures/rails41_app/config/environments/test.rb +4 -0
- data/fixtures/rails41_app/config/initializers/filter_parameter_logging.rb +1 -0
- data/fixtures/rails41_app/db/migrate/20140830065127_create_foos.rb +13 -0
- data/fixtures/rails41_app/db/schema.rb +22 -0
- data/fixtures/rails41_app/test/fixtures/foos.yml +7 -0
- data/fixtures/rails41_app/test/test_helper.rb +13 -0
- data/fixtures/rails41_app/test/unit/foo_test.rb +13 -0
- data/lib/memory_test_fix/schema_file_loader.rb +9 -0
- data/memory_test_fix.gemspec +30 -34
- data/spec/spec_helper.rb +85 -0
- data/spec/unit/memory_test_fix/schema_loader_spec.rb +62 -0
- data/test/integration/integration_test.rb +79 -0
- data/test/test_helper.rb +1 -0
- metadata +56 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1a0498adafb593f01fc7779ae027d3b4309c383
|
4
|
+
data.tar.gz: db098470d01fd6bd391e93fcc8aa1803fa8f8c9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a713a7fba6890b281d9bf79619b963c6b4dbf7bda0983dbde290e299b6a515dc425457b038011b514084faa69fdc802c5a0f1c650ae5c15657896d037cae7baf
|
7
|
+
data.tar.gz: 8f30a51999e7549171346cff5b9108961c299e35e5d0fcd750d83b19ae6954717e59a747e9e3a275274bad3081845e657dc5bca624a6b1e3e0ce89bb445d2db4
|
data/Changelog.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## 1.2.1 / 2014-09-07
|
4
|
+
|
5
|
+
* Ensure all files are available in the gem
|
6
|
+
|
7
|
+
## 1.2.0 / 2014-09-07
|
8
|
+
|
9
|
+
* Drop support for Rails 3.0 and 3.1
|
10
|
+
|
11
|
+
## 1.1.0 / 2014-08-30
|
12
|
+
|
13
|
+
* Officially add support for Rails 4.1
|
14
|
+
* Add 'migrate' option (thanks, Stephan Zalewski)
|
15
|
+
* Use railties to run init_schema at the appropriate moment
|
16
|
+
(thanks, Stephan Zalewski)
|
17
|
+
* Fix Rails 4.0 support by initializing the schema whenever an
|
18
|
+
ActiveRecord connection is established
|
19
|
+
|
20
|
+
## 1.0.0 / 2014-04-07
|
21
|
+
|
22
|
+
* Officially add support for Rails 4.0
|
23
|
+
* Drop support for Rails 2.3
|
24
|
+
|
25
|
+
## 0.2.2 / 2013-02-02
|
26
|
+
|
27
|
+
* Fix broken Rails 3.0 compatibility
|
28
|
+
* Restore Rails 2.3 compatibility
|
29
|
+
|
30
|
+
## 0.2.1 / 2013-02-02
|
31
|
+
|
32
|
+
* Add support for Rails 3.2 (thanks, Stephan Zalewski)
|
33
|
+
|
34
|
+
## 0.2.0 / 2011-01-06
|
35
|
+
|
36
|
+
* Rails 3 compatibility (thanks, Greg Weber)
|
37
|
+
* Only support Rails 3
|
38
|
+
* Use Rails 3 plugin loading mechanism to avoid loading the schema
|
39
|
+
before initialization is complete
|
40
|
+
* Use 'verbosity' setting from the current environment, not from
|
41
|
+
'test'
|
42
|
+
|
43
|
+
## 0.1.3 / 2010-06-26
|
44
|
+
|
45
|
+
* Support other environments besides 'test' (thanks, Erik Hanson &
|
46
|
+
Matt Scilipoti)
|
47
|
+
|
48
|
+
## 0.1.1 / 2009-02-08
|
49
|
+
|
50
|
+
* Fix broken gemspec that did not include any files, nor all
|
51
|
+
authors.
|
52
|
+
|
53
|
+
## 0.1 / 2009-02-08
|
54
|
+
|
55
|
+
* Initial release as a GemPlugin
|
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
desc 'Default: run tests.'
|
6
|
+
task default: :test
|
7
|
+
|
8
|
+
namespace :test do
|
9
|
+
Rake::TestTask.new(:integration) do |t|
|
10
|
+
t.libs += %w(lib test)
|
11
|
+
t.pattern = 'test/integration/**/*_test.rb'
|
12
|
+
t.verbose = true
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
RSpec::Core::RakeTask.new(:spec)
|
17
|
+
|
18
|
+
desc 'Test the memory_test_fix plugin.'
|
19
|
+
task test: [:spec, 'test:integration']
|
@@ -0,0 +1,14 @@
|
|
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
|
@@ -0,0 +1,22 @@
|
|
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
|
@@ -0,0 +1,9 @@
|
|
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'
|
@@ -0,0 +1,13 @@
|
|
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
|
@@ -0,0 +1,13 @@
|
|
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
|
@@ -0,0 +1,14 @@
|
|
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 Rails40App
|
10
|
+
class Application < Rails::Application
|
11
|
+
config.encoding = "utf-8"
|
12
|
+
config.filter_parameters += [:password, :ssn]
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
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 that you 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"
|
19
|
+
t.datetime "updated_at"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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
|
@@ -0,0 +1,13 @@
|
|
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
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.filter_parameters += [:password]
|
@@ -0,0 +1,22 @@
|
|
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 that you 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"
|
19
|
+
t.datetime "updated_at"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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 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
|
@@ -0,0 +1,13 @@
|
|
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
|
data/memory_test_fix.gemspec
CHANGED
@@ -1,41 +1,37 @@
|
|
1
|
-
Gem::Specification.new do |
|
2
|
-
|
3
|
-
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "memory_test_fix"
|
3
|
+
spec.version = "1.2.1"
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
spec.authors = ["Matijs van Zuijlen",
|
6
|
+
"Chris Roos",
|
7
|
+
"Geoffrey Grosenbach",
|
8
|
+
"Kakutani Shintaro",
|
9
|
+
"Erik Hanson and Matt Scilipoti",
|
10
|
+
"Greg Weber",
|
11
|
+
"Stephan Zalewski"]
|
12
|
+
spec.email = "matijs@matijs.net"
|
13
|
+
spec.homepage = "http://wiki.github.com/mvz/memory_test_fix"
|
8
14
|
|
9
|
-
|
10
|
-
"Chris Roos",
|
11
|
-
"Geoffrey Grosenbach",
|
12
|
-
"Kakutani Shintaro",
|
13
|
-
"Erik Hanson and Matt Scilipoti",
|
14
|
-
"Greg Weber",
|
15
|
-
"Stephan Zalewski"]
|
16
|
-
s.email = "matijs@matijs.net"
|
15
|
+
spec.license = "MIT"
|
17
16
|
|
18
|
-
|
17
|
+
spec.summary = "Use SQLite3 in-memory database for Rails tests."
|
18
|
+
spec.description = <<-END
|
19
|
+
Makes use of SQLite3 in-memory database possible for your
|
20
|
+
Rails tests by preloading the schema.
|
21
|
+
END
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
spec.files = Dir["{lib,test,spec,fixtures}/**/*",
|
24
|
+
"*.md",
|
25
|
+
"*.gemspec",
|
26
|
+
"Rakefile",
|
27
|
+
"Gemfile"] & `git ls-files -z`.split("\0")
|
24
28
|
|
25
|
-
|
26
|
-
|
27
|
-
s.files = ["lib/memory_test_fix.rb",
|
28
|
-
"lib/memory_test_fix/railtie.rb",
|
29
|
-
"lib/memory_test_fix/schema_loader.rb",
|
30
|
-
"README.md",
|
31
|
-
"memory_test_fix.gemspec"]
|
32
|
-
s.has_rdoc = true
|
33
|
-
s.extra_rdoc_files = ['README.md']
|
34
|
-
s.rubygems_version = '1.2.0'
|
29
|
+
spec.rdoc_options = ["--main", "README.md"]
|
30
|
+
spec.extra_rdoc_files = ["README.md"]
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
32
|
+
spec.add_runtime_dependency("railties", ">= 3.0.0")
|
33
|
+
spec.add_runtime_dependency("activerecord", ">= 3.0.0")
|
34
|
+
spec.add_development_dependency("rake", "~> 10.2")
|
35
|
+
spec.add_development_dependency("minitest", "~> 5.2")
|
36
|
+
spec.add_development_dependency("rspec", "~> 3.1.0")
|
41
37
|
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause this
|
4
|
+
# file to always be loaded, without a need to explicitly require it in any files.
|
5
|
+
#
|
6
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
7
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
8
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
9
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
10
|
+
# a separate helper file that requires the additional dependencies and performs
|
11
|
+
# the additional setup, and require it from the spec files that actually need it.
|
12
|
+
#
|
13
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
14
|
+
# users commonly want.
|
15
|
+
#
|
16
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
17
|
+
RSpec.configure do |config|
|
18
|
+
# rspec-expectations config goes here. You can use an alternate
|
19
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
20
|
+
# assertions if you prefer.
|
21
|
+
config.expect_with :rspec do |expectations|
|
22
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
23
|
+
# and `failure_message` of custom matchers include text for helper methods
|
24
|
+
# defined using `chain`, e.g.:
|
25
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
26
|
+
# # => "be bigger than 2 and smaller than 4"
|
27
|
+
# ...rather than:
|
28
|
+
# # => "be bigger than 2"
|
29
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
30
|
+
end
|
31
|
+
|
32
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
33
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
34
|
+
config.mock_with :rspec do |mocks|
|
35
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
36
|
+
# a real object. This is generally recommended, and will default to
|
37
|
+
# `true` in RSpec 4.
|
38
|
+
mocks.verify_partial_doubles = true
|
39
|
+
end
|
40
|
+
|
41
|
+
# These two settings work together to allow you to limit a spec run
|
42
|
+
# to individual examples or groups you care about by tagging them with
|
43
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
44
|
+
# get run.
|
45
|
+
config.filter_run :focus
|
46
|
+
config.run_all_when_everything_filtered = true
|
47
|
+
|
48
|
+
# Limits the available syntax to the non-monkey patched syntax that is recommended.
|
49
|
+
# For more details, see:
|
50
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
51
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
52
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
53
|
+
config.disable_monkey_patching!
|
54
|
+
|
55
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
56
|
+
# be too noisy due to issues in dependencies.
|
57
|
+
config.warnings = true
|
58
|
+
|
59
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
60
|
+
# file, and it's useful to allow more verbose output when running an
|
61
|
+
# individual spec file.
|
62
|
+
if config.files_to_run.one?
|
63
|
+
# Use the documentation formatter for detailed output,
|
64
|
+
# unless a formatter has already been configured
|
65
|
+
# (e.g. via a command-line flag).
|
66
|
+
config.default_formatter = 'doc'
|
67
|
+
end
|
68
|
+
|
69
|
+
# Print the 10 slowest examples and example groups at the
|
70
|
+
# end of the spec run, to help surface which specs are running
|
71
|
+
# particularly slow.
|
72
|
+
config.profile_examples = 10
|
73
|
+
|
74
|
+
# Run specs in random order to surface order dependencies. If you find an
|
75
|
+
# order dependency and want to debug it, you can fix the order by providing
|
76
|
+
# the seed, which is printed after each run.
|
77
|
+
# --seed 1234
|
78
|
+
config.order = :random
|
79
|
+
|
80
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
81
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
82
|
+
# test failures related to randomization by passing the same `--seed` value
|
83
|
+
# as the one that triggered the failure.
|
84
|
+
Kernel.srand config.seed
|
85
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'memory_test_fix/schema_loader'
|
4
|
+
|
5
|
+
RSpec.describe MemoryTestFix::SchemaLoader do
|
6
|
+
describe '#init_schema' do
|
7
|
+
let(:migrator) { double(:migrator) }
|
8
|
+
let(:loader) { double(:loader) }
|
9
|
+
let(:options) { { configuration: config, migrator: migrator, loader: loader } }
|
10
|
+
let(:schema_loader) { MemoryTestFix::SchemaLoader.new options }
|
11
|
+
|
12
|
+
before do
|
13
|
+
allow(loader).to receive(:load_schema)
|
14
|
+
allow(migrator).to receive(:up)
|
15
|
+
end
|
16
|
+
|
17
|
+
context 'when no in-memory database is configured' do
|
18
|
+
let(:config) { { database: 'some/file.sqlite3', adapter: 'sqlite3' } }
|
19
|
+
|
20
|
+
it "outputs nothing" do
|
21
|
+
expect { schema_loader.init_schema }.to_not output.to_stdout
|
22
|
+
end
|
23
|
+
|
24
|
+
it "does not load anything" do
|
25
|
+
schema_loader.init_schema
|
26
|
+
expect(loader).to_not have_received :load_schema
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'when an in-memory database is configured' do
|
31
|
+
let(:base_config) { { database: ':memory:', adapter: 'sqlite3' } }
|
32
|
+
let(:config) { base_config }
|
33
|
+
|
34
|
+
it "informs the user it is creating an in-memory database" do
|
35
|
+
expect { schema_loader.init_schema }.
|
36
|
+
to output("Creating sqlite :memory: database\n").to_stdout
|
37
|
+
end
|
38
|
+
|
39
|
+
it "tells the loader to load the schema" do
|
40
|
+
silence_stream(STDOUT) { schema_loader.init_schema }
|
41
|
+
expect(loader).to have_received :load_schema
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when configured to use migrations" do
|
45
|
+
let(:config) { base_config.merge(migrate: true) }
|
46
|
+
|
47
|
+
it "tells the migrator to run the migrations" do
|
48
|
+
silence_stream(STDOUT) { schema_loader.init_schema }
|
49
|
+
expect(migrator).to have_received :up
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "when running in silence" do
|
54
|
+
let(:config) { base_config.merge(verbosity: 'silent') }
|
55
|
+
|
56
|
+
it "outputs nothing" do
|
57
|
+
expect { schema_loader.init_schema }.to_not output.to_stdout
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
def in_clean_bundler_environment(*args)
|
5
|
+
system(*%w(/usr/bin/env RUBYOPT= BUNDLE_BIN_PATH= BUNDLE_GEMFILE=) + args)
|
6
|
+
end
|
7
|
+
|
8
|
+
def update_bundle(label)
|
9
|
+
return if in_clean_bundler_environment(*%w(bundle update --quiet --local))
|
10
|
+
puts "Starting remote update of the bundle for #{label}"
|
11
|
+
return if in_clean_bundler_environment(*%w(bundle update))
|
12
|
+
raise "Unable to initialize test environment for #{label}"
|
13
|
+
end
|
14
|
+
|
15
|
+
def run_tests
|
16
|
+
result = false
|
17
|
+
out, err = capture_subprocess_io do
|
18
|
+
result = in_clean_bundler_environment(*%w(bundle exec rake))
|
19
|
+
end
|
20
|
+
# If the command failed, make it print any error messages
|
21
|
+
err.must_equal "" unless result
|
22
|
+
out
|
23
|
+
end
|
24
|
+
|
25
|
+
BASE_CONFIG = {
|
26
|
+
"development" => {
|
27
|
+
"adapter" => 'sqlite3',
|
28
|
+
"pool" => 5,
|
29
|
+
"timeout" => 5000,
|
30
|
+
"database" => 'db/development.sqlite3'
|
31
|
+
},
|
32
|
+
"test" => {
|
33
|
+
"adapter" => 'sqlite3',
|
34
|
+
"database" => ':memory:'
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
def create_db_config_without_migrations
|
39
|
+
File.open 'config/database.yml', 'w' do |f|
|
40
|
+
f.puts YAML.dump(BASE_CONFIG)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_db_config_with_migrations
|
45
|
+
File.open 'config/database.yml', 'w' do |f|
|
46
|
+
f.puts YAML.dump BASE_CONFIG.merge(test: { migrate: true })
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
VERSIONS = [
|
51
|
+
["Rails 3.2", 'rails32_app'],
|
52
|
+
["Rails 4.0", 'rails40_app'],
|
53
|
+
["Rails 4.1", 'rails41_app'],
|
54
|
+
]
|
55
|
+
|
56
|
+
VERSIONS.each do |label, appdir|
|
57
|
+
Dir.chdir "fixtures/#{appdir}" do
|
58
|
+
update_bundle label
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "A #{label} app using memory_test_fix" do
|
62
|
+
it "can run its tests without a real db" do
|
63
|
+
Dir.chdir "fixtures/#{appdir}" do
|
64
|
+
create_db_config_without_migrations
|
65
|
+
out = run_tests
|
66
|
+
out.must_match(/Creating sqlite :memory: database/)
|
67
|
+
out.must_match(/initialize_schema_migrations_table/)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it "can run its tests in-memory with migrations" do
|
72
|
+
Dir.chdir "fixtures/#{appdir}" do
|
73
|
+
create_db_config_with_migrations
|
74
|
+
out = run_tests
|
75
|
+
out.must_match(/Creating sqlite :memory: database/)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'minitest/autorun'
|
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.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matijs van Zuijlen
|
@@ -86,25 +86,76 @@ dependencies:
|
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 3.1.0
|
89
|
-
description:
|
90
|
-
|
89
|
+
description: |2
|
90
|
+
Makes use of SQLite3 in-memory database possible for your
|
91
|
+
Rails tests by preloading the schema.
|
91
92
|
email: matijs@matijs.net
|
92
93
|
executables: []
|
93
94
|
extensions: []
|
94
95
|
extra_rdoc_files:
|
95
96
|
- README.md
|
96
97
|
files:
|
98
|
+
- Changelog.md
|
99
|
+
- Gemfile
|
97
100
|
- README.md
|
101
|
+
- Rakefile
|
102
|
+
- fixtures/rails32_app/Gemfile
|
103
|
+
- fixtures/rails32_app/Rakefile
|
104
|
+
- fixtures/rails32_app/app/models/foo.rb
|
105
|
+
- fixtures/rails32_app/config/application.rb
|
106
|
+
- fixtures/rails32_app/config/boot.rb
|
107
|
+
- fixtures/rails32_app/config/environment.rb
|
108
|
+
- fixtures/rails32_app/config/environments/test.rb
|
109
|
+
- fixtures/rails32_app/db/migrate/20140830065127_create_foos.rb
|
110
|
+
- fixtures/rails32_app/db/schema.rb
|
111
|
+
- fixtures/rails32_app/script/rails
|
112
|
+
- fixtures/rails32_app/test/fixtures/foos.yml
|
113
|
+
- fixtures/rails32_app/test/test_helper.rb
|
114
|
+
- fixtures/rails32_app/test/unit/foo_test.rb
|
115
|
+
- fixtures/rails40_app/Gemfile
|
116
|
+
- fixtures/rails40_app/Rakefile
|
117
|
+
- fixtures/rails40_app/app/models/foo.rb
|
118
|
+
- fixtures/rails40_app/config/application.rb
|
119
|
+
- fixtures/rails40_app/config/boot.rb
|
120
|
+
- fixtures/rails40_app/config/environment.rb
|
121
|
+
- fixtures/rails40_app/config/environments/test.rb
|
122
|
+
- fixtures/rails40_app/db/migrate/20140830065127_create_foos.rb
|
123
|
+
- fixtures/rails40_app/db/schema.rb
|
124
|
+
- fixtures/rails40_app/test/fixtures/foos.yml
|
125
|
+
- fixtures/rails40_app/test/test_helper.rb
|
126
|
+
- fixtures/rails40_app/test/unit/foo_test.rb
|
127
|
+
- fixtures/rails41_app/Gemfile
|
128
|
+
- fixtures/rails41_app/Rakefile
|
129
|
+
- fixtures/rails41_app/app/models/foo.rb
|
130
|
+
- fixtures/rails41_app/config/application.rb
|
131
|
+
- fixtures/rails41_app/config/boot.rb
|
132
|
+
- fixtures/rails41_app/config/environment.rb
|
133
|
+
- fixtures/rails41_app/config/environments/development.rb
|
134
|
+
- fixtures/rails41_app/config/environments/production.rb
|
135
|
+
- fixtures/rails41_app/config/environments/test.rb
|
136
|
+
- fixtures/rails41_app/config/initializers/filter_parameter_logging.rb
|
137
|
+
- fixtures/rails41_app/db/migrate/20140830065127_create_foos.rb
|
138
|
+
- fixtures/rails41_app/db/schema.rb
|
139
|
+
- fixtures/rails41_app/test/fixtures/foos.yml
|
140
|
+
- fixtures/rails41_app/test/test_helper.rb
|
141
|
+
- fixtures/rails41_app/test/unit/foo_test.rb
|
98
142
|
- lib/memory_test_fix.rb
|
99
143
|
- lib/memory_test_fix/railtie.rb
|
144
|
+
- lib/memory_test_fix/schema_file_loader.rb
|
100
145
|
- lib/memory_test_fix/schema_loader.rb
|
101
146
|
- memory_test_fix.gemspec
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
- spec/unit/memory_test_fix/schema_loader_spec.rb
|
149
|
+
- test/integration/integration_test.rb
|
150
|
+
- test/test_helper.rb
|
102
151
|
homepage: http://wiki.github.com/mvz/memory_test_fix
|
103
152
|
licenses:
|
104
153
|
- MIT
|
105
154
|
metadata: {}
|
106
155
|
post_install_message:
|
107
|
-
rdoc_options:
|
156
|
+
rdoc_options:
|
157
|
+
- "--main"
|
158
|
+
- README.md
|
108
159
|
require_paths:
|
109
160
|
- lib
|
110
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -124,4 +175,4 @@ signing_key:
|
|
124
175
|
specification_version: 4
|
125
176
|
summary: Use SQLite3 in-memory database for Rails tests.
|
126
177
|
test_files: []
|
127
|
-
has_rdoc:
|
178
|
+
has_rdoc:
|