summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorBobby McDonald <BobbyMcWho@users.noreply.github.com>2019-10-02 10:48:19 -0400
committerDaniel Doubrovkine (dB.) @dblockdotorg <dblock@dblock.org>2019-10-02 10:48:19 -0400
commitca3604516b5725b30a290482c219ca55fca5de49 (patch)
treed8c190ab769cba11a430c5c4b92162547f305fde /spec
parent04cd30af1362574a1adea53aae0008e5732ea994 (diff)
downloadhashie-ca3604516b5725b30a290482c219ca55fca5de49.tar.gz
Make Hashie play nice with Rails 6 Hash#except method (#479)
Diffstat (limited to 'spec')
-rw-r--r--spec/integration/elasticsearch/Gemfile2
-rw-r--r--spec/integration/elasticsearch/integration_spec.rb2
-rw-r--r--spec/integration/rails/Gemfile2
-rw-r--r--spec/integration/rails/app.rb17
-rw-r--r--spec/integration/rails/integration_spec.rb18
5 files changed, 26 insertions, 15 deletions
diff --git a/spec/integration/elasticsearch/Gemfile b/spec/integration/elasticsearch/Gemfile
index 318242a..15dc04f 100644
--- a/spec/integration/elasticsearch/Gemfile
+++ b/spec/integration/elasticsearch/Gemfile
@@ -1,6 +1,6 @@
source 'http://rubygems.org'
-gem 'elasticsearch-model'
+gem 'elasticsearch-model', '~> 7.0'
gem 'hashie', path: '../../..'
gem 'rake'
gem 'rspec', '~> 3.5.0'
diff --git a/spec/integration/elasticsearch/integration_spec.rb b/spec/integration/elasticsearch/integration_spec.rb
index 2c4e220..70689fb 100644
--- a/spec/integration/elasticsearch/integration_spec.rb
+++ b/spec/integration/elasticsearch/integration_spec.rb
@@ -23,7 +23,7 @@ RSpec.describe 'elaasticsearch-model' do
object = MyModel.new
stub_elasticsearch_client
- expect { object.__elasticsearch__.index_document }.to raise_error(NoMethodError)
+ expect { object.__elasticsearch__.index_document }.to raise_error(NameError)
end
it 'does not raise an error when the model has an id' do
diff --git a/spec/integration/rails/Gemfile b/spec/integration/rails/Gemfile
index 32e1749..da94f2f 100644
--- a/spec/integration/rails/Gemfile
+++ b/spec/integration/rails/Gemfile
@@ -1,6 +1,6 @@
source 'http://rubygems.org'
gem 'hashie', path: '../../..'
-gem 'rails', '~> 5.0.1'
+gem 'rails', '~> 6.0.0'
gem 'rspec', '~> 3.5.0'
gem 'rspec-rails'
diff --git a/spec/integration/rails/app.rb b/spec/integration/rails/app.rb
index dee7fe1..1065688 100644
--- a/spec/integration/rails/app.rb
+++ b/spec/integration/rails/app.rb
@@ -14,7 +14,7 @@ module RailsApp
end
end
-LAYOUT = <<-HTML.freeze
+PAGE = <<-HTML.freeze
<!DOCTYPE html>
<html>
<head>
@@ -22,24 +22,17 @@ LAYOUT = <<-HTML.freeze
<%= csrf_meta_tags %>
</head>
<body>
-<%= yield %>
+ <h1>Hello, world!</h1>
</body>
</html>
HTML
-INDEX = '<h1>Hello, world!</h1>'.freeze
-
class ApplicationController < ActionController::Base
include Rails.application.routes.url_helpers
- layout 'application'
-
- self.view_paths = [ActionView::FixtureResolver.new(
- 'layouts/application.html.erb' => LAYOUT,
- 'application/index.html.erb' => INDEX
- )]
-
- def index; end
+ def index
+ render inline: PAGE
+ end
end
Bundler.require(:default, Rails.env)
diff --git a/spec/integration/rails/integration_spec.rb b/spec/integration/rails/integration_spec.rb
index 9b150a2..dc1d670 100644
--- a/spec/integration/rails/integration_spec.rb
+++ b/spec/integration/rails/integration_spec.rb
@@ -19,6 +19,24 @@ RSpec.describe 'rails', type: :request 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
+
it 'works' do
get '/'
assert_select 'h1', 'Hello, world!'