diff options
author | Abe Flansburg <abeflansburg@gmail.com> | 2022-12-06 08:58:15 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-06 09:58:15 -0500 |
commit | 6fabbfd31af5952f363a8dc573bfa2059e41371d (patch) | |
tree | 43d5d1e4acda708d6607f51d35858d38714ab69d | |
parent | ccee824b27f5faa956472bc2c0903e875e5c95e5 (diff) | |
download | hashie-6fabbfd31af5952f363a8dc573bfa2059e41371d.tar.gz |
new integration spec for rails 7 exhibiting failure when executing de… (#569)
-rw-r--r-- | CHANGELOG.md | 3 | ||||
-rw-r--r-- | spec/integration/rails_7/.rspec | 3 | ||||
-rw-r--r-- | spec/integration/rails_7/Gemfile | 6 | ||||
-rw-r--r-- | spec/integration/rails_7/app.rb | 40 | ||||
-rw-r--r-- | spec/integration/rails_7/integration_spec.rb | 64 |
5 files changed, 115 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index bc57ada..5067120 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,12 +12,13 @@ Any violations of this scheme are considered to be bugs. ### Added +* [#569](https://github.com/hashie/hashie/pull/569): Added support for Rails 7 - [@aflansburg](https://github.com/aflansburg). * Your contribution here. ### Changed -* Your contribution here. * [#558](https://github.com/hashie/hashie/pull/558): Test with Ruby 3.1 - [@petergoldstein](https://github.com/petergoldstein). +* Your contribution here. ### Deprecated diff --git a/spec/integration/rails_7/.rspec b/spec/integration/rails_7/.rspec new file mode 100644 index 0000000..a4c51e7 --- /dev/null +++ b/spec/integration/rails_7/.rspec @@ -0,0 +1,3 @@ +--colour +--format=documentation +--pattern=*_spec.rb diff --git a/spec/integration/rails_7/Gemfile b/spec/integration/rails_7/Gemfile new file mode 100644 index 0000000..1b6d630 --- /dev/null +++ b/spec/integration/rails_7/Gemfile @@ -0,0 +1,6 @@ +source 'http://rubygems.org' + +gem 'hashie', path: '../../..' +gem 'rails', '~> 7.0.0' +gem 'rspec', '~> 3.5.0' +gem 'rspec-rails' diff --git a/spec/integration/rails_7/app.rb b/spec/integration/rails_7/app.rb new file mode 100644 index 0000000..1065688 --- /dev/null +++ b/spec/integration/rails_7/app.rb @@ -0,0 +1,40 @@ +require 'action_controller/railtie' +require 'action_view/railtie' +require 'action_view/testing/resolvers' +require 'rails/test_unit/railtie' + +module RailsApp + class Application < ::Rails::Application + config.eager_load = false + config.secret_key_base = 'hashieintegrationtest' + + routes.append do + get '/' => 'application#index' + end + end +end + +PAGE = <<-HTML.freeze +<!DOCTYPE html> +<html> +<head> + <title>TestApp</title> + <%= csrf_meta_tags %> +</head> +<body> + <h1>Hello, world!</h1> +</body> +</html> +HTML + +class ApplicationController < ActionController::Base + include Rails.application.routes.url_helpers + + def index + render inline: PAGE + end +end + +Bundler.require(:default, Rails.env) + +RailsApp::Application.initialize! diff --git a/spec/integration/rails_7/integration_spec.rb b/spec/integration/rails_7/integration_spec.rb new file mode 100644 index 0000000..0e69880 --- /dev/null +++ b/spec/integration/rails_7/integration_spec.rb @@ -0,0 +1,64 @@ +ENV['RAILS_ENV'] = 'test' + +require 'rspec/core' + +RSpec.describe 'rails', type: :request do + let(:stdout) { StringIO.new } + + around(:each) do |example| + original_stdout = $stdout + $stdout = stdout + require_relative 'app' + require 'rspec/rails' + example.run + $stdout = original_stdout + end + + it 'does not log anything to STDOUT when initializing' do + expect(stdout.string).to eq('') + end + + it 'sets the Hashie logger to the Rails logger' do + expect(Hashie.logger).to eq(Rails.logger) + end + + context '#except' do + subject { Hashie::Mash.new(x: 1, y: 2) } + + it 'returns an instance of the class it was called on' do + class HashieKlass < Hashie::Mash; end + hashie_klass = HashieKlass.new(subject) + expect(hashie_klass.except('x')).to be_a HashieKlass + end + + it 'works with string keys' do + expect(subject.except('x')).to eq Hashie::Mash.new(y: 2) + end + + it 'works with symbol keys' do + expect(subject.except(:x)).to eq Hashie::Mash.new(y: 2) + end + end + + context '#deep_transform_keys' do + let(:klass) do + Class.new(Hashie::Dash) do + property :foo_bar + property :foo_baz, required: true + end + end + + subject(:hash) { klass.new(foo_bar: 'bar', foo_baz: 'baz') } + + it 'sucessfully deep transforms keys' do + pending('https://github.com/hashie/hashie/issues/559') + transformed = hash.deep_transform_keys(&:to_s) + expect(transformed.keys).to all(be_a(String)) + end + end + + it 'works' do + get '/' + assert_select 'h1', 'Hello, world!' + end +end |