Skip to content
Open
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1
ruby-version: 3.2

- name: Upgrade Bundler
run: |
Expand All @@ -36,4 +36,4 @@ jobs:
run: chmod -R o-w /opt/hostedtoolcache/Ruby

- name: Run tests with coverage
run: COVERAGE=true bundle exec rspec --order random spec
run: COVERAGE=true bundle exec rspec --order random spec
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ group :development, :test do
gem "rspec", "~> 3.0"
gem "simplecov"
gem "standard", "~> 1.3"
gem "vcr"
gem "webmock"
end
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@ You will need to specify these values:

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.

## Testing

This project uses RSpec for testing, with VCR to record HTTP interactions.

To ensure your tests run consistently with CI, remove your local bundler cache before running tests:
```
rm -rf ~/.bundle/cache
```

If you do not clear the cache, VCR may record a 304 response from https://rubygems.org/versions,
causing bundler to use the cached rubygems index. Since CI does not have this cache, cassette
matching will fail and VCR will report unhandled HTTP requests.

To re-record all VCR cassettes (update recorded HTTP interactions), run:

```sh
rake spec:vcr_record_new
```

This will refresh all cassette files used in tests.

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/railsbump/checker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/railsbump/checker/blob/master/CODE_OF_CONDUCT.md).
Expand Down
7 changes: 7 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,10 @@ RSpec::Core::RakeTask.new(:spec)
require "standard/rake"

task default: %i[spec standard]

namespace :spec do
task :vcr_record_new do
ENV["VCR_RECORD_NEW"] = "true"
Rake::Task[:spec].invoke
end
end
9 changes: 7 additions & 2 deletions lib/rails_bump/checker/bundle_locally_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ def gemfile_content
GEMFILE

@dependencies.each do |gem_name, gem_version|
result += "gem '#{gem_name}', '#{gem_version}'\n" unless gem_name == "rails"
if gem_version.include?(",")
gem_versions = gem_version.split(", ").map { |i| "'#{i}'" }.join(", ")
result += "gem '#{gem_name}', #{gem_versions}\n" unless gem_name == "rails"
else
result += "gem '#{gem_name}', '#{gem_version}'\n" unless gem_name == "rails"
end
end

result
Expand All @@ -93,7 +98,7 @@ def try_bundle_install
FileUtils.rm_rf File.join(tmp_dir, "Gemfile")
FileUtils.rm_rf File.join(tmp_dir, "Gemfile.lock")

# Clean Bundler cache
# Remove unused gems
`bundle clean --force`

File.write(File.join(tmp_dir, "Gemfile"), gemfile_content)
Expand Down
13 changes: 12 additions & 1 deletion spec/rails_bump/checker/bundle_locally_check_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

RSpec.describe RailsBump::Checker::BundleLocallyCheck do
RSpec.describe RailsBump::Checker::BundleLocallyCheck, :vcr do
describe "#check" do
let(:deps) do
{"cronex" => ">= 0.13.0", "fugit" => "~> 1.8", "globalid" => ">= 1.0.1", "sidekiq" => ">= 6"}
Expand Down Expand Up @@ -38,6 +38,17 @@

expect(result.success?).to be_truthy
end

context "when dependencies have complex requirements" do
let(:deps) do
{"faraday-net_http" => ">= 2.0, < 3.5"}
end

it "installs dependencies without errors" do
result = @checker.check
expect(result.success?).to be_truthy
end
end
end

context "when dependencies are empty" do
Expand Down
2 changes: 1 addition & 1 deletion spec/rails_bump/checker/rails_release_check_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require "spec_helper"

RSpec.describe RailsBump::Checker::RailsReleaseCheck do
RSpec.describe RailsBump::Checker::RailsReleaseCheck, :vcr do
describe "#check" do
let(:version) { "6.1.0" }

Expand Down
16 changes: 16 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
end
end

# VCR setup
require "vcr"
VCR.configure do |c|
c.cassette_library_dir = "spec/vcr_cassettes"
c.hook_into :webmock
c.default_cassette_options = { record: ENV["VCR_RECORD_NEW"] ? :all : :once }
c.configure_rspec_metadata!
end

require "rails_bump/checker"

RSpec.configure do |config|
Expand All @@ -20,4 +29,11 @@
config.expect_with :rspec do |c|
c.syntax = :expect
end

if ENV["VCR_RECORD_NEW"]
config.before(:each) do
cache_path = File.expand_path('~/.bundler/cache')
FileUtils.rm_rf(cache_path) if Dir.exist?(cache_path)
end
end
end

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading