Skip to content
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

Support Psych v4.0.0 #288

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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
18 changes: 16 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,29 @@ branches:
gemfile:
- gemfiles/rails52.gemfile
- gemfiles/rails60.gemfile
- gemfiles/rails6.gemfile
- gemfiles/rails61.gemfile
- gemfiles/rails70.gemfile
jobs:
allow_failures:
- rvm: ruby-head
- gemfile: gemfiles/rails6.gemfile
- rvm: '3.1'
gemfile: gemfiles/rails52.gemfile
- rvm: '3.1'
gemfile: gemfiles/rails60.gemfile
- rvm: ruby-head
gemfile: gemfiles/rails52.gemfile
- rvm: ruby-head
gemfile: gemfiles/rails60.gemfile
- rvm: "2.5"
gemfile: gemfiles/rails70.gemfile
- rvm: "2.6"
gemfile: gemfiles/rails70.gemfile
language: ruby
rvm:
- "2.5"
- "2.6"
- "2.7"
- "3.0"
- "3.1"
- ruby-head
script: bundle exec rspec
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gemspec

gem "rails", ">= 5.2.0", "< 6.1"
gem "rails", ">= 5.2.0", "< 7.1"

group :test do
gem "aruba", "~> 1.0"
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails6.gemfile → gemfiles/rails61.gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source "https://rubygems.org"

gemspec path: ".."

gem "rails", "~> 6.0"
gem "rails", "~> 6.1.0"

group :test do
gem "aruba", "~> 1.0"
Expand Down
11 changes: 11 additions & 0 deletions gemfiles/rails70.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source "https://rubygems.org"

gemspec path: ".."

gem "rails", "~> 7.0.0"

group :test do
gem "aruba", "~> 1.0"
gem "rspec", "~> 3.9"
gem "sqlite3"
end
5 changes: 4 additions & 1 deletion lib/figaro/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,10 @@ def raw_configuration
end

def parse(path)
File.exist?(path) && YAML.load(ERB.new(File.read(path)).result) || {}
return {} unless File.exist?(path)

payload = ERB.new(File.read(path)).result
(YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(payload) : YAML.load(payload)) || {}
end

def global_configuration
Expand Down
11 changes: 11 additions & 0 deletions spec/figaro/application_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,17 @@ def yaml_to_path(yaml)
expect(application.configuration).to eq("foo" => "bar")
end

it "loads alias from YAML" do
application = Application.new(path: yaml_to_path(<<-YAML), environment: "development")
default: &defaults
foo: bar
development:
<<: *defaults
YAML

expect(application.configuration).to eq("foo" => "bar")
end

it "merges environment-specific values" do
application = Application.new(path: yaml_to_path(<<-YAML), environment: "test")
foo: bar
Expand Down
9 changes: 8 additions & 1 deletion spec/rails_spec.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
describe Figaro::Rails do
before do
rails_spec = Bundler.locked_gems.specs.find { |spec| spec.name == 'rails' }
skip_asset_pipeline_option = if rails_spec.version >= '7.0.0'
'--skip-asset-pipeline'
else
'--skip-sprockets'
end

run_command_and_stop(<<-CMD)
rails new example \
--skip-gemfile \
--skip-git \
--skip-keeps \
--skip-sprockets \
#{skip_asset_pipeline_option} \
--skip-spring \
--skip-listen \
--skip-javascript \
Expand Down