nosql 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -2
- data/lib/nosql.rb +1 -1
- data/lib/nosql/version.rb +1 -1
- data/spec/nosql_spec.rb +17 -14
- metadata +3 -3
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
# Nosql
|
2
2
|
|
3
|
-
|
3
|
+
A simple ActiveRecord 'adapter' that raises an exception whenever the database is used. This is to ensure unit tests do not integrate with a database.
|
4
|
+
|
5
|
+
When testing scopes and complex queries, applying a tag can disable this gem and replace the normal adapter implementation.
|
6
|
+
|
7
|
+
[Write up on usage](http://pivotallabs.com/testing-strategies-rspec-nulldb-nosql)
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
@@ -18,7 +22,18 @@ Or install it yourself as:
|
|
18
22
|
|
19
23
|
## Usage
|
20
24
|
|
21
|
-
|
25
|
+
If you were using RSpec and tagged tests which did hit the datbase with ':db', then you could use the following.
|
26
|
+
|
27
|
+
config.around(:each, type: :model) do |example|
|
28
|
+
if example.metadata[:db]
|
29
|
+
Nosql::Connection.disable!
|
30
|
+
example.run
|
31
|
+
else
|
32
|
+
Nosql::Connection.enable!
|
33
|
+
example.run
|
34
|
+
Nosql::Connection.disable!
|
35
|
+
end
|
36
|
+
end
|
22
37
|
|
23
38
|
## Contributing
|
24
39
|
|
@@ -27,3 +42,8 @@ TODO: Write usage instructions here
|
|
27
42
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
43
|
4. Push to the branch (`git push origin my-new-feature`)
|
29
44
|
5. Create new Pull Request
|
45
|
+
|
46
|
+
## Authors
|
47
|
+
|
48
|
+
* [Robbie](https://github.com/robb1e)
|
49
|
+
* [JT](https://github.com/jtarchie)
|
data/lib/nosql.rb
CHANGED
data/lib/nosql/version.rb
CHANGED
data/spec/nosql_spec.rb
CHANGED
@@ -11,17 +11,10 @@ end
|
|
11
11
|
class Post < ActiveRecord::Base; end
|
12
12
|
|
13
13
|
describe "With ActiveRecord::Base" do
|
14
|
-
context "with a real db connection" do
|
15
|
-
it "can create a record" do
|
16
|
-
expect {
|
17
|
-
Post.create
|
18
|
-
}.to change { Post.count }.by(1)
|
19
|
-
end
|
20
|
-
end
|
21
14
|
|
22
15
|
context "with a null db connection" do
|
23
16
|
before do
|
24
|
-
|
17
|
+
Post.first
|
25
18
|
ActiveRecord::Base.connection.stub(:exec).and_raise(Nosql::Error)
|
26
19
|
ActiveRecord::Base.connection.stub(:exec_query).and_raise(Nosql::Error)
|
27
20
|
end
|
@@ -53,19 +46,20 @@ describe "With ActiveRecord::Base" do
|
|
53
46
|
it "can new an instance up" do
|
54
47
|
expect {
|
55
48
|
Post.new
|
56
|
-
}.to_not raise_error
|
49
|
+
}.to_not raise_error
|
57
50
|
end
|
58
51
|
|
59
|
-
|
52
|
+
xit "can create stub models" do
|
60
53
|
expect {
|
61
54
|
stub_model(:post)
|
62
|
-
}.to_not raise_error
|
55
|
+
}.to_not raise_error
|
63
56
|
end
|
64
57
|
|
65
58
|
end
|
66
59
|
|
67
60
|
context "with a nosql adapter connection" do
|
68
61
|
before do
|
62
|
+
Post.first
|
69
63
|
Nosql::Connection.enable!
|
70
64
|
end
|
71
65
|
|
@@ -100,14 +94,23 @@ describe "With ActiveRecord::Base" do
|
|
100
94
|
it "can new an instance up" do
|
101
95
|
expect {
|
102
96
|
Post.new
|
103
|
-
}.to_not raise_error
|
97
|
+
}.to_not raise_error
|
104
98
|
end
|
105
99
|
|
106
|
-
|
100
|
+
xit "can create stub models" do
|
107
101
|
expect {
|
108
102
|
stub_model(:post)
|
109
|
-
}.to_not raise_error
|
103
|
+
}.to_not raise_error
|
110
104
|
end
|
111
105
|
|
112
106
|
end
|
107
|
+
|
108
|
+
context "with a real db connection" do
|
109
|
+
it "can create a record" do
|
110
|
+
expect {
|
111
|
+
Post.create
|
112
|
+
}.to change { Post.count }.by(1)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
113
116
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nosql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sqlite3
|
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
97
|
version: '0'
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project:
|
100
|
-
rubygems_version: 1.8.
|
100
|
+
rubygems_version: 1.8.25
|
101
101
|
signing_key:
|
102
102
|
specification_version: 3
|
103
103
|
summary: A simple ActiveRecord 'adapter' that raises on any call
|