/
integration_spec.rb
64 lines (51 loc) · 1.54 KB
/
integration_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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 'successfully 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