memory_test_fix 1.4.2 → 1.5.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
- SHA1:
3
- metadata.gz: e61644658f57f5842df48c9474e0b14af9e44b61
4
- data.tar.gz: f336ed05d3fb0d75a8218b88b1da6ea4be11f73a
2
+ SHA256:
3
+ metadata.gz: dbbaf46755ac3025b3caa67313dfdd3f84e749faedd7e381fa21c12d7a1202da
4
+ data.tar.gz: 5265b0c883df03deb39a391713a1f085c2edb33c406c9d5ed1516b614db3198b
5
5
  SHA512:
6
- metadata.gz: c96f54b41ff3dfc9928d665debfad734bd7d4b1c1f50662d516e70c2998b401360188caf554fe420dc7d2495547b4dd421f33bf3215189cd1d2a0618da0b4a64
7
- data.tar.gz: 7be2a625d38ee7baa03b293063225966ceb484dac3f3e4878d7043883c94970ff228ba6c4a093ae410df08d3bd329b6f8784ccadc6a24910d54cb2b593349cf5
6
+ metadata.gz: 8f95e587b55511535076f7edb1a061b9b0cd287cd04d315604e53601ff77c54519dd1c6f26c21fd2ac326ddcf523a40e9c8efd29ec6c76d0972c2a9cc83dac35
7
+ data.tar.gz: 5e9d1c624e2852dbb8f387de415061bbca5635bad6b9dc0d5f263b170b243683520d27cc61540a986c6f886ffa035d84809e265e2a6197af6bbfcd27597c5ed4
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.5.0 / 2018-02-14
4
+
5
+ * Add support for Rails 5.2
6
+
3
7
  ## 1.4.2 / 2017-04-28
4
8
 
5
9
  * Update dependencies to allow use with Rails 5.1
data/README.md CHANGED
@@ -46,7 +46,8 @@ You can also use this with other (testing) environments, not just 'test'.
46
46
  In general, Bundler should pick a compatible version for you if you don't
47
47
  specify one in your `Gemfile`.
48
48
 
49
- That said, the latest version of this gem is compatible with Rails 5.0 and 5.1.
49
+ That said, the latest version of this gem is compatible with Rails 5.0, 5.1 and
50
+ upcoming 5.2.
50
51
  If you're still on Rails 4, you can use version 1.3.0. Unfortunately, the hard
51
52
  requirement of Ruby 2.2 or above for Rails 5 means `memory_test_fix` cannot
52
53
  support Rails 4 and 5 at the same time.
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rails', '~> 5.2.0.rc1'
4
+ gem 'sqlite3', platform: :ruby
5
+ gem 'activerecord-jdbcsqlite3-adapter', platform: :jruby
6
+ gem 'memory_test_fix', path: '../..'
7
+
8
+ group :development do
9
+ gem 'spring'
10
+ end
@@ -0,0 +1,6 @@
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_relative 'config/application'
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ self.abstract_class = true
3
+ end
@@ -0,0 +1,2 @@
1
+ class Foo < ApplicationRecord
2
+ end
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path('../spring', __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?('spring')
6
+ end
7
+ require_relative '../config/boot'
8
+ require 'rake'
9
+ Rake.application.run
@@ -0,0 +1,17 @@
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
+ lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
11
+ spring = lockfile.specs.detect { |spec| spec.name == "spring" }
12
+ if spring
13
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
14
+ gem 'spring', spring.version
15
+ require 'spring/binstub'
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ require_relative 'boot'
2
+
3
+ require 'rails'
4
+ require 'active_record/railtie'
5
+ require 'rails/test_unit/railtie'
6
+
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module RailsTestApp
10
+ class Application < Rails::Application
11
+ config.load_defaults 5.2
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
2
+
3
+ require 'bundler/setup' # Set up gems listed in the Gemfile.
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative 'application'
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!
@@ -0,0 +1,3 @@
1
+ Rails.application.configure do
2
+ config.eager_load = false
3
+ end
@@ -0,0 +1,3 @@
1
+ Rails.application.configure do
2
+ config.eager_load = true
3
+ end
@@ -0,0 +1,5 @@
1
+ Rails.application.configure do
2
+ config.eager_load = false
3
+ config.active_support.test_order = :random
4
+ config.active_support.deprecation = :stderr
5
+ end
@@ -0,0 +1 @@
1
+ Rails.application.config.filter_parameters += [:password]
@@ -0,0 +1,13 @@
1
+ class CreateFoos < ActiveRecord::Migration[5.1]
2
+ def self.up
3
+ create_table :foos do |t|
4
+ t.string :name
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+
10
+ def self.down
11
+ drop_table :foos
12
+ end
13
+ 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: :cascade 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,7 @@
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
@@ -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,10 @@
1
+ ENV['RAILS_ENV'] ||= 'test'
2
+ require_relative '../config/environment'
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
+ fixtures :all
8
+
9
+ # Add more helper methods to be used by all tests here...
10
+ end
@@ -1,4 +1,5 @@
1
1
  require 'memory_test_fix/schema_file_loader'
2
+ require 'active_record'
2
3
 
3
4
  module MemoryTestFix
4
5
  # Set up database schema into in-memory database.
@@ -72,7 +73,11 @@ module MemoryTestFix
72
73
 
73
74
  def load_schema
74
75
  if migrate
75
- @migrator.up('db/migrate')
76
+ if @migrator.respond_to? :up
77
+ @migrator.up('db/migrate')
78
+ else
79
+ ActiveRecord::Base.connection.migration_context.up
80
+ end
76
81
  else
77
82
  @loader.load_schema
78
83
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "memory_test_fix"
3
- spec.version = "1.4.2"
3
+ spec.version = "1.5.0"
4
4
 
5
5
  spec.authors = ["Matijs van Zuijlen",
6
6
  "Chris Roos",
@@ -15,10 +15,11 @@ Gem::Specification.new do |spec|
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.summary = "Use SQLite3 in-memory database for Rails tests."
18
- spec.description = <<-END
18
+ spec.description = <<-TEXT
19
19
  Makes use of SQLite3 in-memory database possible for your
20
20
  Rails tests by preloading the schema.
21
- END
21
+ TEXT
22
+ spec.required_ruby_version = '>= 2.2.0'
22
23
 
23
24
  spec.files = Dir["{lib,test,spec,fixtures}/**/*",
24
25
  "*.md",
@@ -29,9 +30,9 @@ Gem::Specification.new do |spec|
29
30
  spec.rdoc_options = ["--main", "README.md"]
30
31
  spec.extra_rdoc_files = ["README.md"]
31
32
 
32
- spec.add_runtime_dependency("railties", "~> 5.0")
33
33
  spec.add_runtime_dependency("activerecord", "~> 5.0")
34
- spec.add_development_dependency("rake", "~> 12.0")
34
+ spec.add_runtime_dependency("railties", "~> 5.0")
35
35
  spec.add_development_dependency("minitest", "~> 5.2")
36
+ spec.add_development_dependency("rake", "~> 12.0")
36
37
  spec.add_development_dependency("rspec", "~> 3.1")
37
38
  end
@@ -15,10 +15,11 @@ RSpec.describe MemoryTestFix::SchemaLoader do
15
15
  end
16
16
 
17
17
  describe '#init_schema' do
18
- let(:migrator) { double(:migrator) }
19
- let(:loader) { double(:loader) }
18
+ let(:migrator) { class_double(ActiveRecord::Migrator) }
19
+ let(:loader) { class_double(MemoryTestFix::SchemaFileLoader) }
20
20
  let(:options) { { configuration: config, migrator: migrator, loader: loader } }
21
- let(:schema_loader) { MemoryTestFix::SchemaLoader.new options }
21
+ let(:schema_loader) { described_class.new options }
22
+ let(:base_config) { { database: ':memory:', adapter: 'sqlite3' } }
22
23
 
23
24
  before do
24
25
  allow(loader).to receive(:load_schema) { puts 'loading schema' }
@@ -29,17 +30,16 @@ RSpec.describe MemoryTestFix::SchemaLoader do
29
30
  let(:config) { { database: 'some/file.sqlite3', adapter: 'sqlite3' } }
30
31
 
31
32
  it "outputs nothing" do
32
- expect { schema_loader.init_schema }.to_not output.to_stdout
33
+ expect { schema_loader.init_schema }.not_to output.to_stdout
33
34
  end
34
35
 
35
36
  it "does not load anything" do
36
37
  schema_loader.init_schema
37
- expect(loader).to_not have_received :load_schema
38
+ expect(loader).not_to have_received :load_schema
38
39
  end
39
40
  end
40
41
 
41
- context 'when an in-memory database is configured' do
42
- let(:base_config) { { database: ':memory:', adapter: 'sqlite3' } }
42
+ context 'when configured not to use migrations' do
43
43
  let(:config) { base_config }
44
44
 
45
45
  it "informs the user it is creating an in-memory database" do
@@ -56,36 +56,46 @@ RSpec.describe MemoryTestFix::SchemaLoader do
56
56
  silently { schema_loader.init_schema }
57
57
  expect(loader).to have_received :load_schema
58
58
  end
59
+ end
60
+
61
+ context "when configured to use migrations" do
62
+ let(:config) { base_config.merge(migrate: true) }
59
63
 
60
- context "when configured to use migrations" do
61
- let(:config) { base_config.merge(migrate: true) }
64
+ it "informs the user it is creating an in-memory database" do
65
+ expect { schema_loader.init_schema }.
66
+ to output(/Creating sqlite :memory: database/).to_stdout
67
+ end
68
+
69
+ it "does not print 'loading schema'" do
70
+ expect { schema_loader.init_schema }.
71
+ not_to output(/loading schema/).to_stdout
72
+ end
62
73
 
63
- it "tells the migrator to run the migrations" do
64
- silently { schema_loader.init_schema }
65
- expect(migrator).to have_received :up
66
- end
74
+ it "tells the migrator to run the migrations" do
75
+ silently { schema_loader.init_schema }
76
+ expect(migrator).to have_received :up
67
77
  end
78
+ end
68
79
 
69
- context "when running in quietly" do
70
- let(:config) { base_config.merge(verbosity: 'quiet') }
80
+ context "when running in quietly" do
81
+ let(:config) { base_config.merge(verbosity: 'quiet') }
71
82
 
72
- it "informs the user it is creating an in-memory database" do
73
- expect { schema_loader.init_schema }.
74
- to output(/Creating sqlite :memory: database/).to_stdout
75
- end
83
+ it "informs the user it is creating an in-memory database" do
84
+ expect { schema_loader.init_schema }.
85
+ to output(/Creating sqlite :memory: database/).to_stdout
86
+ end
76
87
 
77
- it "does not print the output from the loader" do
78
- expect { schema_loader.init_schema }.
79
- not_to output(/loading schema/).to_stdout
80
- end
88
+ it "does not print the output from the loader" do
89
+ expect { schema_loader.init_schema }.
90
+ not_to output(/loading schema/).to_stdout
81
91
  end
92
+ end
82
93
 
83
- context "when running in silence" do
84
- let(:config) { base_config.merge(verbosity: 'silent') }
94
+ context "when running in silence" do
95
+ let(:config) { base_config.merge(verbosity: 'silent') }
85
96
 
86
- it "outputs nothing" do
87
- expect { schema_loader.init_schema }.to_not output.to_stdout
88
- end
97
+ it "outputs nothing" do
98
+ expect { schema_loader.init_schema }.not_to output.to_stdout
89
99
  end
90
100
  end
91
101
  end
@@ -6,9 +6,9 @@ def in_clean_bundler_environment(*args)
6
6
  end
7
7
 
8
8
  def update_bundle(label)
9
- return if in_clean_bundler_environment(*%w(bundle update --quiet --local))
9
+ return if in_clean_bundler_environment('bundle', 'update', '--quiet', '--local')
10
10
  puts "Starting remote update of the bundle for #{label}"
11
- return if in_clean_bundler_environment(*%w(bundle update))
11
+ return if in_clean_bundler_environment('bundle', 'update')
12
12
  raise "Unable to initialize test environment for #{label}"
13
13
  end
14
14
 
@@ -24,7 +24,7 @@ end
24
24
 
25
25
  def stop_spring
26
26
  capture_subprocess_io do
27
- in_clean_bundler_environment(*%w(bin/spring stop))
27
+ in_clean_bundler_environment('bin/spring', 'stop')
28
28
  end
29
29
  end
30
30
 
@@ -39,7 +39,7 @@ BASE_CONFIG = {
39
39
  "adapter" => 'sqlite3',
40
40
  "database" => ':memory:'
41
41
  }
42
- }
42
+ }.freeze
43
43
 
44
44
  MIGRATING_CONFIG = BASE_CONFIG.dup.tap do |config|
45
45
  config["test"] = config["test"].merge("migrate" => true)
@@ -60,7 +60,8 @@ end
60
60
  VERSIONS = [
61
61
  ["Rails 5.0", 'rails50_app'],
62
62
  ["Rails 5.1", 'rails51_app'],
63
- ]
63
+ ["Rails 5.2", 'rails52_app'],
64
+ ].freeze
64
65
 
65
66
  VERSIONS.each do |label, appdir|
66
67
  Dir.chdir "fixtures/#{appdir}" do
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.4.2
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matijs van Zuijlen
@@ -14,10 +14,10 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2017-04-28 00:00:00.000000000 Z
17
+ date: 2018-02-14 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
- name: railties
20
+ name: activerecord
21
21
  requirement: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
@@ -31,7 +31,7 @@ dependencies:
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5.0'
33
33
  - !ruby/object:Gem::Dependency
34
- name: activerecord
34
+ name: railties
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
@@ -45,33 +45,33 @@ dependencies:
45
45
  - !ruby/object:Gem::Version
46
46
  version: '5.0'
47
47
  - !ruby/object:Gem::Dependency
48
- name: rake
48
+ name: minitest
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '12.0'
53
+ version: '5.2'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '12.0'
60
+ version: '5.2'
61
61
  - !ruby/object:Gem::Dependency
62
- name: minitest
62
+ name: rake
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '5.2'
67
+ version: '12.0'
68
68
  type: :development
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '5.2'
74
+ version: '12.0'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: rspec
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -135,6 +135,24 @@ files:
135
135
  - fixtures/rails51_app/test/fixtures/foos.yml
136
136
  - fixtures/rails51_app/test/test_helper.rb
137
137
  - fixtures/rails51_app/test/unit/foo_test.rb
138
+ - fixtures/rails52_app/Gemfile
139
+ - fixtures/rails52_app/Rakefile
140
+ - fixtures/rails52_app/app/models/application_record.rb
141
+ - fixtures/rails52_app/app/models/foo.rb
142
+ - fixtures/rails52_app/bin/rake
143
+ - fixtures/rails52_app/bin/spring
144
+ - fixtures/rails52_app/config/application.rb
145
+ - fixtures/rails52_app/config/boot.rb
146
+ - fixtures/rails52_app/config/environment.rb
147
+ - fixtures/rails52_app/config/environments/development.rb
148
+ - fixtures/rails52_app/config/environments/production.rb
149
+ - fixtures/rails52_app/config/environments/test.rb
150
+ - fixtures/rails52_app/config/initializers/filter_parameter_logging.rb
151
+ - fixtures/rails52_app/db/migrate/20140830065127_create_foos.rb
152
+ - fixtures/rails52_app/db/schema.rb
153
+ - fixtures/rails52_app/test/fixtures/foos.yml
154
+ - fixtures/rails52_app/test/models/foo_test.rb
155
+ - fixtures/rails52_app/test/test_helper.rb
138
156
  - lib/memory_test_fix.rb
139
157
  - lib/memory_test_fix/railtie.rb
140
158
  - lib/memory_test_fix/schema_file_loader.rb
@@ -158,7 +176,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
158
176
  requirements:
159
177
  - - ">="
160
178
  - !ruby/object:Gem::Version
161
- version: '0'
179
+ version: 2.2.0
162
180
  required_rubygems_version: !ruby/object:Gem::Requirement
163
181
  requirements:
164
182
  - - ">="
@@ -166,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
184
  version: '0'
167
185
  requirements: []
168
186
  rubyforge_project:
169
- rubygems_version: 2.6.8
187
+ rubygems_version: 2.7.3
170
188
  signing_key:
171
189
  specification_version: 4
172
190
  summary: Use SQLite3 in-memory database for Rails tests.