bunny_testing 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 60e8602f66b0845aa8be4028270c5a5009fc42e05ff30af953ccdc9899f90ccd
4
+ data.tar.gz: 3728b516991faddb236b53b9a6f0ece3562c26bbfab81e667a466e404034a0c4
5
+ SHA512:
6
+ metadata.gz: aea6972b819d3a9c22abd34f5e4ba9f6b80c1758a1e45b73779b04724d403877f1b28749df09821b9d99e5f8ac25f89310e0e22b16c6554819f098a2e1eb5b9e
7
+ data.tar.gz: afa5c97ef27594b7fce23a8bb090fa6e0e24c713821cd3ebbaef29a9bd53626537c2e129a745492a7f6df21ae5782c720693a6ede479207a5a9802ea4e8236e0
@@ -0,0 +1,16 @@
1
+ Gemfile.lock
2
+ .rspec
3
+ .ruby-version
4
+ *.gem
5
+
6
+ /.bundle/
7
+ /.yardoc
8
+ /_yardoc/
9
+ /coverage/
10
+ /doc/
11
+ /pkg/
12
+ /spec/reports/
13
+ /tmp/
14
+
15
+ # rspec failure tracking
16
+ .rspec_status
@@ -0,0 +1,15 @@
1
+ FROM ruby:alpine
2
+
3
+ RUN apk add --no-cache build-base git
4
+
5
+ WORKDIR /bunny_testing
6
+
7
+ COPY lib/bunny/testing/version.rb lib/bunny/testing/version.rb
8
+ COPY bunny_testing.gemspec .
9
+ COPY Gemfile* ./
10
+
11
+ RUN bundle install --retry=3
12
+
13
+ COPY . .
14
+
15
+ CMD rake spec
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bunny_testing.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ gem "rspec", "~> 3.0"
8
+ gem "standard"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Vitaly Shlyaga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,33 @@
1
+ # Bunny::Testing
2
+
3
+ ![Run Specs](https://github.com/storkvist/bunny_testing/workflows/Run%20Specs/badge.svg)
4
+
5
+ TODO: Write description here
6
+
7
+ ## Installation
8
+
9
+ Adding gem to your project:
10
+
11
+ ```ruby
12
+ group :test do
13
+ gem 'bunny_testing'
14
+ end
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/storkvist/bunny_testing.
30
+
31
+ ## License
32
+
33
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require "standard/rake"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: ["standard:fix", :spec]
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bunny_testing"
5
+
6
+ require "irb"
7
+ IRB.start(__FILE__)
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail
4
+ IFS=$'\n\t'
5
+ set -vx
6
+
7
+ bundle install
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ docker-compose run bunny_testing rake spec
@@ -0,0 +1,27 @@
1
+ require_relative "lib/bunny/testing/version"
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "bunny_testing"
5
+ spec.version = Bunny::Testing::VERSION
6
+ spec.authors = ["Vitaly Shlyaga"]
7
+ spec.email = ["vitaly@shlyaga.ru"]
8
+
9
+ spec.summary = "Use bunny gem in your tests without running RabbitMQ"
10
+ # spec.description = %q{TODO: Write a longer description or delete this line.}
11
+ spec.homepage = "https://github.com/storkvist/bunny_testing"
12
+ spec.license = "MIT"
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
14
+
15
+ spec.metadata["homepage_uri"] = spec.homepage
16
+ spec.metadata["source_code_uri"] = spec.homepage
17
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
18
+
19
+ spec.add_runtime_dependency "bunny", "~> 2.0"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(\.github|test|spec|features)/}) }
25
+ end
26
+ spec.require_paths = ["lib"]
27
+ end
@@ -0,0 +1,7 @@
1
+ version: '3'
2
+
3
+ services:
4
+ bunny_testing:
5
+ build: .
6
+ volumes:
7
+ - .:/bunny_testing
@@ -0,0 +1,88 @@
1
+ require "bunny/testing/version"
2
+
3
+ require "bunny"
4
+ require "singleton"
5
+
6
+ module Bunny
7
+ class Testing
8
+ include Singleton
9
+
10
+ attr_reader :exchanges
11
+
12
+ class << self
13
+ def exchanges
14
+ instance.exchanges
15
+ end
16
+
17
+ def queue(exchange:, routing_key: nil)
18
+ instance.queue(exchange: exchange, routing_key: routing_key)
19
+ end
20
+
21
+ def reset_queue!
22
+ instance.reset_queue!
23
+ end
24
+ end
25
+
26
+ def initialize
27
+ reset_queue!
28
+ end
29
+
30
+ def queue(exchange:, routing_key: nil)
31
+ messages = exchanges[exchange]
32
+
33
+ return messages.find_all { |message| message[:routing_key] == routing_key } unless routing_key.nil?
34
+
35
+ messages
36
+ end
37
+
38
+ def reset_queue!
39
+ @exchanges = Hash.new { |hash, key| hash[key] = [] }
40
+ end
41
+ end
42
+
43
+ class Session
44
+ def connected?
45
+ true
46
+ end
47
+
48
+ def open?
49
+ true
50
+ end
51
+
52
+ def next_channel_id
53
+ @bunny_testing_channel_id = (@bunny_testing_channel_id || 0) + 1
54
+ end
55
+
56
+ def start
57
+ self
58
+ end
59
+ end
60
+
61
+ class Exchange
62
+ def declare!
63
+ true
64
+ end
65
+ end
66
+
67
+ class Channel
68
+ def basic_publish(payload, exchange, routing_key, opts = {})
69
+ Bunny::Testing.exchanges[exchange] << {payload: payload, routing_key: routing_key, opts: opts}
70
+ end
71
+
72
+ def open
73
+ @status = :open
74
+
75
+ self
76
+ end
77
+
78
+ def register_exchange(exchange)
79
+ Bunny::Testing.exchanges[exchange.name] = []
80
+ end
81
+ end
82
+
83
+ class Queue
84
+ def declare!
85
+ @name
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,5 @@
1
+ module Bunny
2
+ class Testing
3
+ VERSION = "0.2.0"
4
+ end
5
+ end
@@ -0,0 +1 @@
1
+ require "bunny/testing"
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bunny_testing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Vitaly Shlyaga
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bunny
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ description:
28
+ email:
29
+ - vitaly@shlyaga.ru
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Dockerfile
36
+ - Gemfile
37
+ - LICENSE.txt
38
+ - README.md
39
+ - Rakefile
40
+ - bin/console
41
+ - bin/setup
42
+ - bin/specs
43
+ - bunny_testing.gemspec
44
+ - docker-compose.yml
45
+ - lib/bunny/testing.rb
46
+ - lib/bunny/testing/version.rb
47
+ - lib/bunny_testing.rb
48
+ homepage: https://github.com/storkvist/bunny_testing
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ homepage_uri: https://github.com/storkvist/bunny_testing
53
+ source_code_uri: https://github.com/storkvist/bunny_testing
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 2.4.0
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ requirements: []
69
+ rubygems_version: 3.1.2
70
+ signing_key:
71
+ specification_version: 4
72
+ summary: Use bunny gem in your tests without running RabbitMQ
73
+ test_files: []