nulldb 0.3.7.pre.alpha.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.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +28 -0
  3. data/.travis.yml +49 -0
  4. data/Appraisals +36 -0
  5. data/CHANGES.md +75 -0
  6. data/Gemfile +14 -0
  7. data/LICENSE +21 -0
  8. data/README.rdoc +147 -0
  9. data/Rakefile +14 -0
  10. data/VERSION +1 -0
  11. data/gemfiles/activerecord_2.3.gemfile +17 -0
  12. data/gemfiles/activerecord_3.0.gemfile +16 -0
  13. data/gemfiles/activerecord_3.1.gemfile +16 -0
  14. data/gemfiles/activerecord_3.2.gemfile +16 -0
  15. data/gemfiles/activerecord_4.0.gemfile +16 -0
  16. data/gemfiles/activerecord_4.1.gemfile +16 -0
  17. data/gemfiles/activerecord_4.2.gemfile +16 -0
  18. data/gemfiles/activerecord_5.0.gemfile +16 -0
  19. data/gemfiles/activerecord_5.1.gemfile +16 -0
  20. data/gemfiles/activerecord_master.gemfile +18 -0
  21. data/lib/active_record/connection_adapters/nulldb_adapter.rb +21 -0
  22. data/lib/active_record/connection_adapters/nulldb_adapter/checkpoint.rb +13 -0
  23. data/lib/active_record/connection_adapters/nulldb_adapter/column.rb +20 -0
  24. data/lib/active_record/connection_adapters/nulldb_adapter/configuration.rb +5 -0
  25. data/lib/active_record/connection_adapters/nulldb_adapter/core.rb +324 -0
  26. data/lib/active_record/connection_adapters/nulldb_adapter/empty_result.rb +26 -0
  27. data/lib/active_record/connection_adapters/nulldb_adapter/index_definition.rb +5 -0
  28. data/lib/active_record/connection_adapters/nulldb_adapter/null_object.rb +13 -0
  29. data/lib/active_record/connection_adapters/nulldb_adapter/statement.rb +15 -0
  30. data/lib/active_record/connection_adapters/nulldb_adapter/table_definition.rb +5 -0
  31. data/lib/activerecord-nulldb-adapter.rb +1 -0
  32. data/lib/nulldb.rb +2 -0
  33. data/lib/nulldb/arel_compiler.rb +6 -0
  34. data/lib/nulldb/core.rb +39 -0
  35. data/lib/nulldb/extensions.rb +42 -0
  36. data/lib/nulldb/rails.rb +4 -0
  37. data/lib/nulldb_rspec.rb +104 -0
  38. data/lib/tasks/database.rake +32 -0
  39. data/nulldb.gemspec +27 -0
  40. data/spec/nulldb_spec.rb +345 -0
  41. data/spec/spec.opts +1 -0
  42. metadata +172 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: c5f28228f29a027603172aaf61a0c08ec2958833
4
+ data.tar.gz: 8824bed0fba061b342c3912d65190f295b87c11b
5
+ SHA512:
6
+ metadata.gz: d506cd2de2bcf2c815cf2c40b27e26200a03b0cc908d152b00da55d2af50c7935c3be10b292cd6c13d3675918cd619405a17a94860e35f65751cac6055800073
7
+ data.tar.gz: '086e9b1e30fe1063d12b1ae5251ccb0256051fce53e981183d0765a7092fee03ce01a41cb59769f38166394da583e9cd8c43a630bd418f610a1d38fb2b6703d2'
@@ -0,0 +1,28 @@
1
+ # generated coverage
2
+ coverage
3
+ coverage.data
4
+
5
+ # docs
6
+ rdoc
7
+ doc
8
+ .yardoc
9
+
10
+ # bundler
11
+ .bundle
12
+ *.lock
13
+
14
+ # gem
15
+ pkg
16
+
17
+ # mac os specific
18
+ .DS_Store
19
+
20
+ # vim
21
+ *.swp
22
+
23
+ # rvm
24
+ .rvmrc
25
+ .ruby-*
26
+
27
+ # ginger
28
+ .ginger
@@ -0,0 +1,49 @@
1
+ language: ruby
2
+ cache: bundler
3
+ bundler_args: --without development
4
+ sudo: false
5
+
6
+ rvm:
7
+ - 1.9.3
8
+ - 2.1.10
9
+ - 2.2.5
10
+ - 2.3.1
11
+ - jruby
12
+ - rbx
13
+
14
+ matrix:
15
+ fast_finish: true
16
+ allow_failures:
17
+ - rvm: jruby
18
+ - rvm: rbx
19
+ exclude:
20
+ - rvm: 1.9.3
21
+ gemfile: gemfiles/activerecord_master.gemfile
22
+ - rvm: 2.1.10
23
+ gemfile: gemfiles/activerecord_master.gemfile
24
+ - rvm: 1.9.3
25
+ gemfile: gemfiles/activerecord_5.1.gemfile
26
+ - rvm: 2.1.10
27
+ gemfile: gemfiles/activerecord_5.1.gemfile
28
+ - rvm: 1.9.3
29
+ gemfile: gemfiles/activerecord_5.0.gemfile
30
+ - rvm: 2.1.10
31
+ gemfile: gemfiles/activerecord_5.0.gemfile
32
+ - rvm: 2.1.10
33
+ gemfile: gemfiles/activerecord_2.3.gemfile
34
+ - rvm: 2.2.5
35
+ gemfile: gemfiles/activerecord_2.3.gemfile
36
+ - rvm: 2.3.1
37
+ gemfile: gemfiles/activerecord_2.3.gemfile
38
+
39
+ gemfile:
40
+ - gemfiles/activerecord_2.3.gemfile
41
+ - gemfiles/activerecord_3.0.gemfile
42
+ - gemfiles/activerecord_3.1.gemfile
43
+ - gemfiles/activerecord_3.2.gemfile
44
+ - gemfiles/activerecord_4.0.gemfile
45
+ - gemfiles/activerecord_4.1.gemfile
46
+ - gemfiles/activerecord_4.2.gemfile
47
+ - gemfiles/activerecord_5.0.gemfile
48
+ - gemfiles/activerecord_5.1.gemfile
49
+ - gemfiles/activerecord_master.gemfile
@@ -0,0 +1,36 @@
1
+ appraise "activerecord-2.3" do
2
+ gem 'iconv', :platforms => :ruby
3
+ gem "activerecord", "~> 2.3.0"
4
+ end
5
+
6
+ appraise "activerecord-3.0" do
7
+ gem "activerecord", "~> 3.0.0"
8
+ end
9
+
10
+ appraise "activerecord-3.1" do
11
+ gem "activerecord", "~> 3.1.0"
12
+ end
13
+
14
+ appraise "activerecord-3.2" do
15
+ gem "activerecord", "~> 3.2.0"
16
+ end
17
+
18
+ appraise "activerecord-4.0" do
19
+ gem "activerecord", "~> 4.0.0"
20
+ end
21
+
22
+ appraise "activerecord-4.1" do
23
+ gem "activerecord", "~> 4.1.0"
24
+ end
25
+
26
+ appraise "activerecord-4.2" do
27
+ gem "activerecord", "~> 4.2.0"
28
+ end
29
+
30
+ appraise "activerecord-5.0" do
31
+ gem "activerecord", "~> 5.0.0"
32
+ end
33
+
34
+ appraise "activerecord-5.1" do
35
+ gem "activerecord", "~> 5.1.0"
36
+ end
@@ -0,0 +1,75 @@
1
+ 0.3.7 (2017-06-04)
2
+ -----------
3
+ - Adds support for ActiveRecord 5.1/5.2.
4
+ - Support limit and null
5
+
6
+
7
+ 0.3.6 (2016-11-23)
8
+ -----------
9
+ - Adds support for ActiveRecord 5.0.
10
+
11
+
12
+ 0.3.5 (2016-09-26)
13
+ -----------
14
+ - Adds support for #cast_values on EmptyResult instance.
15
+
16
+
17
+ 0.3.4 (2016-08-10)
18
+ -----------
19
+ - Adds support for Postgres-specific 'enable_extension'
20
+
21
+
22
+ 0.3.3 (2016-08-01)
23
+ -----------
24
+ - Adds support for ActiveRecord 4.2.
25
+ - Deprecates support for MRI 2.0.0.
26
+
27
+
28
+ 0.3.2 (2016-01-25)
29
+ -----------
30
+ - Deprecates support for MRI 1.9.3 and adds support for 2.3.x.
31
+ - Fixes :string column type fetching for AR 4.1.
32
+
33
+
34
+ 0.3.1 (2014-02-17)
35
+ -----------
36
+ - Removes accidental dependency on iconv. Fixing JRuby support.
37
+
38
+
39
+ 0.3.0 (2014-01-31)
40
+ -----------
41
+ - Drops 1.8.7 support.
42
+ - Adds support for Ruby 2.0, 2.1 and ActiveRecord 4.
43
+ - Fixes ActiveRecord 2.3 support on Ruby 2 and up.
44
+ - Misc small fixes
45
+
46
+
47
+ 0.2.1 (2010-09-01)
48
+ -----------
49
+ - Updated Rails 3 support so that nulldb works against AR 3.0.0.
50
+ - Add support for RSpec 2.
51
+
52
+
53
+ 0.2.0 (2010-03-20)
54
+ -----------
55
+ - Rails 3 support. All specs pass against ActiveRecord 3.0.0.beta.
56
+
57
+
58
+ 0.1.1 (2010-03-15)
59
+ -----------
60
+ - Released as activerecord-nulldb-adapter gem.
61
+
62
+
63
+ 0.1.0 (2010-03-02)
64
+ -----------
65
+ - Released as nulldb gem, with some bug fixes.
66
+
67
+
68
+ 0.0.2 (2007-05-31)
69
+ -----------
70
+ - Moved to Rubyforge
71
+
72
+
73
+ 0.0.1 (2007-02-18)
74
+ -----------
75
+ - Initial Release
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'activerecord', '>= 2.0.0'
4
+
5
+ group :development, :test do
6
+ gem 'spec'
7
+ gem 'rspec', '>= 1.2.9'
8
+ gem 'rake'
9
+ end
10
+
11
+ group :development do
12
+ gem 'appraisal'
13
+ gem 'simplecov', :require => false
14
+ end
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2008 Avdi Grimm
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,147 @@
1
+ {<img src="https://badge.fury.io/rb/activerecord-nulldb-adapter.png" alt="Gem Version" />}[http://badge.fury.io/rb/activerecord-nulldb-adapter]
2
+ {<img src="https://codeclimate.com/github/nulldb/nulldb.png" />}[https://codeclimate.com/github/nulldb/nulldb]
3
+ {<img src="https://travis-ci.org/nulldb/nulldb.png?branch=master" alt="Build Status" />}[https://travis-ci.org/nulldb/nulldb]
4
+
5
+
6
+ = The NullDB Connection Adapter Plugin
7
+
8
+ == What
9
+
10
+ NullDB is the Null Object pattern as applied to ActiveRecord database
11
+ adapters. It is a database backend that translates database
12
+ interactions into no-ops. Using NullDB enables you to test your model
13
+ business logic - including +after_save+ hooks - without ever touching
14
+ a real database.
15
+
16
+ == Compatibility
17
+
18
+ === Ruby
19
+ Currently supported Ruby versions: MRI 1.9.3, 2.0.0, 2.1.x, 2.2.x, 2.3.x
20
+
21
+ Experimental support provided for: JRuby, Rubinius (both in 1.9 mode)
22
+
23
+ === ActiveRecord
24
+ Any version of ActiveRecord since 2.0, including ActiveRecord 5.0
25
+
26
+ It is tested against AR 2.3, 3.0, 3.1, 3.2, 4.0, 4.1, 4.2 and 5.0.
27
+
28
+ == Installation
29
+
30
+ gem install activerecord-nulldb-adapter
31
+
32
+ == How
33
+
34
+ Once installed, NullDB can be used much like any other ActiveRecord
35
+ database adapter:
36
+
37
+ ActiveRecord::Base.establish_connection :adapter => :nulldb
38
+
39
+ NullDB needs to know where you keep your schema file in order to
40
+ reflect table metadata. By default it looks in
41
+ RAILS_ROOT/db/schema.rb. You can override that by setting the
42
+ +schema+ option:
43
+
44
+ ActiveRecord::Base.establish_connection :adapter => :nulldb,
45
+ :schema => 'foo/myschema.rb'
46
+
47
+ NullDB comes with RSpec integration. To replace the database with
48
+ NullDB in all of your specs, put the following in your
49
+ spec/spec_helper:
50
+
51
+ require 'nulldb_rspec'
52
+ include NullDB::RSpec::NullifiedDatabase
53
+
54
+ Or if you just want to use NullDB in a specific spec context, you can
55
+ include the same module inside a context:
56
+
57
+ require 'nulldb_rspec'
58
+
59
+ describe Employee, "with access to the database" do
60
+ fixtures :employees
61
+ # ...
62
+ end
63
+
64
+ describe Employee, "with NullDB" do
65
+ include NullDB::RSpec::NullifiedDatabase
66
+ # ...
67
+ end
68
+
69
+ If you want to have NullDB enabled by default but disabled for particular contexts then (see this post)[https://web.archive.org/web/20120419204019/http://andywaite.com/2011/5/18/rspec-disable-nulldb]
70
+
71
+ NullDB::Rspec provides some custom matcher support for verifying
72
+ expectations about interactions with the database:
73
+
74
+ describe Employee do
75
+ include NullDB::RSpec::NullifiedDatabase
76
+
77
+ it "should cause an insert statement to be executed" do
78
+ Employee.create!
79
+ Employee.connection.should have_executed(:insert)
80
+ end
81
+ end
82
+
83
+ UnitRecord-style verification that no database calls have been made at
84
+ all can be achieved by using the special +:anything+ symbol:
85
+
86
+ describe "stuff that shouldn't touch the database" do
87
+ after :each do
88
+ Employee.connection.should_not have_executed(:anything)
89
+ end
90
+ # ...
91
+ end
92
+
93
+ You can also experiment with putting NullDB in your database.yml:
94
+
95
+ unit_test:
96
+ adapter: nulldb
97
+
98
+ However, due to the way Rails hard-codes specific database adapters
99
+ into its standard Rake tasks, you may find that this generates
100
+ unexpected and difficult-to-debug behavior. Workarounds for this are
101
+ under development.
102
+
103
+ == Why
104
+
105
+ There are a number of advantages to writing unit tests that never
106
+ touch the database. The biggest is probably speed of execution - unit
107
+ tests must be fast for test-driven development to be practical.
108
+ Another is separation of concerns: unit tests should be exercising
109
+ only the business logic contained in your models, not ActiveRecord.
110
+ For more on why testing-sans-database is a good idea, see:
111
+ http://www.dcmanges.com/blog/rails-unit-record-test-without-the-database.
112
+
113
+ NullDB is one way to separate your unit tests from the database. It
114
+ was inspired by the ARBS[http://arbs.rubyforge.org/] and
115
+ UnitRecord[http://unit-test-ar.rubyforge.org/] libraries. It differs
116
+ from them in that rather than modifying parts of ActiveRecord, it
117
+ implements the same [semi-]well-documented public interface that the
118
+ other standard database adapters, like MySQL and SQLServer,
119
+ implement. This has enabled it to evolve to support new ActiveRecord
120
+ versions relatively easily.
121
+
122
+ One concrete advantage of this null-object pattern design is that it
123
+ is possible with NullDB to test +after_save+ hooks. With NullDB, you
124
+ can call +#save+ and all of the usual callbacks will be called - but
125
+ nothing will be saved.
126
+
127
+ == Limitations
128
+
129
+ * It is *not* an in-memory database. Finds will not work. Neither
130
+ will +reload+, currently. Test fixtures won't work either, for
131
+ obvious reasons.
132
+ * It has only the most rudimentery schema/migration support. Complex
133
+ migrations will probably break it.
134
+ * Lots of other things probably don't work. Patches welcome!
135
+
136
+ == Who
137
+
138
+ NullDB was originally written by Avdi Grimm <mailto:avdi@avdi.org>.
139
+ It is currently maintained by {Bram de Vries}[https://github.com/blaet].
140
+
141
+ == Where
142
+
143
+ * Homepage: https://github.com/nulldb/nulldb
144
+
145
+ == License
146
+
147
+ See the LICENSE file for licensing information.
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rspec/core/rake_task'
4
+
5
+ require 'bundler/gem_tasks'
6
+
7
+ RSpec::Core::RakeTask.new(:spec)
8
+ task :default => :spec
9
+
10
+ require 'rdoc/task'
11
+ Rake::RDocTask.new do |rd|
12
+ rd.main = "README.rdoc"
13
+ rd.rdoc_files.include("README.rdoc", "LICENSE", "lib/**/*.rb")
14
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.3.5
@@ -0,0 +1,17 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 2.3.0"
6
+ gem "iconv", :platforms => :ruby
7
+
8
+ group :development, :test do
9
+ gem "spec"
10
+ gem "rspec", ">= 1.2.9"
11
+ gem "rake"
12
+ end
13
+
14
+ group :development do
15
+ gem "appraisal"
16
+ gem "simplecov", :require => false
17
+ end
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.0.0"
6
+
7
+ group :development, :test do
8
+ gem "spec"
9
+ gem "rspec", ">= 1.2.9"
10
+ gem "rake"
11
+ end
12
+
13
+ group :development do
14
+ gem "appraisal"
15
+ gem "simplecov", :require => false
16
+ end
@@ -0,0 +1,16 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "activerecord", "~> 3.1.0"
6
+
7
+ group :development, :test do
8
+ gem "spec"
9
+ gem "rspec", ">= 1.2.9"
10
+ gem "rake"
11
+ end
12
+
13
+ group :development do
14
+ gem "appraisal"
15
+ gem "simplecov", :require => false
16
+ end