adaptable_tests_for_rails 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.rvmrc +2 -0
- data/Gemfile +4 -0
- data/README.rdoc +75 -0
- data/Rakefile +2 -0
- data/adaptable_tests_for_rails.gemspec +22 -0
- data/lib/adaptable_tests_for_rails.rb +4 -0
- data/lib/adaptable_tests_for_rails/railtie.rb +33 -0
- data/lib/adaptable_tests_for_rails/version.rb +3 -0
- metadata +78 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
data/Gemfile
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
= adaptable_tests_for_rails
|
2
|
+
|
3
|
+
Sets up testing environment for multiple databases.
|
4
|
+
|
5
|
+
|
6
|
+
== Installation
|
7
|
+
|
8
|
+
Using bundler:
|
9
|
+
|
10
|
+
group :test do
|
11
|
+
gem 'adaptable_tests_for_rails'
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
== Configuration
|
16
|
+
|
17
|
+
Create the different environments in database.yml (they should all be prefixed with test_) and specify a default configuration:
|
18
|
+
|
19
|
+
test_sqlite_memory: &DEFAULT_TEST
|
20
|
+
adapter: sqlite3
|
21
|
+
database: ":memory:"
|
22
|
+
verbosity: quiet
|
23
|
+
|
24
|
+
test_sqlite_file:
|
25
|
+
adapter: sqlite3
|
26
|
+
database: db/test.sqlite3
|
27
|
+
|
28
|
+
test_mysql:
|
29
|
+
database: gvt-us_test
|
30
|
+
<<: *base
|
31
|
+
|
32
|
+
test:
|
33
|
+
<<: *DEFAULT_TEST
|
34
|
+
|
35
|
+
|
36
|
+
== Usage
|
37
|
+
|
38
|
+
Now you can run tests normally.
|
39
|
+
|
40
|
+
rake
|
41
|
+
|
42
|
+
This will run tests with *DEFAULT_TEST configuration.
|
43
|
+
|
44
|
+
You can also run tests for a specific database config:
|
45
|
+
|
46
|
+
rake spec DB=sqlite_file
|
47
|
+
|
48
|
+
This will run the test_sqlite_file configuration.
|
49
|
+
|
50
|
+
Notice that none of this configuration is unique to adaptable_tests_for_rails. Each of these configuration paradigms are simply
|
51
|
+
Ruby or Rails paradigms.
|
52
|
+
|
53
|
+
|
54
|
+
== License
|
55
|
+
|
56
|
+
Copyright (c) 2011 C. Jason Harrelson (midas)
|
57
|
+
|
58
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
59
|
+
a copy of this software and associated documentation files (the
|
60
|
+
"Software"), to deal in the Software without restriction, including
|
61
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
62
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
63
|
+
permit persons to whom the Software is furnished to do so, subject to
|
64
|
+
the following conditions:
|
65
|
+
|
66
|
+
The above copyright notice and this permission notice shall be
|
67
|
+
included in all copies or substantial portions of the Software.
|
68
|
+
|
69
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
70
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
71
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
72
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
73
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
74
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
75
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "adaptable_tests_for_rails/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "adaptable_tests_for_rails"
|
7
|
+
s.version = AdaptableTestsForRails::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["C. Jason Harrelson (midas)"]
|
10
|
+
s.email = ["jason@lookforwardenterprises.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Adds SQLite in memory and file testing abilities in addition to MySQL or other db tests.}
|
13
|
+
s.description = %q{Adds SQLite in memory and file testing abilities in addition to MySQL or other db
|
14
|
+
tests. You must provide the configuration in your database.yml file.}
|
15
|
+
|
16
|
+
s.rubyforge_project = "adaptable_tests_for_rails"
|
17
|
+
|
18
|
+
s.files = `git ls-files`.split("\n")
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module AdaptableTestsForRails
|
4
|
+
class Railtie < ::Rails::Railtie
|
5
|
+
initializer "adaptable_tests_for_rails.initialize" do
|
6
|
+
setup_test_environment( ENV['DB'] || 'test' )
|
7
|
+
end
|
8
|
+
|
9
|
+
config.before_initialize do
|
10
|
+
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup_test_environment( env )
|
14
|
+
puts "", "Connecting to #{db_type( env )} database ..."
|
15
|
+
ActiveRecord::Base.establish_connection( Rails.configuration.database_configuration["test_#{env}"] )
|
16
|
+
puts building_database_statement, ""
|
17
|
+
load schema_path
|
18
|
+
end
|
19
|
+
|
20
|
+
def db_type( env )
|
21
|
+
env.gsub( /test_/, '' ).gsub( /_/, ' ' )
|
22
|
+
end
|
23
|
+
|
24
|
+
def building_database_statement
|
25
|
+
"Building database from db/schema.rb ..."
|
26
|
+
end
|
27
|
+
|
28
|
+
def schema_path
|
29
|
+
"#{Rails.root}/db/schema.rb"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: adaptable_tests_for_rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- C. Jason Harrelson (midas)
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-05-02 00:00:00 -05:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: |-
|
23
|
+
Adds SQLite in memory and file testing abilities in addition to MySQL or other db
|
24
|
+
tests. You must provide the configuration in your database.yml file.
|
25
|
+
email:
|
26
|
+
- jason@lookforwardenterprises.com
|
27
|
+
executables: []
|
28
|
+
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files: []
|
32
|
+
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- .rvmrc
|
36
|
+
- Gemfile
|
37
|
+
- README.rdoc
|
38
|
+
- Rakefile
|
39
|
+
- adaptable_tests_for_rails.gemspec
|
40
|
+
- lib/adaptable_tests_for_rails.rb
|
41
|
+
- lib/adaptable_tests_for_rails/railtie.rb
|
42
|
+
- lib/adaptable_tests_for_rails/version.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: ""
|
45
|
+
licenses: []
|
46
|
+
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
hash: 3
|
67
|
+
segments:
|
68
|
+
- 0
|
69
|
+
version: "0"
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project: adaptable_tests_for_rails
|
73
|
+
rubygems_version: 1.6.0
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Adds SQLite in memory and file testing abilities in addition to MySQL or other db tests.
|
77
|
+
test_files: []
|
78
|
+
|