|
14 | 14 | # If you try it, one or both of them will not work. |
15 | 15 | # |
16 | 16 | # However, if you have RethinkDB installed locally, this spec should work in isolation! |
17 | | -require "nobrainer" |
18 | | - |
19 | | -RSpec.describe(OmniAuth::Identity::Models::NoBrainer, :rethinkdb) do |
20 | | - before(:context) do |
21 | | - NoBrainer.configure do |config| |
22 | | - config.app_name = "DeezBrains" |
23 | | - config.rethinkdb_urls = ["rethinkdb://127.0.0.1:28015/DeezBrains_test"] |
24 | | - config.table_options = { |
25 | | - shards: 1, |
26 | | - replicas: 1, |
27 | | - write_acks: :majority, |
28 | | - } |
| 17 | +if ENV.fetch("CI", "false").casecmp("true").zero? && ENV.fetch("OMNIAUTH_IDENTITY_ENABLE_RETHINKDB", "false").casecmp("true") != 0 |
| 18 | + RSpec.describe("NoBrainer ORM", :rethinkdb) do |
| 19 | + it("is isolated to local RethinkDB-enabled runs") do |
| 20 | + skip("NoBrainer specs require RethinkDB; set OMNIAUTH_IDENTITY_ENABLE_RETHINKDB=true to run them in CI") |
29 | 21 | end |
30 | | - NoBrainer.sync_schema |
31 | 22 | end |
| 23 | +else |
| 24 | + require "nobrainer" |
32 | 25 |
|
33 | | - before do |
34 | | - nobrainer_test_identity = Class.new do |
35 | | - include NoBrainer::Document |
| 26 | + RSpec.describe(OmniAuth::Identity::Models::NoBrainer, :rethinkdb) do |
| 27 | + before(:context) do |
| 28 | + NoBrainer.configure do |config| |
| 29 | + config.app_name = "DeezBrains" |
| 30 | + config.rethinkdb_urls = ["rethinkdb://127.0.0.1:28015/DeezBrains_test"] |
| 31 | + config.table_options = { |
| 32 | + shards: 1, |
| 33 | + replicas: 1, |
| 34 | + write_acks: :majority, |
| 35 | + } |
| 36 | + end |
| 37 | + NoBrainer.sync_schema |
| 38 | + end |
| 39 | + |
| 40 | + before do |
| 41 | + nobrainer_test_identity = Class.new do |
| 42 | + include NoBrainer::Document |
36 | 43 |
|
37 | | - include OmniAuth::Identity::Models::NoBrainer |
| 44 | + include OmniAuth::Identity::Models::NoBrainer |
38 | 45 |
|
39 | | - field :email |
40 | | - field :password_digest |
| 46 | + field :email |
| 47 | + field :password_digest |
| 48 | + end |
| 49 | + stub_const("NoBrainerTestIdentity", nobrainer_test_identity) |
| 50 | + NoBrainer.purge! |
41 | 51 | end |
42 | | - stub_const("NoBrainerTestIdentity", nobrainer_test_identity) |
43 | | - NoBrainer.purge! |
44 | | - end |
45 | 52 |
|
46 | | - describe "model", type: :model do |
47 | | - let(:model_klass) { NoBrainerTestIdentity } |
| 53 | + describe "model", type: :model do |
| 54 | + let(:model_klass) { NoBrainerTestIdentity } |
48 | 55 |
|
49 | | - include_context "with persistable model" |
| 56 | + include_context "with persistable model" |
50 | 57 |
|
51 | | - describe "::locate" do |
52 | | - it "delegates locate to the where query method" do |
53 | | - args = { |
54 | | - "email" => "open faced", |
55 | | - "category" => "sandwiches", |
56 | | - } |
57 | | - allow(model_klass).to(receive(:where).with(args).and_return(["wakka"])) |
58 | | - expect(model_klass.locate(args)).to(eq("wakka")) |
| 58 | + describe "::locate" do |
| 59 | + it "delegates locate to the where query method" do |
| 60 | + args = { |
| 61 | + "email" => "open faced", |
| 62 | + "category" => "sandwiches", |
| 63 | + } |
| 64 | + allow(model_klass).to(receive(:where).with(args).and_return(["wakka"])) |
| 65 | + expect(model_klass.locate(args)).to(eq("wakka")) |
| 66 | + end |
59 | 67 | end |
60 | 68 | end |
61 | 69 | end |
|
0 commit comments