3 ms·
I will share a concrete example where I've recently run into this problem. In order to make use of OpenStruct, `require 'ostruct'` first needs to be declared.
by Umofomia 1y ago
I will share a concrete example where I've recently run into this problem.
In order to make use of OpenStruct, `require 'ostruct'` first needs to be declared. Our code neglected to make that declaration, and we saw failures when it was deployed. This code, however, passed all of our tests. We discovered it was because our testing framework included rspec-expectations, which has a dependency on diff-lcs[1], and diff-lcs itself declares `require 'ostruct'`[2]. Because of this, ostruct was loaded globally before our code was tested, which silently masked the underlying issue.
This being said, I do understand the sentiment that this feature seems superfluous and may introduce unnecessary complication, especially from a Rubyist's point of view. The underlying mental model of Ruby dependency management is different from many other languages, and it's something to keep in mind when coming from other languages that do have scope for declared dependencies.
[1] https://github.com/rspec/rspec-expectations/blob/v3.13.3/rspec-expectations.gemspec#L45 https://github.com/rspec/rspec-expectations/blob/v3.13.3/rsp...
[2] https://github.com/halostatue/diff-lcs/blob/v1.5.1/lib/diff/lcs/ldiff.rb#L4 https://github.com/halostatue/diff-lcs/blob/v1.5.1/lib/diff/...
- halostatue 1y ago`diff-lcs` no longer uses `ostruct` as of 1.6.0 (granted, that was released in February).
- quesera 1y agoDoes that mean you develop code without running it locally? The first execution of new code is in CI?
- viraptor 1y agoThey didn't say where it was deployed. I'd often only test some changes in staging rather than locally, because they rely on some specific other service I don't want to spend time setting up. It's very common.
- deleted 1y ago[deleted]
- ljm 1y agoLocally you’d have all the dependencies installed. In production you’d leave out development and test dependencies.
- deleted 1y ago[deleted]
- deleted 1y ago[deleted]
- lukeasrodgers 1y agoTypically with rails applications, test dependencies are not used for local development (i.e. running the rails server on your local machine), they are separate groups in the Gemfile.
- ljm 1y agoSpring and bootsnap muddy the waters. You do not have hermetic dev and test environments in Rails.
- mjbamford 1y agoVery helpful example.