Skip to content

Commit 3f28678

Browse files
committed
👷 Workflows: fix CouchDB initialization for tests
1 parent ccee650 commit 3f28678

File tree

8 files changed

+97
-49
lines changed

8 files changed

+97
-49
lines changed

.envrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export K_SOUP_COV_DO=true # Means you want code coverage
2020
export K_SOUP_COV_COMMAND_NAME="RSpec Coverage"
2121
export K_SOUP_COV_FORMATTERS="html,tty"
2222
export K_SOUP_COV_MIN_BRANCH=80 # Means you want to enforce X% branch coverage
23-
export K_SOUP_COV_MIN_LINE=69 # Means you want to enforce X% line coverage
23+
export K_SOUP_COV_MIN_LINE=91 # Means you want to enforce X% line coverage
2424
export K_SOUP_COV_MIN_HARD=true # Means you want the build to fail if the coverage thresholds are not met
2525
export K_SOUP_COV_MULTI_FORMATTERS=true
2626
export MAX_ROWS=1 # Setting for simplecov-console gem for tty output, limits to the worst N rows of bad coverage

.github/workflows/coverage.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Ruby - Coverage
22

33
env:
44
K_SOUP_COV_MIN_BRANCH: 80
5-
K_SOUP_COV_MIN_LINE: 69
5+
K_SOUP_COV_MIN_LINE: 91
66
K_SOUP_COV_MIN_HARD: true
77
K_SOUP_COV_DO: true
88
K_SOUP_COV_COMMAND_NAME: "RSpec Coverage"

.github/workflows/unsupported.yml

-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ jobs:
3535
strategy:
3636
fail-fast: false
3737
matrix:
38-
gemfile: "Appraisal.root"
39-
rubygems: '3.4.22'
40-
bundler: '2.4.22'
4138
include:
4239
# Ruby 2.6
4340
- ruby: "2.6"

README.md

+71-36
Original file line numberDiff line numberDiff line change
@@ -282,42 +282,77 @@ Please contribute some documentation if you have the gumption! The maintainer's
282282
3. Commit your changes (`git commit -am ‘Added some feature’`)
283283
4. Push to the branch (`git push origin my-new-feature`)
284284
5. Make sure to add tests for it. This is important so I don’t break it in a future version unintentionally.
285-
- NOTE: In order to run *all* the tests you will need to have the following databases installed, configured, and running.
286-
1. [RethinkDB](https://rethinkdb.com), an open source, real-time, web database, [installed](https://rethinkdb.com/docs/install/) and [running](https://rethinkdb.com/docs/start-a-server/), e.g.
287-
```bash
288-
brew install rethinkdb
289-
rethinkdb
290-
```
291-
2. [MongoDB](https://docs.mongodb.com/manual/administration/install-community/)
292-
```bash
293-
brew tap mongodb/brew
294-
brew install [email protected]
295-
mongod --config /usr/local/etc/mongod.conf
296-
```
297-
3. [CouchDB](https://couchdb.apache.org) (download the .app)
298-
299-
To run all tests on all databases (except RethinkDB):
300-
```bash
301-
bundle exec rake spec
302-
```
303-
To run a specific DB:
304-
```bash
305-
# CouchDB / CouchPotato
306-
bundle exec rspec spec spec_orms --tag 'couchdb'
307-
308-
# ActiveRecord and Sequel, as they both use the in-memory SQLite driver.
309-
bundle exec rspec spec spec_orms --tag 'sqlite3'
310-
311-
# NOTE - mongoid and nobrainer specs can't be isolated with "tag" because it still loads everything,
312-
# and the two libraries are fundamentally incompatible.
313-
314-
# MongoDB / Mongoid
315-
bundle exec rspec spec_orms/mongoid_spec.rb
316-
317-
# RethinkDB / NoBrainer (Ignored by CI! see spec file for more)
318-
bundle exec rspec spec_ignored/nobrainer_spec.rb
319-
```
320-
6. Create new Pull Request
285+
286+
NOTE: In order to run *all* the tests you will need to have the following databases installed, configured, and running.
287+
288+
1. [RethinkDB](https://rethinkdb.com), an open source, real-time, web database, [installed](https://rethinkdb.com/docs/install/) and [running](https://rethinkdb.com/docs/start-a-server/), e.g.
289+
```bash
290+
brew install rethinkdb
291+
rethinkdb
292+
```
293+
2. [MongoDB](https://docs.mongodb.com/manual/administration/install-community/)
294+
```bash
295+
brew tap mongodb/brew
296+
brew install [email protected]
297+
mongod --config /usr/local/etc/mongod.conf
298+
```
299+
3. [CouchDB](https://couchdb.apache.org) - download the .app, or:
300+
```bash
301+
brew install couchdb
302+
```
303+
CouchDB 3.x requires a set admin password set before startup.
304+
Add one to your `$HOMEBREW_PREFIX/etc/local.ini` before starting CouchDB e.g.:
305+
```ini
306+
[admins]
307+
admin = yourabsolutesecret
308+
```
309+
Also add whatever password you set to your `.env.local`:
310+
```dotenv
311+
export COUCHDB_PASSWORD=yourabsolutesecret
312+
```
313+
Then start the CouchDB service
314+
```bash
315+
brew services start couchdb
316+
```
317+
318+
Now you can run any of the tests!
319+
320+
To run all tests on all databases (except RethinkDB):
321+
```bash
322+
bundle exec rake spec:orm:all
323+
```
324+
325+
To run all tests that do not require any additional services, like MongoDB, CouchDB, or RethinkDB:
326+
```bash
327+
bundle exec rake test
328+
```
329+
330+
To run a specific DB:
331+
```bash
332+
# CouchDB / CouchPotato
333+
bundle exec rspec spec spec_orms --tag 'couchdb'
334+
335+
# ActiveRecord and Sequel, as they both use the in-memory SQLite driver.
336+
bundle exec rspec spec spec_orms --tag 'sqlite3'
337+
338+
# NOTE - mongoid and nobrainer specs can't be isolated with "tag" because it still loads everything,
339+
# and the two libraries are fundamentally incompatible.
340+
341+
# MongoDB / Mongoid
342+
bundle exec rspec spec_orms/mongoid_spec.rb
343+
344+
# RethinkDB / NoBrainer (Ignored by CI! see spec file for reasons)
345+
bundle exec rspec spec_ignored/nobrainer_spec.rb
346+
```
347+
348+
### Finally
349+
350+
Run all the default tasks, which includes running the gradually autocorrecting linter, `rubocop-gradual`.
351+
```bash
352+
bundle exec rake
353+
```
354+
355+
📌 Create new Pull Request with your changes 📌
321356

322357
## License
323358

lib/omniauth/identity/models/couch_potato.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def self.included(base)
1717
include(::OmniAuth::Identity::SecurePassword)
1818

1919
# validations: true (default) incurs a dependency on ActiveModel, but CouchPotato is ActiveModel based.
20-
has_secure_password(validations: false)
20+
has_secure_password
2121

2222
def self.auth_key=(key)
2323
super
@@ -29,7 +29,7 @@ def self.locate(search_hash)
2929
end
3030

3131
def save
32-
CouchPotato.database.save(self)
32+
CouchPotato.database.save_document(self)
3333
end
3434
end
3535
end

lib/omniauth/identity/models/sequel.rb

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ def self.included(base)
3131

3232
def self.auth_key=(key)
3333
super
34+
# Sequel version of validates_uniqueness_of! Does not incur ActiveRecord dependency!
3435
validates_uniqueness_of(:key, case_sensitive: false)
3536
end
3637

spec/support/shared_contexts/persistable_model.rb

+18-5
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,29 @@
88

99
include_context "instance with instance methods"
1010

11+
before do
12+
instance.email = DEFAULT_EMAIL
13+
instance.password = DEFAULT_PASSWORD
14+
instance.password_confirmation = DEFAULT_PASSWORD
15+
end
16+
17+
describe "#valid?" do
18+
subject(:is_valid) do
19+
instance.valid?
20+
end
21+
22+
it "is valid" do
23+
expect(is_valid).to eq(true)
24+
end
25+
end
26+
1127
describe "#save" do
12-
subject(:save) do
13-
instance.email = DEFAULT_EMAIL
14-
instance.password = DEFAULT_PASSWORD
15-
instance.password_confirmation = DEFAULT_PASSWORD
28+
subject(:is_saved) do
1629
instance.save
1730
end
1831

1932
it "does not raise an error" do
20-
save
33+
block_is_expected.not_to raise_error
2134
end
2235
end
2336
end

spec_orms/couch_potato_spec.rb

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44

55
RSpec.describe(OmniAuth::Identity::Models::CouchPotatoModule, :couchdb) do
66
before(:all) do
7-
CouchPotato::Config.database_name = "http://admin:[email protected]:5984/"
7+
CouchPotato::Config.database_host = "http://admin:#{ENV.fetch("COUCHDB_PASSWORD", "password")}@127.0.0.1:5984"
8+
CouchPotato::Config.database_name = "test"
9+
CouchPotato.couchrest_database.recreate!
810
end
911

1012
before do

0 commit comments

Comments
 (0)