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

new integration spec for rails 7 exhibiting failure when executing de… #569

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -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

Expand Down
3 changes: 3 additions & 0 deletions spec/integration/rails_7/.rspec
@@ -0,0 +1,3 @@
--colour
--format=documentation
--pattern=*_spec.rb
6 changes: 6 additions & 0 deletions 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'
40 changes: 40 additions & 0 deletions 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!
64 changes: 64 additions & 0 deletions 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