Skip to content

Specs fail because an rspec double is leaking across tests #105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 18, 2025
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