bunny-mock 1.2.1 → 1.2.2
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/CHANGELOG.md +4 -0
 - data/bunny-mock.gemspec +1 -1
 - data/lib/bunny_mock/exchange.rb +7 -4
 - data/lib/bunny_mock/session.rb +19 -2
 - data/lib/bunny_mock/version.rb +1 -1
 - data/spec/unit/bunny_mock/session_spec.rb +63 -2
 - metadata +6 -6
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 236588fb9cea816f91284a397efdf607f564077e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 58a81920f3d8909260f4468f6f0fdab8a303c150
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d924c1e85439de0784bd9821343d6422b18a9692f829a785e4ac3a6298390c075c88371ab1a0df22db4e81648884457f8cda85df504146c2a90d652df71b8f95
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 0c66093b0771d596a9e25724685e4c1846c9886c654897d8df55ef112d837fbc4df5ba4d831ef08bc4b068eb3a8b76afc28497338de45ce4e209249c2d1a6666
         
     | 
    
        data/CHANGELOG.md
    CHANGED
    
    | 
         @@ -1,3 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## v1.2.2
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            * [#6](https://github.com/arempe93/bunny-mock/pull/6): Adds more status methods to `Session` - [@syndbg](https://github.com/syndbg)
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       1 
5 
     | 
    
         
             
            ## v1.2.1
         
     | 
| 
       2 
6 
     | 
    
         | 
| 
       3 
7 
     | 
    
         
             
            * [#5](https://github.com/arempe93/bunny-mock/pull/5): Fixes `routing_key` being modified when delivering in a topic exchange - [@austinmoore](https://github.com/austinmoore)
         
     | 
    
        data/bunny-mock.gemspec
    CHANGED
    
    | 
         @@ -18,7 +18,7 @@ Gem::Specification.new do |s| 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
              s.add_dependency 'bunny', '~> 2.0'
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              s.add_development_dependency 'rake'
         
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_development_dependency 'rake', '~> 10.5.0'
         
     | 
| 
       22 
22 
     | 
    
         
             
              s.add_development_dependency 'rubocop'
         
     | 
| 
       23 
23 
     | 
    
         
             
              s.add_development_dependency 'yard'
         
     | 
| 
       24 
24 
     | 
    
         
             
              s.add_development_dependency 'rspec', '~> 3.4.0'
         
     | 
    
        data/lib/bunny_mock/exchange.rb
    CHANGED
    
    | 
         @@ -171,6 +171,7 @@ module BunnyMock 
     | 
|
| 
       171 
171 
     | 
    
         
             
                #
         
     | 
| 
       172 
172 
     | 
    
         
             
                # @option opts [String] :routing_key Custom routing key
         
     | 
| 
       173 
173 
     | 
    
         
             
                #
         
     | 
| 
      
 174 
     | 
    
         
            +
                # @return [BunnyMock::Exchange] self
         
     | 
| 
       174 
175 
     | 
    
         
             
                # @api public
         
     | 
| 
       175 
176 
     | 
    
         
             
                #
         
     | 
| 
       176 
177 
     | 
    
         
             
                def unbind(exchange, opts = {})
         
     | 
| 
         @@ -185,6 +186,8 @@ module BunnyMock 
     | 
|
| 
       185 
186 
     | 
    
         
             
                    # we need the channel to look up the exchange
         
     | 
| 
       186 
187 
     | 
    
         
             
                    @channel.xchg_unbind opts.fetch(:routing_key, @name), exchange
         
     | 
| 
       187 
188 
     | 
    
         
             
                  end
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                  self
         
     | 
| 
       188 
191 
     | 
    
         
             
                end
         
     | 
| 
       189 
192 
     | 
    
         | 
| 
       190 
193 
     | 
    
         
             
                # @endgroup
         
     | 
| 
         @@ -240,10 +243,10 @@ module BunnyMock 
     | 
|
| 
       240 
243 
     | 
    
         
             
                ##
         
     | 
| 
       241 
244 
     | 
    
         
             
                # Deliver a message to routes
         
     | 
| 
       242 
245 
     | 
    
         
             
                #
         
     | 
| 
       243 
     | 
    
         
            -
                # @see  
     | 
| 
       244 
     | 
    
         
            -
                # @see  
     | 
| 
       245 
     | 
    
         
            -
                # @see  
     | 
| 
       246 
     | 
    
         
            -
                # @see  
     | 
| 
      
 246 
     | 
    
         
            +
                # @see BunnyMock::Exchanges::Direct#deliver
         
     | 
| 
      
 247 
     | 
    
         
            +
                # @see BunnyMock::Exchanges::Topic#deliver
         
     | 
| 
      
 248 
     | 
    
         
            +
                # @see BunnyMock::Exchanges::Fanout#deliver
         
     | 
| 
      
 249 
     | 
    
         
            +
                # @see BunnyMock::Exchanges::Headers#deliver
         
     | 
| 
       247 
250 
     | 
    
         
             
                # @api public
         
     | 
| 
       248 
251 
     | 
    
         
             
                #
         
     | 
| 
       249 
252 
     | 
    
         
             
                def deliver(payload, opts, key)
         
     | 
    
        data/lib/bunny_mock/session.rb
    CHANGED
    
    | 
         @@ -51,7 +51,6 @@ module BunnyMock 
     | 
|
| 
       51 
51 
     | 
    
         
             
                # @return [BunnyMock::Session] self
         
     | 
| 
       52 
52 
     | 
    
         
             
                # @api public
         
     | 
| 
       53 
53 
     | 
    
         
             
                def stop
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
54 
     | 
    
         
             
                  @status = :closed
         
     | 
| 
       56 
55 
     | 
    
         | 
| 
       57 
56 
     | 
    
         
             
                  self
         
     | 
| 
         @@ -64,9 +63,27 @@ module BunnyMock 
     | 
|
| 
       64 
63 
     | 
    
         
             
                # @return [Boolean] true if status is connected, false otherwise
         
     | 
| 
       65 
64 
     | 
    
         
             
                # @api public
         
     | 
| 
       66 
65 
     | 
    
         
             
                def open?
         
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
66 
     | 
    
         
             
                  @status == :connected
         
     | 
| 
       69 
67 
     | 
    
         
             
                end
         
     | 
| 
      
 68 
     | 
    
         
            +
                alias connected? open?
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                ##
         
     | 
| 
      
 71 
     | 
    
         
            +
                # Tests if connection is closed
         
     | 
| 
      
 72 
     | 
    
         
            +
                #
         
     | 
| 
      
 73 
     | 
    
         
            +
                # @return [Boolean] true if status is closed, false otherwise
         
     | 
| 
      
 74 
     | 
    
         
            +
                # @api public
         
     | 
| 
      
 75 
     | 
    
         
            +
                def closed?
         
     | 
| 
      
 76 
     | 
    
         
            +
                  @status == :closed
         
     | 
| 
      
 77 
     | 
    
         
            +
                end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                ##
         
     | 
| 
      
 80 
     | 
    
         
            +
                # Tests if connection is closing
         
     | 
| 
      
 81 
     | 
    
         
            +
                #
         
     | 
| 
      
 82 
     | 
    
         
            +
                # @return [Boolean] true if status is closing, false otherwise
         
     | 
| 
      
 83 
     | 
    
         
            +
                # @api public
         
     | 
| 
      
 84 
     | 
    
         
            +
                def closing?
         
     | 
| 
      
 85 
     | 
    
         
            +
                  @status == :closing
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
       70 
87 
     | 
    
         | 
| 
       71 
88 
     | 
    
         
             
                ##
         
     | 
| 
       72 
89 
     | 
    
         
             
                # Creates a new {BunnyMock::Channel} instance
         
     | 
    
        data/lib/bunny_mock/version.rb
    CHANGED
    
    
| 
         @@ -26,7 +26,7 @@ describe BunnyMock::Session do 
     | 
|
| 
       26 
26 
     | 
    
         
             
                end
         
     | 
| 
       27 
27 
     | 
    
         
             
              end
         
     | 
| 
       28 
28 
     | 
    
         | 
| 
       29 
     | 
    
         
            -
              context '#open?' do
         
     | 
| 
      
 29 
     | 
    
         
            +
              context '#open? (connected?)' do
         
     | 
| 
       30 
30 
     | 
    
         | 
| 
       31 
31 
     | 
    
         
             
                it 'should return true if status is open' do
         
     | 
| 
       32 
32 
     | 
    
         
             
                  @session.start
         
     | 
| 
         @@ -45,8 +45,69 @@ describe BunnyMock::Session do 
     | 
|
| 
       45 
45 
     | 
    
         
             
                end
         
     | 
| 
       46 
46 
     | 
    
         
             
              end
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
       48 
     | 
    
         
            -
               
     | 
| 
      
 48 
     | 
    
         
            +
              describe '#closed?' do
         
     | 
| 
      
 49 
     | 
    
         
            +
                context 'with `not_connected` status' do
         
     | 
| 
      
 50 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 51 
     | 
    
         
            +
                    expect(@session.closed?).to be_falsey
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                context 'with `connected` status' do
         
     | 
| 
      
 56 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 57 
     | 
    
         
            +
                    @session.start
         
     | 
| 
      
 58 
     | 
    
         
            +
                    expect(@session.closed?).to be_falsey
         
     | 
| 
      
 59 
     | 
    
         
            +
                  end
         
     | 
| 
      
 60 
     | 
    
         
            +
                end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
                context 'with `closing` status' do
         
     | 
| 
      
 63 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 64 
     | 
    
         
            +
                    # Mock `closing` status
         
     | 
| 
      
 65 
     | 
    
         
            +
                    @session.instance_variable_set('@status', :closing)
         
     | 
| 
      
 66 
     | 
    
         
            +
                    expect(@session.closed?).to be_falsey
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
       49 
69 
     | 
    
         | 
| 
      
 70 
     | 
    
         
            +
                context 'with `closed` status' do
         
     | 
| 
      
 71 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 72 
     | 
    
         
            +
                    @session.start
         
     | 
| 
      
 73 
     | 
    
         
            +
                    @session.close
         
     | 
| 
      
 74 
     | 
    
         
            +
                    expect(@session.closed?).to be_truthy
         
     | 
| 
      
 75 
     | 
    
         
            +
                  end
         
     | 
| 
      
 76 
     | 
    
         
            +
                end
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              describe '#closing?' do
         
     | 
| 
      
 80 
     | 
    
         
            +
                context 'with `not_connected` status' do
         
     | 
| 
      
 81 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 82 
     | 
    
         
            +
                    expect(@session.closing?).to be_falsey
         
     | 
| 
      
 83 
     | 
    
         
            +
                  end
         
     | 
| 
      
 84 
     | 
    
         
            +
                end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                context 'with `connected` status' do
         
     | 
| 
      
 87 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 88 
     | 
    
         
            +
                    @session.start
         
     | 
| 
      
 89 
     | 
    
         
            +
                    expect(@session.closing?).to be_falsey
         
     | 
| 
      
 90 
     | 
    
         
            +
                  end
         
     | 
| 
      
 91 
     | 
    
         
            +
                end
         
     | 
| 
      
 92 
     | 
    
         
            +
             
     | 
| 
      
 93 
     | 
    
         
            +
                context 'with `closing` status' do
         
     | 
| 
      
 94 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 95 
     | 
    
         
            +
                    # Mock `closing` status
         
     | 
| 
      
 96 
     | 
    
         
            +
                    @session.instance_variable_set('@status', :closing)
         
     | 
| 
      
 97 
     | 
    
         
            +
                    expect(@session.closing?).to be_truthy
         
     | 
| 
      
 98 
     | 
    
         
            +
                  end
         
     | 
| 
      
 99 
     | 
    
         
            +
                end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                context 'with `closed` status' do
         
     | 
| 
      
 102 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 103 
     | 
    
         
            +
                    @session.start
         
     | 
| 
      
 104 
     | 
    
         
            +
                    @session.close
         
     | 
| 
      
 105 
     | 
    
         
            +
                    expect(@session.closing?).to be_falsey
         
     | 
| 
      
 106 
     | 
    
         
            +
                  end
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              context '#create_channel (channel)' do
         
     | 
| 
       50 
111 
     | 
    
         
             
                it 'should create a new channel with no arguments' do
         
     | 
| 
       51 
112 
     | 
    
         
             
                  first = @session.create_channel
         
     | 
| 
       52 
113 
     | 
    
         
             
                  second = @session.create_channel
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: bunny-mock
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 1.2. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 1.2.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Andrew Rempe
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2016-03- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2016-03-28 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bunny
         
     | 
| 
         @@ -28,16 +28,16 @@ dependencies: 
     | 
|
| 
       28 
28 
     | 
    
         
             
              name: rake
         
     | 
| 
       29 
29 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
30 
     | 
    
         
             
                requirements:
         
     | 
| 
       31 
     | 
    
         
            -
                - - " 
     | 
| 
      
 31 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       32 
32 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version:  
     | 
| 
      
 33 
     | 
    
         
            +
                    version: 10.5.0
         
     | 
| 
       34 
34 
     | 
    
         
             
              type: :development
         
     | 
| 
       35 
35 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
36 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
37 
     | 
    
         
             
                requirements:
         
     | 
| 
       38 
     | 
    
         
            -
                - - " 
     | 
| 
      
 38 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
       39 
39 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version:  
     | 
| 
      
 40 
     | 
    
         
            +
                    version: 10.5.0
         
     | 
| 
       41 
41 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       42 
42 
     | 
    
         
             
              name: rubocop
         
     | 
| 
       43 
43 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     |