Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

- [BUGFIX: example](https://github.com/fastruby/next_rails/pull/<number>)

- [FEATURE: Add `NextRails.current?` as the inverse of `NextRails.next?`](https://github.com/fastruby/next_rails/pull/174)

* Your changes/patches go here.

# v1.4.8 / 2026-03-23 [(commits)](https://github.com/fastruby/next_rails/compare/v1.4.7...v1.4.8)
Expand Down
8 changes: 8 additions & 0 deletions lib/next_rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def self.next?
@@next_bundle_gemfile = File.exist?(ENV["BUNDLE_GEMFILE"]) && File.basename(ENV["BUNDLE_GEMFILE"]) == "Gemfile.next"
end

# This method is the inverse of `NextRails.next?`. It returns true when your
# application is running with the current set of dependencies.
#
# @return [Boolean]
def self.current?
!next?
end

# This method will reset the @@next_bundle_gemfile variable. Then next time
# you call `NextRails.next?` it will check the environment once again.
def self.reset_next_bundle_gemfile
Expand Down
33 changes: 33 additions & 0 deletions spec/next_rails_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,37 @@
end
end

describe "NextRails.current?" do
context "when BUNDLE_GEMFILE is not set" do
it "returns true" do
NextRails.reset_next_bundle_gemfile
expect(NextRails.current?).to be_truthy
end
end

context "when BUNDLE_GEMFILE is set" do
context "when it is set to Gemfile.next" do
it "returns false" do
FileUtils.touch("Gemfile.next")
NextRails.reset_next_bundle_gemfile

with_env("BUNDLE_GEMFILE" => "Gemfile.next")
expect(NextRails.current?).to be_falsey
end
end

context "when it is set to something else" do
it "returns true" do
FileUtils.touch("Gemfile4")
NextRails.reset_next_bundle_gemfile

with_env("BUNDLE_GEMFILE" => "Gemfile4")
expect(NextRails.current?).to be_truthy

FileUtils.rm("Gemfile4")
end
end
end
end

end
Loading