bunny-mock 1.1.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/.editorconfig +12 -0
 - data/.rubocop.yml +9 -0
 - data/.rubocop_todo.yml +65 -0
 - data/.travis.yml +6 -5
 - data/.yardopts +1 -0
 - data/CHANGELOG.md +14 -0
 - data/Gemfile +1 -11
 - data/README.md +61 -88
 - data/Rakefile +29 -0
 - data/UPGRADING.md +12 -0
 - data/bunny-mock.gemspec +19 -16
 - data/lib/bunny-mock.rb +30 -29
 - data/lib/bunny_mock/channel.rb +275 -274
 - data/lib/bunny_mock/exchange.rb +258 -267
 - data/lib/bunny_mock/exchanges/direct.rb +20 -19
 - data/lib/bunny_mock/exchanges/fanout.rb +20 -23
 - data/lib/bunny_mock/exchanges/headers.rb +27 -26
 - data/lib/bunny_mock/exchanges/topic.rb +45 -49
 - data/lib/bunny_mock/queue.rb +210 -209
 - data/lib/bunny_mock/session.rb +171 -151
 - data/lib/bunny_mock/version.rb +3 -2
 - data/spec/spec_helper.rb +1 -1
 - data/spec/unit/bunny_mock/exchange_spec.rb +10 -10
 - data/spec/unit/bunny_mock/queue_spec.rb +7 -7
 - data/spec/unit/bunny_mock/session_spec.rb +74 -48
 - metadata +86 -14
 - data/CHANGELOG +0 -8
 - data/lib/bunny_mock/exceptions.rb +0 -16
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: c674fde478dce165ef8edd3f4b5679487d1a77e9
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9b61556fb514f0f12e3be7f72efc01a0f11a820c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 06040eeb88b2446118f40a8ff9ef61d27caaa0d7173bafb6d27a8f9410b7ba9fa47e106557adb728e11d3bce8ba5d2193382944473b551fe42805cd939bcd501
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4fa7fd68ca0c53948622f0bc45ab230f9646864534a62ab896d47a87b3a0b1efc8c9faa52ea0b9d8907e81009924761fc2634101ed370c61f3a65bd47bab88e9
         
     | 
    
        data/.editorconfig
    ADDED
    
    
    
        data/.rubocop.yml
    ADDED
    
    
    
        data/.rubocop_todo.yml
    ADDED
    
    | 
         @@ -0,0 +1,65 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # This configuration was generated by
         
     | 
| 
      
 2 
     | 
    
         
            +
            # `rubocop --auto-gen-config`
         
     | 
| 
      
 3 
     | 
    
         
            +
            # on 2016-02-18 00:29:42 -0500 using RuboCop version 0.37.2.
         
     | 
| 
      
 4 
     | 
    
         
            +
            # The point is for the user to remove these configuration records
         
     | 
| 
      
 5 
     | 
    
         
            +
            # one by one as the offenses are removed from the code base.
         
     | 
| 
      
 6 
     | 
    
         
            +
            # Note that changes in the inspected code, or installation of new
         
     | 
| 
      
 7 
     | 
    
         
            +
            # versions of RuboCop, may require this file to be generated again.
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            # Offense count: 33
         
     | 
| 
      
 10 
     | 
    
         
            +
            # Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
         
     | 
| 
      
 11 
     | 
    
         
            +
            # URISchemes: http, https
         
     | 
| 
      
 12 
     | 
    
         
            +
            Metrics/LineLength:
         
     | 
| 
      
 13 
     | 
    
         
            +
              Max: 126
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            # Offense count: 7
         
     | 
| 
      
 16 
     | 
    
         
            +
            Style/Documentation:
         
     | 
| 
      
 17 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 18 
     | 
    
         
            +
                - 'spec/**/*'
         
     | 
| 
      
 19 
     | 
    
         
            +
                - 'test/**/*'
         
     | 
| 
      
 20 
     | 
    
         
            +
                - 'lib/bunny_mock/channel.rb'
         
     | 
| 
      
 21 
     | 
    
         
            +
                - 'lib/bunny_mock/exchange.rb'
         
     | 
| 
      
 22 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/direct.rb'
         
     | 
| 
      
 23 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/fanout.rb'
         
     | 
| 
      
 24 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/headers.rb'
         
     | 
| 
      
 25 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/topic.rb'
         
     | 
| 
      
 26 
     | 
    
         
            +
                - 'lib/bunny_mock/queue.rb'
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            # Offense count: 8
         
     | 
| 
      
 29 
     | 
    
         
            +
            # Cop supports --auto-correct.
         
     | 
| 
      
 30 
     | 
    
         
            +
            # Configuration parameters: EnforcedStyle, SupportedStyles.
         
     | 
| 
      
 31 
     | 
    
         
            +
            # SupportedStyles: empty_lines, no_empty_lines
         
     | 
| 
      
 32 
     | 
    
         
            +
            Style/EmptyLinesAroundClassBody:
         
     | 
| 
      
 33 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 34 
     | 
    
         
            +
                - 'lib/bunny_mock/channel.rb'
         
     | 
| 
      
 35 
     | 
    
         
            +
                - 'lib/bunny_mock/exchange.rb'
         
     | 
| 
      
 36 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/direct.rb'
         
     | 
| 
      
 37 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/fanout.rb'
         
     | 
| 
      
 38 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/headers.rb'
         
     | 
| 
      
 39 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/topic.rb'
         
     | 
| 
      
 40 
     | 
    
         
            +
                - 'lib/bunny_mock/queue.rb'
         
     | 
| 
      
 41 
     | 
    
         
            +
                - 'lib/bunny_mock/session.rb'
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            # Offense count: 36
         
     | 
| 
      
 44 
     | 
    
         
            +
            # Cop supports --auto-correct.
         
     | 
| 
      
 45 
     | 
    
         
            +
            Style/EmptyLinesAroundMethodBody:
         
     | 
| 
      
 46 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 47 
     | 
    
         
            +
                - 'lib/bunny-mock.rb'
         
     | 
| 
      
 48 
     | 
    
         
            +
                - 'lib/bunny_mock/channel.rb'
         
     | 
| 
      
 49 
     | 
    
         
            +
                - 'lib/bunny_mock/exchange.rb'
         
     | 
| 
      
 50 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/direct.rb'
         
     | 
| 
      
 51 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/fanout.rb'
         
     | 
| 
      
 52 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/headers.rb'
         
     | 
| 
      
 53 
     | 
    
         
            +
                - 'lib/bunny_mock/exchanges/topic.rb'
         
     | 
| 
      
 54 
     | 
    
         
            +
                - 'lib/bunny_mock/queue.rb'
         
     | 
| 
      
 55 
     | 
    
         
            +
                - 'lib/bunny_mock/session.rb'
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            # Offense count: 3
         
     | 
| 
      
 58 
     | 
    
         
            +
            # Cop supports --auto-correct.
         
     | 
| 
      
 59 
     | 
    
         
            +
            # Configuration parameters: EnforcedStyle, SupportedStyles.
         
     | 
| 
      
 60 
     | 
    
         
            +
            # SupportedStyles: empty_lines, no_empty_lines
         
     | 
| 
      
 61 
     | 
    
         
            +
            Style/EmptyLinesAroundModuleBody:
         
     | 
| 
      
 62 
     | 
    
         
            +
              Exclude:
         
     | 
| 
      
 63 
     | 
    
         
            +
                - 'lib/bunny-mock.rb'
         
     | 
| 
      
 64 
     | 
    
         
            +
                - 'lib/bunny_mock/exceptions.rb'
         
     | 
| 
      
 65 
     | 
    
         
            +
                - 'lib/bunny_mock/version.rb'
         
     | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/.yardopts
    CHANGED
    
    
    
        data/CHANGELOG.md
    ADDED
    
    | 
         @@ -0,0 +1,14 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## v1.2.0
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * Adds `with_channel` functionality to `BunnyMock::Session`
         
     | 
| 
      
 4 
     | 
    
         
            +
            * Renames `BunnyMock::Exchange#has_binding?` to `BunnyMock::Exchange#routes_to?`
         
     | 
| 
      
 5 
     | 
    
         
            +
            * Adds `Bunny` as a dependency to use its exceptions
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            ## v1.1.0
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            * Moves queue and exchange storage to `BunnyMock::Session`
         
     | 
| 
      
 10 
     | 
    
         
            +
            * Adds `queue_exists?` and `exchange_exists?` methods to `BunnyMock::Session`
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            ## v1.0.0
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            First stable release!
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -10,70 +10,43 @@ A mock client for RabbitMQ, modeled after the popular [Bunny client](https://git 
     | 
|
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
            ## Usage
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
            BunnyMock can be injected into your RabbitMQ application in place of Bunny for testing.  
     | 
| 
      
 13 
     | 
    
         
            +
            BunnyMock can be injected into your RabbitMQ application in place of Bunny for testing. For example, if you have a helper module named `AMQFactory`, some code similar to the following placed in `spec_helper` or `test_helper` or what have you is all you need to start using BunnyMock to test your RabbitMQ application
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
            ```ruby
         
     | 
| 
       16 
     | 
    
         
            -
            require 'bunny'
         
     | 
| 
      
 16 
     | 
    
         
            +
            require 'bunny-mock'
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
            		mattr_accessor :connection
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
                    ####################################################
         
     | 
| 
       25 
     | 
    
         
            -
                    #   Connection Management
         
     | 
| 
       26 
     | 
    
         
            -
                    ####################################################
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                    def self.connect
         
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
                        # create bunny rmq client
         
     | 
| 
       31 
     | 
    
         
            -
                        @connection = Bunny.new Global.amqp.to_hash
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                        # make connection
         
     | 
| 
       34 
     | 
    
         
            -
                        @connection.start
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                        # return connection
         
     | 
| 
       37 
     | 
    
         
            -
                        @connection
         
     | 
| 
       38 
     | 
    
         
            -
                    end
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
            		def self.get_channel
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                        # make connection if not connected
         
     | 
| 
       43 
     | 
    
         
            -
                        connect unless defined?(@connection) and @connection.open?
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                        # get channel
         
     | 
| 
       46 
     | 
    
         
            -
                        @connection.channel
         
     | 
| 
       47 
     | 
    
         
            -
                    end
         
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
            		...
         
     | 
| 
       50 
     | 
    
         
            -
            	end
         
     | 
| 
      
 18 
     | 
    
         
            +
            RSpec.configure do |config|
         
     | 
| 
      
 19 
     | 
    
         
            +
              config.before(:each) do
         
     | 
| 
      
 20 
     | 
    
         
            +
                AMQFactory.connection = BunnyMock.new.start
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
       51 
22 
     | 
    
         
             
            end
         
     | 
| 
       52 
23 
     | 
    
         
             
            ```
         
     | 
| 
       53 
24 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
      
 25 
     | 
    
         
            +
            For an example, easy to mock setup, check out [this helper](https://gist.github.com/arempe93/8143edb17c57666e738f)
         
     | 
| 
       55 
26 
     | 
    
         | 
| 
       56 
27 
     | 
    
         
             
            ## Examples
         
     | 
| 
       57 
28 
     | 
    
         | 
| 
      
 29 
     | 
    
         
            +
            Here are some examples showcasing what BunnyMock can do
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       58 
31 
     | 
    
         
             
            #### Declaration
         
     | 
| 
       59 
32 
     | 
    
         | 
| 
       60 
33 
     | 
    
         
             
            ```ruby
         
     | 
| 
       61 
34 
     | 
    
         
             
            it 'should create queues and exchanges' do
         
     | 
| 
       62 
35 
     | 
    
         | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
              session = BunnyMock.new.start
         
     | 
| 
      
 37 
     | 
    
         
            +
              channel = session.channel
         
     | 
| 
       65 
38 
     | 
    
         | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
              queue = channel.queue 'queue.test'
         
     | 
| 
      
 40 
     | 
    
         
            +
              expect(session.queue_exists?('queue.test')).to be_truthy
         
     | 
| 
       68 
41 
     | 
    
         | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
              queue.delete
         
     | 
| 
      
 43 
     | 
    
         
            +
              expect(session.queue_exists?('queue.test')).to be_falsey
         
     | 
| 
       71 
44 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
      
 45 
     | 
    
         
            +
              xchg = channel.exchange 'xchg.test'
         
     | 
| 
      
 46 
     | 
    
         
            +
              expect(session.exchange_exists?('exchange.test')).to be_truthy
         
     | 
| 
       74 
47 
     | 
    
         | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
      
 48 
     | 
    
         
            +
              xchg.delete
         
     | 
| 
      
 49 
     | 
    
         
            +
              expect(session.exchange_exists?('exchange.test')).to be_falsey
         
     | 
| 
       77 
50 
     | 
    
         
             
            end
         
     | 
| 
       78 
51 
     | 
    
         
             
            ```
         
     | 
| 
       79 
52 
     | 
    
         | 
| 
         @@ -82,31 +55,31 @@ end 
     | 
|
| 
       82 
55 
     | 
    
         
             
            ```ruby
         
     | 
| 
       83 
56 
     | 
    
         
             
            it 'should publish messages to queues' do
         
     | 
| 
       84 
57 
     | 
    
         | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
              channel = BunnyMock.new.start.channel
         
     | 
| 
      
 59 
     | 
    
         
            +
              queue = channel.queue 'queue.test'
         
     | 
| 
       87 
60 
     | 
    
         | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
      
 61 
     | 
    
         
            +
              queue.publish 'Testing message', priority: 5
         
     | 
| 
       89 
62 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
      
 63 
     | 
    
         
            +
              expect(queue.message_count).to eq(1)
         
     | 
| 
       91 
64 
     | 
    
         | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
      
 65 
     | 
    
         
            +
              payload = queue.pop
         
     | 
| 
      
 66 
     | 
    
         
            +
              expect(queue.message_count).to eq(0)
         
     | 
| 
       94 
67 
     | 
    
         | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
              expect(payload[:message]).to eq('Testing message')
         
     | 
| 
      
 69 
     | 
    
         
            +
              expect(payload[:options][:priority]).to eq(5)
         
     | 
| 
       97 
70 
     | 
    
         
             
            end
         
     | 
| 
       98 
71 
     | 
    
         | 
| 
       99 
72 
     | 
    
         
             
            it 'should route messages from exchanges' do
         
     | 
| 
       100 
73 
     | 
    
         | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
      
 74 
     | 
    
         
            +
              channel = BunnyMock.new.start.channel
         
     | 
| 
       102 
75 
     | 
    
         | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
      
 76 
     | 
    
         
            +
              xchg = channel.topic 'xchg.topic'
         
     | 
| 
      
 77 
     | 
    
         
            +
              queue = channel.queue 'queue.test'
         
     | 
| 
       105 
78 
     | 
    
         | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
      
 79 
     | 
    
         
            +
              xchg.publish 'Routed message', routing_key: '*.test'
         
     | 
| 
       107 
80 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
      
 81 
     | 
    
         
            +
              expect(queue.message_count).to eq(1)
         
     | 
| 
      
 82 
     | 
    
         
            +
              expect(queue.pop[:message]).to eq('Routed message')
         
     | 
| 
       110 
83 
     | 
    
         
             
            end
         
     | 
| 
       111 
84 
     | 
    
         
             
            ```
         
     | 
| 
       112 
85 
     | 
    
         | 
| 
         @@ -115,48 +88,48 @@ end 
     | 
|
| 
       115 
88 
     | 
    
         
             
            ```ruby
         
     | 
| 
       116 
89 
     | 
    
         
             
            it 'should bind queues to exchanges' do
         
     | 
| 
       117 
90 
     | 
    
         | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
      
 91 
     | 
    
         
            +
              channel = BunnyMock.new.start.channel
         
     | 
| 
       119 
92 
     | 
    
         | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
      
 93 
     | 
    
         
            +
              queue = channel.queue 'queue.test'
         
     | 
| 
      
 94 
     | 
    
         
            +
              xchg = channel.exchange 'xchg.test'
         
     | 
| 
       122 
95 
     | 
    
         | 
| 
       123 
     | 
    
         
            -
             
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
      
 96 
     | 
    
         
            +
              queue.bind xchg
         
     | 
| 
      
 97 
     | 
    
         
            +
              expect(queue.bound_to?(xchg)).to be_truthy
         
     | 
| 
      
 98 
     | 
    
         
            +
              expect(xchg.routes_to?(queue)).to be_truthy
         
     | 
| 
       126 
99 
     | 
    
         | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
      
 100 
     | 
    
         
            +
              queue.unbind xchg
         
     | 
| 
      
 101 
     | 
    
         
            +
              expect(queue.bound_to?(xchg)).to be_falsey
         
     | 
| 
      
 102 
     | 
    
         
            +
              expect(xchg.routes_to?(queue)).to be_falsey
         
     | 
| 
       130 
103 
     | 
    
         | 
| 
       131 
     | 
    
         
            -
             
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
      
 104 
     | 
    
         
            +
              queue.bind 'xchg.test'
         
     | 
| 
      
 105 
     | 
    
         
            +
              expect(queue.bound_to?(xchg)).to be_truthy
         
     | 
| 
      
 106 
     | 
    
         
            +
              expect(xchg.routes_to?(queue)).to be_truthy
         
     | 
| 
       134 
107 
     | 
    
         
             
            end
         
     | 
| 
       135 
108 
     | 
    
         | 
| 
       136 
109 
     | 
    
         
             
            it 'should bind exchanges to exchanges' do
         
     | 
| 
       137 
110 
     | 
    
         | 
| 
       138 
     | 
    
         
            -
             
     | 
| 
      
 111 
     | 
    
         
            +
              channel = BunnyMock.new.start.channel
         
     | 
| 
       139 
112 
     | 
    
         | 
| 
       140 
     | 
    
         
            -
             
     | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
      
 113 
     | 
    
         
            +
              source = channel.exchange 'xchg.source'
         
     | 
| 
      
 114 
     | 
    
         
            +
              receiver = channel.exchange 'xchg.receiver'
         
     | 
| 
       142 
115 
     | 
    
         | 
| 
       143 
     | 
    
         
            -
             
     | 
| 
       144 
     | 
    
         
            -
             
     | 
| 
       145 
     | 
    
         
            -
             
     | 
| 
      
 116 
     | 
    
         
            +
              receiver.bind source
         
     | 
| 
      
 117 
     | 
    
         
            +
              expect(receiver.bound_to?(source)).to be_truthy
         
     | 
| 
      
 118 
     | 
    
         
            +
              expect(source.routes_to?(receiver)).to be_truthy
         
     | 
| 
       146 
119 
     | 
    
         | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
       149 
     | 
    
         
            -
             
     | 
| 
      
 120 
     | 
    
         
            +
              receiver.unbind source
         
     | 
| 
      
 121 
     | 
    
         
            +
              expect(receiver.bound_to?(source)).to be_falsey
         
     | 
| 
      
 122 
     | 
    
         
            +
              expect(xchg.routes_to?(receiver)).to be_falsey
         
     | 
| 
       150 
123 
     | 
    
         | 
| 
       151 
     | 
    
         
            -
             
     | 
| 
       152 
     | 
    
         
            -
             
     | 
| 
       153 
     | 
    
         
            -
             
     | 
| 
      
 124 
     | 
    
         
            +
              receiver.bind 'xchg.source'
         
     | 
| 
      
 125 
     | 
    
         
            +
              expect(receiver.bound_to?(source)).to be_truthy
         
     | 
| 
      
 126 
     | 
    
         
            +
              expect(source.routes_to?(receiver)).to be_truthy
         
     | 
| 
       154 
127 
     | 
    
         
             
            end
         
     | 
| 
       155 
128 
     | 
    
         
             
            ```
         
     | 
| 
       156 
129 
     | 
    
         | 
| 
       157 
130 
     | 
    
         
             
            ## Installation
         
     | 
| 
       158 
131 
     | 
    
         | 
| 
       159 
     | 
    
         
            -
             
     | 
| 
      
 132 
     | 
    
         
            +
            #### With RubyGems
         
     | 
| 
       160 
133 
     | 
    
         | 
| 
       161 
134 
     | 
    
         
             
            To install BunnyMock with RubyGems:
         
     | 
| 
       162 
135 
     | 
    
         | 
| 
         @@ -164,7 +137,7 @@ To install BunnyMock with RubyGems: 
     | 
|
| 
       164 
137 
     | 
    
         
             
            gem install bunny-mock
         
     | 
| 
       165 
138 
     | 
    
         
             
            ```
         
     | 
| 
       166 
139 
     | 
    
         | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
      
 140 
     | 
    
         
            +
            #### With Bundler
         
     | 
| 
       168 
141 
     | 
    
         | 
| 
       169 
142 
     | 
    
         
             
            To use BunnyMock with a Bundler managed project:
         
     | 
| 
       170 
143 
     | 
    
         | 
| 
         @@ -178,9 +151,9 @@ View the documentation on [RubyDoc](http://www.rubydoc.info/github/arempe93/bunn 
     | 
|
| 
       178 
151 
     | 
    
         | 
| 
       179 
152 
     | 
    
         
             
            ## Dependencies
         
     | 
| 
       180 
153 
     | 
    
         | 
| 
       181 
     | 
    
         
            -
            *  
     | 
| 
      
 154 
     | 
    
         
            +
            * [Bunny](https://github.com/ruby-amqp/bunny) - To use original exception classes
         
     | 
| 
       182 
155 
     | 
    
         | 
| 
       183 
     | 
    
         
            -
            *  
     | 
| 
      
 156 
     | 
    
         
            +
            * Ruby version >= 2.0 (A requirement of Bunny)
         
     | 
| 
       184 
157 
     | 
    
         | 
| 
       185 
158 
     | 
    
         
             
            ## License
         
     | 
| 
       186 
159 
     | 
    
         | 
    
        data/Rakefile
    ADDED
    
    | 
         @@ -0,0 +1,29 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'bundler'
         
     | 
| 
      
 3 
     | 
    
         
            +
            Bundler.setup :default, :test, :development
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Bundler::GemHelper.install_tasks
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            require 'rspec/core/rake_task'
         
     | 
| 
      
 8 
     | 
    
         
            +
            RSpec::Core::RakeTask.new(:spec) do |spec|
         
     | 
| 
      
 9 
     | 
    
         
            +
              spec.pattern = 'spec/**/*_spec.rb'
         
     | 
| 
      
 10 
     | 
    
         
            +
            end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            RSpec::Core::RakeTask.new(:rcov) do |spec|
         
     | 
| 
      
 13 
     | 
    
         
            +
              spec.pattern = 'spec/**/*_spec.rb'
         
     | 
| 
      
 14 
     | 
    
         
            +
              spec.rcov = true
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            task :spec
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            require 'rubocop/rake_task'
         
     | 
| 
      
 20 
     | 
    
         
            +
            RuboCop::RakeTask.new
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
            task default: [:rubocop, :spec]
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            require 'yard'
         
     | 
| 
      
 25 
     | 
    
         
            +
            DOC_FILES = ['lib/**/*.rb', 'README.md']
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
            YARD::Rake::YardocTask.new(:doc) do |t|
         
     | 
| 
      
 28 
     | 
    
         
            +
              t.files = DOC_FILES
         
     | 
| 
      
 29 
     | 
    
         
            +
            end
         
     | 
    
        data/UPGRADING.md
    ADDED
    
    | 
         @@ -0,0 +1,12 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            Upgrading BunnyMock
         
     | 
| 
      
 2 
     | 
    
         
            +
            ===================
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            ## Upgrading to >= 1.2.0
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            #### Changes `has_binding?` to `routes_to?` in `BunnyMock::Exchange`
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            The `has_binding?` helper has been name changed to `routes_to?`. For now, an alias exists for `has_binding?`, but this may be deprecated in version 2.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            #### Changes to use `Bunny` exceptions, instead of custom
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
            Now all exceptions thrown will be the original `Bunny` exceptions
         
     | 
    
        data/bunny-mock.gemspec
    CHANGED
    
    | 
         @@ -5,23 +5,26 @@ require 'base64' 
     | 
|
| 
       5 
5 
     | 
    
         
             
            require File.expand_path("../lib/bunny_mock/version", __FILE__)
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            Gem::Specification.new do |s|
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
              s.name        = 'bunny-mock'
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.version     = BunnyMock::VERSION.dup
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.platform    = Gem::Platform::RUBY
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.authors     = ['Andrew Rempe']
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.email       = [Base64.decode64('YW5kcmV3cmVtcGVAZ21haWwuY29t\n')]
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.summary     = 'Mocking for the popular Bunny client for RabbitMQ'
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.description = 'Easy to use mocking for testing the Bunny client for RabbitMQ'
         
     | 
| 
      
 15 
     | 
    
         
            +
              s.license     = 'MIT'
         
     | 
| 
       14 
16 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
            	s.email =  [ Base64.encode64('YW5kcmV3cmVtcGVAZ21haWwuY29t\n') ]
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.required_ruby_version = Gem::Requirement.new '>= 2.0'
         
     | 
| 
       17 
18 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
            	s.add_dependency 'amq-protocol', '>= 2.0.1'
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.add_dependency 'bunny', '~> 2.0'
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_development_dependency 'rake'
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.add_development_dependency 'rubocop'
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.add_development_dependency 'yard'
         
     | 
| 
      
 24 
     | 
    
         
            +
              s.add_development_dependency 'rspec', '~> 3.4.0'
         
     | 
| 
      
 25 
     | 
    
         
            +
              s.add_development_dependency 'coveralls'
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              s.files         = `git ls-files`.split "\n"
         
     | 
| 
      
 28 
     | 
    
         
            +
              s.test_files    = `git ls-files -- spec/*`.split "\n"
         
     | 
| 
      
 29 
     | 
    
         
            +
              s.require_paths = [ 'lib' ]
         
     | 
| 
       27 
30 
     | 
    
         
             
            end
         
     |