Skip to content

Commit dbe978d

Browse files
Run memory specs separately; Fix some rubocop issues
1 parent 295102f commit dbe978d

File tree

9 files changed

+27
-25
lines changed

9 files changed

+27
-25
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
- name: Test
2121
run: bundle exec rspec
2222

23+
- name: Memory test
24+
run: bundle exec rspec --tag speed:slow
25+
2326
lint:
2427
runs-on: ubuntu-latest
2528
timeout-minutes: 5

.rspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
--format documentation
22
--color
3+
--require spec_helper

json-streamer.gemspec

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ Gem::Specification.new do |spec|
88
spec.authors = ['thisismydesign']
99
spec.email = ['thisismydesign@users.noreply.github.com']
1010

11-
spec.summary = 'Utility to support JSON streaming allowing you to get data based on various criteria (key, nesting level, etc).'
11+
spec.summary = 'Stream JSON data based on various criteria (key, nesting level, etc).'
1212
spec.homepage = 'https://github.com/thisismydesign/json-streamer'
1313
spec.license = 'MIT'
1414
spec.required_ruby_version = '>= 3.1.0'
1515

1616
spec.metadata['homepage_uri'] = spec.homepage
1717
spec.metadata['source_code_uri'] = 'https://github.com/thisismydesign/json-streamer'
18+
spec.metadata['rubygems_mfa_required'] = 'true'
1819

1920
# Specify which files should be added to the gem when it is released.
2021
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -29,9 +30,5 @@ Gem::Specification.new do |spec|
2930
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
3031
spec.require_paths = ['lib']
3132

32-
# Because of `require_relative`
33-
spec.required_ruby_version = '>= 1.9.2'
34-
3533
spec.add_dependency 'json-stream'
36-
spec.metadata['rubygems_mfa_required'] = 'true'
3734
end

lib/json/streamer/aggregator.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,19 @@ def key
2424
@aggregator.last[:key] unless @aggregator.last.nil?
2525
end
2626

27-
def key=(k)
28-
@aggregator.last[:key] = k
27+
def key=(param)
28+
@aggregator.last[:key] = param
2929
end
3030

3131
def value
3232
@aggregator.last[:value]
3333
end
3434

35-
def value=(d)
35+
def value=(param)
3636
if array_level?
37-
value << d
37+
value << param
3838
else
39-
value[key] = d
39+
value[key] = param
4040
end
4141
end
4242

spec/json/streamer/conditions_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Json::Streamer::Conditions do
64
let(:yield_level) { -1 }
75
let(:yield_key) { nil }

spec/json/streamer/json_streamer_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.shared_examples 'Json::Streamer::JsonStreamer' do
64
let(:example_key) { 'key' }
75
let(:example_value) { 'value' }

spec/json/streamer_memory_spec.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Json::Streamer do
6-
describe 'memory usage', speed: 'slow', type: 'memory' do
4+
describe 'memory usage', speed: 'slow' do
75
before do
86
GC.start
97
highlight('MEMORY USAGE TEST')

spec/json/streamer_spec.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# frozen_string_literal: true
22

3-
require 'spec_helper'
4-
53
RSpec.describe Json::Streamer do
64
describe '.parser' do
75
it 'returns Json::Streamer::JsonStreamer instance' do

spec/spec_helper.rb

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
# frozen_string_literal: true
22

3-
require 'bundler/setup'
4-
Bundler.setup
5-
63
require 'simplecov'
7-
SimpleCov.start do
8-
add_filter 'spec'
9-
end
4+
SimpleCov.start
105

116
require 'stringio'
127
require 'json'
@@ -29,3 +24,17 @@ def highlight(msg)
2924
def current_memory_usage
3025
GetProcessMem.new.mb.round
3126
end
27+
28+
RSpec.configure do |config|
29+
# Enable flags like --only-failures and --next-failure
30+
config.example_status_persistence_file_path = '.rspec_status'
31+
32+
# Disable RSpec exposing methods globally on `Module` and `main`
33+
config.disable_monkey_patching!
34+
35+
config.expect_with :rspec do |c|
36+
c.syntax = :expect
37+
end
38+
39+
config.filter_run_excluding speed: 'slow'
40+
end

0 commit comments

Comments
 (0)