From e6d8779e09fbc2e3e684e202836857280641afbf Mon Sep 17 00:00:00 2001 From: bruce-szalwinski-he Date: Mon, 6 May 2024 10:06:17 -0500 Subject: [PATCH] exclude examples from codeclimate --- .codeclimate.yml | 1 + examples/karafka/v2.4-non-rails/.gitignore | 60 ----------- examples/karafka/v2.4-non-rails/.rspec | 1 - examples/karafka/v2.4-non-rails/Gemfile | 18 ---- examples/karafka/v2.4-non-rails/Gemfile.lock | 102 ------------------ examples/karafka/v2.4-non-rails/README.md | 37 ------- .../app/consumers/application_consumer.rb | 7 -- .../app/consumers/counters_consumer.rb | 21 ---- .../app/consumers/pong/ping_consumer.rb | 15 --- .../app/consumers/pong/pong_consumer.rb | 15 --- .../app/consumers/xml_messages_consumer.rb | 11 -- examples/karafka/v2.4-non-rails/karafka.rb | 86 --------------- .../v2.4-non-rails/lib/tasks/sender.rake | 23 ---- .../v2.4-non-rails/lib/xml_deserializer.rb | 17 --- examples/karafka/v2.4-non-rails/log/.gitkeep | 0 examples/karafka/v2.4-non-rails/rakefile.rb | 10 -- .../consumers/application_consumer_spec.rb | 5 - .../spec/consumers/counters_consumer_spec.rb | 20 ---- .../spec/consumers/pong/ping_consumer_spec.rb | 15 --- .../spec/consumers/pong/pong_consumer_spec.rb | 15 --- .../consumers/xml_messages_consumer_spec.rb | 23 ---- .../v2.4-non-rails/spec/karafka_spec.rb | 17 --- .../spec/lib/xml_deserializer_spec.rb | 28 ----- .../v2.4-non-rails/spec/spec_helper.rb | 41 ------- 24 files changed, 1 insertion(+), 587 deletions(-) delete mode 100644 examples/karafka/v2.4-non-rails/.gitignore delete mode 100644 examples/karafka/v2.4-non-rails/.rspec delete mode 100644 examples/karafka/v2.4-non-rails/Gemfile delete mode 100644 examples/karafka/v2.4-non-rails/Gemfile.lock delete mode 100644 examples/karafka/v2.4-non-rails/README.md delete mode 100644 examples/karafka/v2.4-non-rails/app/consumers/application_consumer.rb delete mode 100644 examples/karafka/v2.4-non-rails/app/consumers/counters_consumer.rb delete mode 100644 examples/karafka/v2.4-non-rails/app/consumers/pong/ping_consumer.rb delete mode 100644 examples/karafka/v2.4-non-rails/app/consumers/pong/pong_consumer.rb delete mode 100644 examples/karafka/v2.4-non-rails/app/consumers/xml_messages_consumer.rb delete mode 100644 examples/karafka/v2.4-non-rails/karafka.rb delete mode 100644 examples/karafka/v2.4-non-rails/lib/tasks/sender.rake delete mode 100644 examples/karafka/v2.4-non-rails/lib/xml_deserializer.rb delete mode 100644 examples/karafka/v2.4-non-rails/log/.gitkeep delete mode 100644 examples/karafka/v2.4-non-rails/rakefile.rb delete mode 100644 examples/karafka/v2.4-non-rails/spec/consumers/application_consumer_spec.rb delete mode 100644 examples/karafka/v2.4-non-rails/spec/consumers/counters_consumer_spec.rb delete mode 100644 examples/karafka/v2.4-non-rails/spec/consumers/pong/ping_consumer_spec.rb delete mode 100644 examples/karafka/v2.4-non-rails/spec/consumers/pong/pong_consumer_spec.rb delete mode 100644 examples/karafka/v2.4-non-rails/spec/consumers/xml_messages_consumer_spec.rb delete mode 100644 examples/karafka/v2.4-non-rails/spec/karafka_spec.rb delete mode 100644 examples/karafka/v2.4-non-rails/spec/lib/xml_deserializer_spec.rb delete mode 100644 examples/karafka/v2.4-non-rails/spec/spec_helper.rb diff --git a/.codeclimate.yml b/.codeclimate.yml index a97ee5e..cfb69b3 100644 --- a/.codeclimate.yml +++ b/.codeclimate.yml @@ -1,2 +1,3 @@ exclude_patterns: - "**/thor_ext.rb" +- "examples/" diff --git a/examples/karafka/v2.4-non-rails/.gitignore b/examples/karafka/v2.4-non-rails/.gitignore deleted file mode 100644 index 2a48bd4..0000000 --- a/examples/karafka/v2.4-non-rails/.gitignore +++ /dev/null @@ -1,60 +0,0 @@ -# Created by .ignore support plugin (hsz.mobi) -.idea -.byebug_history -.irb-history -### SublimeText template -# cache files for sublime text -*.tmlanguage.cache -*.tmPreferences.cache -*.stTheme.cache - -# workspace files are user-specific -*.sublime-workspace - -# project files should be checked into the repository, unless a significant -# proportion of contributors will probably not be using SublimeText -# *.sublime-project - -# sftp configuration file -sftp-config.json - - -### Ruby template -*.gem -*.rbc -/.config -/coverage/ -/InstalledFiles -/pkg/ -/spec/reports/ -/test/tmp/ -/test/version_tmp/ -/tmp/ -/config/*.yml -/.coditsu/local.yml - -## Specific to RubyMotion: -.dat* -.repl_history -build/ - -## Documentation cache and generated files: -/.yardoc/ -/_yardoc/ -/doc/ -/rdoc/ - -## Environment normalisation: -/.bundle/ -/vendor/bundle -/app/lib/bundler/man/ - -# for a library or gem, you might want to ignore these files since the code is -# intended to run in multiple environments; otherwise, check them in: -# Gemfile.lock -# .ruby-version -# .ruby-gemset -log/*.log - -# unless supporting rvm < 1.11.0 or doing something fancy, ignore this: -.rvmrc diff --git a/examples/karafka/v2.4-non-rails/.rspec b/examples/karafka/v2.4-non-rails/.rspec deleted file mode 100644 index c99d2e7..0000000 --- a/examples/karafka/v2.4-non-rails/.rspec +++ /dev/null @@ -1 +0,0 @@ ---require spec_helper diff --git a/examples/karafka/v2.4-non-rails/Gemfile b/examples/karafka/v2.4-non-rails/Gemfile deleted file mode 100644 index 1fc4fb6..0000000 --- a/examples/karafka/v2.4-non-rails/Gemfile +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -source 'https://rubygems.org' - -# ActiveSupport and rexml are only used for XML support -gem 'activesupport' -gem 'rake' -gem 'rexml' - -gem "aws-msk-iam-sasl-signer" -gem 'karafka' - -group :development, :test do - gem 'byebug', platform: :ruby - gem 'karafka-testing' - gem 'rspec' - gem 'simplecov' -end diff --git a/examples/karafka/v2.4-non-rails/Gemfile.lock b/examples/karafka/v2.4-non-rails/Gemfile.lock deleted file mode 100644 index 1008b7e..0000000 --- a/examples/karafka/v2.4-non-rails/Gemfile.lock +++ /dev/null @@ -1,102 +0,0 @@ -GEM - remote: https://rubygems.org/ - specs: - activesupport (7.1.3.2) - base64 - bigdecimal - concurrent-ruby (~> 1.0, >= 1.0.2) - connection_pool (>= 2.2.5) - drb - i18n (>= 1.6, < 2) - minitest (>= 5.1) - mutex_m - tzinfo (~> 2.0) - aws-eventstream (1.3.0) - aws-msk-iam-sasl-signer (0.1.0) - aws-sdk-kafka - thor - aws-partitions (1.924.0) - aws-sdk-core (3.194.1) - aws-eventstream (~> 1, >= 1.3.0) - aws-partitions (~> 1, >= 1.651.0) - aws-sigv4 (~> 1.8) - jmespath (~> 1, >= 1.6.1) - aws-sdk-kafka (1.70.0) - aws-sdk-core (~> 3, >= 3.193.0) - aws-sigv4 (~> 1.1) - aws-sigv4 (1.8.0) - aws-eventstream (~> 1, >= 1.0.2) - base64 (0.2.0) - bigdecimal (3.1.7) - byebug (11.1.3) - concurrent-ruby (1.2.3) - connection_pool (2.4.1) - diff-lcs (1.5.1) - docile (1.4.0) - drb (2.2.1) - ffi (1.16.3) - i18n (1.14.4) - concurrent-ruby (~> 1.0) - jmespath (1.6.2) - karafka (2.4.0) - karafka-core (>= 2.4.0, < 2.5.0) - waterdrop (>= 2.7.0, < 3.0.0) - zeitwerk (~> 2.3) - karafka-core (2.4.0) - karafka-rdkafka (>= 0.15.0, < 0.16.0) - karafka-rdkafka (0.15.0) - ffi (~> 1.15) - mini_portile2 (~> 2.6) - rake (> 12) - karafka-testing (2.4.2) - karafka (>= 2.4.0, < 2.5.0) - waterdrop (>= 2.7.0) - mini_portile2 (2.8.6) - minitest (5.22.3) - mutex_m (0.2.0) - rake (13.2.1) - rexml (3.2.6) - rspec (3.13.0) - rspec-core (~> 3.13.0) - rspec-expectations (~> 3.13.0) - rspec-mocks (~> 3.13.0) - rspec-core (3.13.0) - rspec-support (~> 3.13.0) - rspec-expectations (3.13.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-mocks (3.13.0) - diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.13.0) - rspec-support (3.13.1) - simplecov (0.22.0) - docile (~> 1.1) - simplecov-html (~> 0.11) - simplecov_json_formatter (~> 0.1) - simplecov-html (0.12.3) - simplecov_json_formatter (0.1.4) - thor (1.3.1) - tzinfo (2.0.6) - concurrent-ruby (~> 1.0) - waterdrop (2.7.0) - karafka-core (>= 2.4.0, < 3.0.0) - zeitwerk (~> 2.3) - zeitwerk (2.6.13) - -PLATFORMS - ruby - x86_64-linux - -DEPENDENCIES - activesupport - aws-msk-iam-sasl-signer - byebug - karafka - karafka-testing - rake - rexml - rspec - simplecov - -BUNDLED WITH - 2.5.9 diff --git a/examples/karafka/v2.4-non-rails/README.md b/examples/karafka/v2.4-non-rails/README.md deleted file mode 100644 index 760ed84..0000000 --- a/examples/karafka/v2.4-non-rails/README.md +++ /dev/null @@ -1,37 +0,0 @@ -# Karafka 2.4 non Rails example application - -This is an example application which uses: - -- [Karafka framework](https://github.com/karafka/karafka) `2.4` to receive messages from [Apache Kafka](http://kafka.apache.org/) server -- [WaterDrop gem](https://github.com/karafka/waterdrop) to send messages back to Kafka -- [Karafka-Testing](https://github.com/karafka/testing) provides RSpec helpers, to make testing of Karafka consumers much easier - -## Usage - -Please run `bundle install` to install all the dependencies. - -After that, following commands are available. You should run them in the console. - -Create all needed topics: - -``` -bundle exec karafka topics migrate -``` - -Run Karafka server to consume messages, process and send messages: - -``` -bundle exec karafka s -``` - -Generate initial messages to Kafka server by sending them using WaterDrop: - -``` -bundle exec rake waterdrop:send -``` - -You can also run RSpec specs to see how the testing RSpec library integrates with RSpec: - -``` -bundle exec rspec spec -``` diff --git a/examples/karafka/v2.4-non-rails/app/consumers/application_consumer.rb b/examples/karafka/v2.4-non-rails/app/consumers/application_consumer.rb deleted file mode 100644 index 2214b6c..0000000 --- a/examples/karafka/v2.4-non-rails/app/consumers/application_consumer.rb +++ /dev/null @@ -1,7 +0,0 @@ -# frozen_string_literal: true - -# Application consumer from which all Karafka consumers should inherit -# You can rename it if it would conflict with your current code base (in case you're integrating -# Karafka with other frameworks) -class ApplicationConsumer < Karafka::BaseConsumer -end diff --git a/examples/karafka/v2.4-non-rails/app/consumers/counters_consumer.rb b/examples/karafka/v2.4-non-rails/app/consumers/counters_consumer.rb deleted file mode 100644 index 5949c07..0000000 --- a/examples/karafka/v2.4-non-rails/app/consumers/counters_consumer.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -# This consumer receives a batch of messages at once -# You can use it to process multiple messages at the same time, for example -# for batch inserting ito database, etc -# The batch is accessible using the #messages method -class CountersConsumer < ApplicationConsumer - # Performs business logic with messages batch - def consume - # You can access the messages as an array and just work with it - sum = messages - .map { |message| message.payload['number'] } - .inject(0) { |accu, val| accu + val } - - Karafka.logger.info "Sum of #{messages.count} elements equals to: #{sum}" - - # This is not needed as automatic offset management is on, but we add it just to illustrate - # that the karafka-testing works with this case as well - mark_as_consumed!(messages.last) - end -end diff --git a/examples/karafka/v2.4-non-rails/app/consumers/pong/ping_consumer.rb b/examples/karafka/v2.4-non-rails/app/consumers/pong/ping_consumer.rb deleted file mode 100644 index 0bde490..0000000 --- a/examples/karafka/v2.4-non-rails/app/consumers/pong/ping_consumer.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -# Namespace for everything related to our small ping-pong game -module Pong - # Catches the ping and uses producer to respond on a pong topic - class PingConsumer < ApplicationConsumer - # We increase the ball hits and respond - def consume - hits = messages.last.payload['hits'] + 1 - # The initial ping needs to be triggered via the rake task - Karafka.logger.info "Ping consumer with hits: #{hits}" - producer.produce_async(topic: 'pong', payload: { hits: hits }.to_json) - end - end -end diff --git a/examples/karafka/v2.4-non-rails/app/consumers/pong/pong_consumer.rb b/examples/karafka/v2.4-non-rails/app/consumers/pong/pong_consumer.rb deleted file mode 100644 index 76b962b..0000000 --- a/examples/karafka/v2.4-non-rails/app/consumers/pong/pong_consumer.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -module Pong - # Catches the pong and uses PongResponder to respond on a ping topic - class PongConsumer < ApplicationConsumer - # Increase ball hits and respond - def consume - # Just a small delay so we won't overuse the CPU - sleep rand - hits = messages.last.payload['hits'] + 1 - Karafka.logger.info "Pong consumer with hits: #{hits}" - producer.produce_async(topic: 'ping', payload: { hits: hits }.to_json) - end - end -end diff --git a/examples/karafka/v2.4-non-rails/app/consumers/xml_messages_consumer.rb b/examples/karafka/v2.4-non-rails/app/consumers/xml_messages_consumer.rb deleted file mode 100644 index e546332..0000000 --- a/examples/karafka/v2.4-non-rails/app/consumers/xml_messages_consumer.rb +++ /dev/null @@ -1,11 +0,0 @@ -# frozen_string_literal: true - -# Consumer that is meant to handle xml data -class XmlMessagesConsumer < ApplicationConsumer - # This method just logs parsed data with Karafka logger - def consume - messages.each do |message| - Karafka.logger.info "Consumed following message: #{message.payload}" - end - end -end diff --git a/examples/karafka/v2.4-non-rails/karafka.rb b/examples/karafka/v2.4-non-rails/karafka.rb deleted file mode 100644 index dec9e91..0000000 --- a/examples/karafka/v2.4-non-rails/karafka.rb +++ /dev/null @@ -1,86 +0,0 @@ -# frozen_string_literal: true - -# This is a non-Rails example app! - -ENV['KARAFKA_ENV'] ||= 'development' -Bundler.require(:default, ENV['KARAFKA_ENV']) - -# Zeitwerk custom loader for loading the app components before the whole -# Karafka framework configuration -APP_LOADER = Zeitwerk::Loader.new - -%w[ - lib - app/consumers -].each(&APP_LOADER.method(:push_dir)) - -APP_LOADER.setup -APP_LOADER.eager_load - -class OAuthTokenRefresher - def on_oauthbearer_token_refresh(event) - print "refreshing token\n" - - signer = AwsMskIamSaslSigner::MSKTokenProvider.new(region: ENV.fetch("AWS_REGION", nil)) - token = signer.generate_auth_token - if token - event[:bearer].oauthbearer_set_token( - token: token.token, - lifetime_ms: token.expiration_time_ms, - principal_name: "kafka-cluster" - ) - else - event[:bearer].oauthbearer_set_token_failure( - "Failed to generate token." - ) - end - end -end - -# App class -class App < Karafka::App - setup do |config| - config.concurrency = 5 - config.max_wait_time = 1_000 - config.kafka = { 'bootstrap.servers': ENV['KAFKA_BOOTSTRAP_SERVERS'] } - config.oauth.token_provider_listener = OAuthTokenRefresher.new - end -end - -Karafka.monitor.subscribe(Karafka::Instrumentation::LoggerListener.new) -Karafka.monitor.subscribe(Karafka::Instrumentation::ProctitleListener.new) -Karafka.producer.monitor.subscribe( - WaterDrop::Instrumentation::LoggerListener.new( - Karafka.logger, - # If you set this to true, logs will contain each message details - # Please note, that this can be extensive - log_messages: false - ) -) - -App.consumer_groups.draw do - consumer_group :batched_group do - topic :xml_data do - config(partitions: 2) - consumer XmlMessagesConsumer - deserializer XmlDeserializer.new - end - - topic :counters do - config(partitions: 1) - consumer CountersConsumer - end - - topic :ping do - # 1 day in ms - config(partitions: 5, 'retention.ms': 86_400_000) - consumer Pong::PingConsumer - end - - topic :pong do - # 1 day in ms - config(partitions: 5, 'retention.ms': 86_400_000) - consumer Pong::PongConsumer - end - end -end diff --git a/examples/karafka/v2.4-non-rails/lib/tasks/sender.rake b/examples/karafka/v2.4-non-rails/lib/tasks/sender.rake deleted file mode 100644 index 09db078..0000000 --- a/examples/karafka/v2.4-non-rails/lib/tasks/sender.rake +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -namespace :waterdrop do - desc 'Generates messages to Kafka server' - task :send do - 3.times do - message = "home-#{rand}" - Karafka.producer.produce_async(topic: 'xml_data', payload: message) - end - - 10.times do - message = { 'number' => rand }.to_json - # @note You can send messages with sync producer again - Karafka.producer.produce_async(topic: 'counters', payload: message) - end - - # Sends the initial ping to start ping-pong within Karafka - message = { 'hits' => 0 }.to_json - Karafka.producer.produce_async(topic: 'ping', payload: message) - - Karafka.producer.close - end -end diff --git a/examples/karafka/v2.4-non-rails/lib/xml_deserializer.rb b/examples/karafka/v2.4-non-rails/lib/xml_deserializer.rb deleted file mode 100644 index 0ca8895..0000000 --- a/examples/karafka/v2.4-non-rails/lib/xml_deserializer.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -require 'active_support/isolated_execution_state' -require 'active_support/core_ext/hash' -require 'active_support/xml_mini' -require 'rexml/document' - -# Xml deserializer class -class XmlDeserializer - # @param params [Karafka::Params::Params] params to de-serialize - # @return [Hash] deserialized xml - # @example: - # XmlDeserializer.new.call('n') - def call(params) - ::Hash.from_xml(params.raw_payload) - end -end diff --git a/examples/karafka/v2.4-non-rails/log/.gitkeep b/examples/karafka/v2.4-non-rails/log/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/examples/karafka/v2.4-non-rails/rakefile.rb b/examples/karafka/v2.4-non-rails/rakefile.rb deleted file mode 100644 index 546243a..0000000 --- a/examples/karafka/v2.4-non-rails/rakefile.rb +++ /dev/null @@ -1,10 +0,0 @@ -# frozen_string_literal: true - -require 'bundler' -require 'rake' -require 'rspec/core/rake_task' -require './karafka' -load './lib/tasks/sender.rake' - -RSpec::Core::RakeTask.new(:spec) -task default: :spec diff --git a/examples/karafka/v2.4-non-rails/spec/consumers/application_consumer_spec.rb b/examples/karafka/v2.4-non-rails/spec/consumers/application_consumer_spec.rb deleted file mode 100644 index 0c6031e..0000000 --- a/examples/karafka/v2.4-non-rails/spec/consumers/application_consumer_spec.rb +++ /dev/null @@ -1,5 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe ApplicationConsumer do - specify { expect(described_class).to be < Karafka::BaseConsumer } -end diff --git a/examples/karafka/v2.4-non-rails/spec/consumers/counters_consumer_spec.rb b/examples/karafka/v2.4-non-rails/spec/consumers/counters_consumer_spec.rb deleted file mode 100644 index 80a903c..0000000 --- a/examples/karafka/v2.4-non-rails/spec/consumers/counters_consumer_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe CountersConsumer do - subject(:consumer) { karafka.consumer_for(:counters) } - - let(:nr1_value) { rand } - let(:nr2_value) { rand } - let(:sum) { nr1_value + nr2_value } - - before do - karafka.produce({ 'number' => nr1_value }.to_json) - karafka.produce({ 'number' => nr2_value }.to_json, partition: 2) - allow(Karafka.logger).to receive(:info) - end - - it 'expects to log a proper message' do - expect(Karafka.logger).to receive(:info).with("Sum of 2 elements equals to: #{sum}") - consumer.consume - end -end diff --git a/examples/karafka/v2.4-non-rails/spec/consumers/pong/ping_consumer_spec.rb b/examples/karafka/v2.4-non-rails/spec/consumers/pong/ping_consumer_spec.rb deleted file mode 100644 index 8eaffd7..0000000 --- a/examples/karafka/v2.4-non-rails/spec/consumers/pong/ping_consumer_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe Pong::PingConsumer do - subject(:consumer) { karafka.consumer_for(:ping) } - - context 'when we receive a message' do - before { karafka.produce({ 'hits' => 0 }.to_json) } - - it 'expect to dispatch a pong message with counter back' do - consumer.consume - - expect(karafka.produced_messages.last[:payload]).to eq({ hits: 1 }.to_json) - end - end -end diff --git a/examples/karafka/v2.4-non-rails/spec/consumers/pong/pong_consumer_spec.rb b/examples/karafka/v2.4-non-rails/spec/consumers/pong/pong_consumer_spec.rb deleted file mode 100644 index aca31e0..0000000 --- a/examples/karafka/v2.4-non-rails/spec/consumers/pong/pong_consumer_spec.rb +++ /dev/null @@ -1,15 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe Pong::PongConsumer do - subject(:consumer) { karafka.consumer_for(:pong) } - - context 'when we receive a message' do - before { karafka.produce({ 'hits' => 1 }.to_json) } - - it 'expect to dispatch a ping message with counter back' do - consumer.consume - - expect(karafka.produced_messages.last[:payload]).to eq({ hits: 2 }.to_json) - end - end -end diff --git a/examples/karafka/v2.4-non-rails/spec/consumers/xml_messages_consumer_spec.rb b/examples/karafka/v2.4-non-rails/spec/consumers/xml_messages_consumer_spec.rb deleted file mode 100644 index d50a24e..0000000 --- a/examples/karafka/v2.4-non-rails/spec/consumers/xml_messages_consumer_spec.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe XmlMessagesConsumer do - subject(:consumer) { karafka.consumer_for(:xml_data) } - - let(:message_content) { "home-#{rand}" } - let(:payload) { consumer.messages.first.payload } - - before do - karafka.produce("#{message_content}") - allow(Karafka.logger).to receive(:info) - end - - it 'expects to log a proper message' do - expect(Karafka.logger).to receive(:info).with("Consumed following message: #{payload}") - consumer.consume - end - - it 'expects to unparse message' do - consumer.consume - expect(payload['message']['new']).to eq message_content - end -end diff --git a/examples/karafka/v2.4-non-rails/spec/karafka_spec.rb b/examples/karafka/v2.4-non-rails/spec/karafka_spec.rb deleted file mode 100644 index eadd109..0000000 --- a/examples/karafka/v2.4-non-rails/spec/karafka_spec.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe Karafka do - describe 'batched group' do - let(:group) do - described_class::App.consumer_groups.find do |cg| - cg.name == 'batched_group' - end - end - - describe 'xml_data topic' do - let(:topic) { group.topics.find('xml_data') } - - it { expect(topic.deserializers.payload).to be_a XmlDeserializer } - end - end -end diff --git a/examples/karafka/v2.4-non-rails/spec/lib/xml_deserializer_spec.rb b/examples/karafka/v2.4-non-rails/spec/lib/xml_deserializer_spec.rb deleted file mode 100644 index 4f41984..0000000 --- a/examples/karafka/v2.4-non-rails/spec/lib/xml_deserializer_spec.rb +++ /dev/null @@ -1,28 +0,0 @@ -# frozen_string_literal: true - -RSpec.describe XmlDeserializer do - subject(:deserializer) { described_class.new } - - describe '#call' do - let(:params) do - Karafka::Messages::Message.new( - message, - Karafka::Messages::Metadata.new( - deserializers: OpenStruct.new(payload: deserializer) - ) - ) - end - - context 'when message has correct xml format' do - let(:message) { 'home' } - - it { expect(params.payload).to eq('message' => { 'new' => 'home' }) } - end - - context 'when message has wrong xml format' do - let(:message) { '' } - - it { expect { params.payload }.to raise_error(REXML::ParseException) } - end - end -end diff --git a/examples/karafka/v2.4-non-rails/spec/spec_helper.rb b/examples/karafka/v2.4-non-rails/spec/spec_helper.rb deleted file mode 100644 index b2aecd8..0000000 --- a/examples/karafka/v2.4-non-rails/spec/spec_helper.rb +++ /dev/null @@ -1,41 +0,0 @@ -# frozen_string_literal: true - -$LOAD_PATH.unshift(File.dirname(__FILE__)) -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) - -ENV['KARAFKA_ENV'] ||= 'test' - -%w[ - rubygems - simplecov - rake - logger - karafka - karafka/testing/rspec/helpers -].each(&method(:require)) - -require 'byebug' unless defined?(JRUBY_VERSION) - -# Don't include unnecessary stuff into rcov -SimpleCov.start do - add_filter '/vendor/' - add_filter '/gems/' - add_filter '/.bundle/' - add_filter '/doc/' - add_filter '/spec/' - add_filter '/config/' - add_filter '/tasks' - merge_timeout 600 -end - -RSpec.configure do |config| - config.disable_monkey_patching! - config.order = :random - config.include Karafka::Testing::RSpec::Helpers - - config.expect_with :rspec do |expectations| - expectations.include_chain_clauses_in_custom_matcher_descriptions = true - end -end - -require './karafka'