Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions spec/unit/railtie_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
# TODO: Write proper specs
require "rails_helper"

RSpec.describe Graphiti::Rails::Railtie do
before do
stub_const("::Rails", rails)
Graphiti.instance_variable_set(:@config, nil)
end

after do
Graphiti.instance_variable_set(:@config, nil)
end

describe "when rails is defined with logger" do
let(:rails) do
logger = OpenStruct.new(level: 1)
Expand All @@ -11,15 +21,6 @@ def logger.debug?
double(root: Pathname.new("/foo/bar"), logger: logger)
end

before do
stub_const("::Rails", rails)
Graphiti.instance_variable_set(:@config, nil)
end

after do
Graphiti.instance_variable_set(:@config, nil)
end

describe "#schema_path" do
it "defaults" do
expect(Graphiti.config.schema_path.to_s)
Expand Down Expand Up @@ -50,11 +51,7 @@ def logger.debug?
end

context "when Rails is defined without logger" do
before do
rails = double(root: Pathname.new("/foo/bar"), logger: double.as_null_object)
stub_const("::Rails", rails)
Graphiti.instance_variable_set(:@config, nil)
end
let(:rails) { stub_const("::Rails", double(root: Pathname.new("/foo/bar"), logger: nil)) }

it "defaults" do
expect(Graphiti.config.schema_path.to_s)
Expand Down