I'm writing a simple ruby application(basically using PORO's). I've added a Gemfile to it and I'm trying to require the pry gem(which is useful for adding breakpoints while debugging, as the application grows) via the Gemfile but I'm unable to require that gem using Bundler.setup
, things work fine with Bundler.require
.
I'm trying to avoid the use of Bundler.require
for reasons stated in this blog for instance.
In the Employee.rb file, I have the below code -
# require 'bundler'
# require 'bundler/setup'
# Bundler.setup(:default, :test, :development)
Bundler.require(:default, :development, :test)
def total_score(scores)
binding.pry #added on purpose , just to see if the app stops at this breakpoint
scores.inject(:+)
end
When I use Bundler.setup(uncommenting the lines commented above), instead of Bundler.require, I get the below error for the command rspec spec .
given from my apps root directory-
Failure/Error: expect(total_score(scores)).to eq(16)
NoMethodError:
undefined method `pry' for #<Binding:0x007fbda22b79d0>
# ./Employee.rb:9:in `total_score'
# ./spec/employee_spec.rb:5:in `block (3 levels) in <top (required)>'
Also, just one more note, as per the bundler docs, I tried even doing a require rubygems
, but even that doesn't help. Ideally, I would want to avoid using require rubygems
for reasons mentioned in this link.
How do I get my app to require the pry gem using Bundler.setup, without doing a require rubygems
alongside and also without using Bunder.require
?