rspecproxies 0.1.0 → 1.0.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/.travis.yml +2 -2
- data/DayBook.org +12 -0
- data/Dockerfile +1 -0
- data/README.md +73 -21
- data/docker-compose.yml +11 -0
- data/lib/rspecproxies.rb +1 -0
- data/lib/rspecproxies/proxies.rb +30 -61
- data/lib/rspecproxies/proxy_chains.rb +34 -0
- data/lib/rspecproxies/version.rb +1 -1
- data/rspecproxies.gemspec +1 -2
- data/spec/rspecproxies/proxies_spec.rb +34 -8
- metadata +25 -58
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- metadata.gz.sig +0 -0
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 8780bd0b36987621f35cb6060457f7d3216aca83
         | 
| 4 | 
            +
              data.tar.gz: 65c3c13a0cbc60e9ed35b69a50e64cf6261aa639
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: fd406ed228f3415dd4dd3a36273b5573175a0ef2f06c97dfc0e0bd5cb3f24cea8cfbb7fcdae21756cd694e823cd4e803a1448997c34b36fda9edd944236ae6b8
         | 
| 7 | 
            +
              data.tar.gz: 86591baa5eda35111672aa25c036e84f73f196e054ba09e2b5e1dc5cfb04ece12d9c58a8daeae0cf0d3ffbdde1e486bee372b15fb70c5cc78ad4c3e8be61d77f
         | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/DayBook.org
    ADDED
    
    | @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            * DONE update the code
         | 
| 2 | 
            +
            * DONE increase the version to 1.0.0
         | 
| 3 | 
            +
            * DONE update the Readme
         | 
| 4 | 
            +
            ** DONE new syntax (use mock-experiments)
         | 
| 5 | 
            +
            ** DONE how to do with docker*
         | 
| 6 | 
            +
            ** DONE update the links
         | 
| 7 | 
            +
            * TODO Create a github page
         | 
| 8 | 
            +
            ** DONE copy the readme into a page in my blog
         | 
| 9 | 
            +
            ** DONE move open source projects pages from navigation to an aside
         | 
| 10 | 
            +
            ** TODO check the links
         | 
| 11 | 
            +
            * TODO release and bump a new version
         | 
| 12 | 
            +
            * TODO add code snipets from mock-experiments to the google pres
         | 
    
        data/Dockerfile
    ADDED
    
    | @@ -0,0 +1 @@ | |
| 1 | 
            +
            FROM ruby:2.3
         | 
    
        data/README.md
    CHANGED
    
    | @@ -2,13 +2,26 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            # RSpecProxies
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 5 | 
            +
            Simplify [RSpec](http://rspec.info) mocking with test proxies !
         | 
| 6 6 |  | 
| 7 | 
            -
             | 
| 7 | 
            +
            ## Why ?
         | 
| 8 8 |  | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 9 | 
            +
            As you might know after the [Is TDD Dead ?](http://martinfowler.com/articles/is-tdd-dead/) debate, [Mockists are dead, long live to classicists](https://www.thoughtworks.com/insights/blog/mockists-are-dead-long-live-classisists). Heavy mocking is getting out of fashion because it makes tests unreliable and difficult to maintain.
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Test proxies mix the best of both worlds, they behave like the real objects but also provide hooks to perform assertions or to inject test code. RSpec now features minimal supports for proxies with partial mocks, spies and the ```and_call_original``` and ```and_wrap_original``` expectations. RSpecProxies goes one step further with more specific expectations. Using RSpecProxies should help you to use as little mocking as possible.
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            More specifically, RSpecProxies helps to :
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            * Simplify the setup of mocks by relying on the real objects
         | 
| 16 | 
            +
            * Write reliable tests that use the real code
         | 
| 17 | 
            +
            * Capture return values and arguments to the real calls
         | 
| 18 | 
            +
            * Setup nested proxies when needed
         | 
| 19 | 
            +
             | 
| 20 | 
            +
            RSpecProxies will not make your tests as fast as heavy mocking, but for that you can :
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            * Use in-memory databases to run your tests (such as [SQLite](http://www.sqlite.org))
         | 
| 23 | 
            +
            * Split your system in sub-systems
         | 
| 24 | 
            +
            * Write in-memory fakes of your sub-systems to use in your tests
         | 
| 12 25 |  | 
| 13 26 | 
             
            ## Installation
         | 
| 14 27 |  | 
| @@ -26,42 +39,68 @@ Or install it yourself as: | |
| 26 39 |  | 
| 27 40 | 
             
            ## Usage
         | 
| 28 41 |  | 
| 29 | 
            -
            Just as inspiration, here are a few sample usages | 
| 42 | 
            +
            RSpecProxies is used on top of RSpec's ```and_return_original``` and ```and_wrap_original``` expectations. The syntax is meant to be very similar. Just as inspiration, here are a few sample usages.
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            ### Verify caching
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            NB: this is an illustration of the built-in spy features that RSpec now provides
         | 
| 30 47 |  | 
| 31 | 
            -
             | 
| 48 | 
            +
            By definition, caching should not change the behaviour of your system. But some methods should not be called many times. This used to be a good place to use mocks. RSpec spies now helps to deal with that in an unintrusive way :
         | 
| 32 49 |  | 
| 33 50 | 
             
            ```ruby
         | 
| 34 51 | 
             
            it 'caches users' do
         | 
| 35 | 
            -
               | 
| 52 | 
            +
              allow(User).to receive(:load).and_return_original
         | 
| 36 53 |  | 
| 37 54 | 
             
              controller.login('joe', 'secret')
         | 
| 38 55 | 
             
              controller.login('joe', 'secret')
         | 
| 39 56 |  | 
| 40 | 
            -
              expect(users).to  | 
| 57 | 
            +
              expect(users).to have_received(:load).once
         | 
| 41 58 | 
             
            end
         | 
| 42 59 | 
             
            ```
         | 
| 43 60 |  | 
| 44 | 
            -
            ### Verify loaded data | 
| 61 | 
            +
            ### Verify loaded data
         | 
| 62 | 
            +
             | 
| 63 | 
            +
            Sometimes, the verifications you want to make in your test depends on the data that has been loaded. The best way to handle that is to know what data is going to be loaded, but that is not always easy or possible. An alternative is heavy mocking with will take you down the setup hell road, is often not a good choice at all. Using proxies, it is possible to win on both aspects.
         | 
| 45 64 |  | 
| 46 65 | 
             
            ```ruby
         | 
| 47 | 
            -
            it ' | 
| 48 | 
            -
               | 
| 66 | 
            +
            it 'can check that the correct data is used (using and_after_calling_original)' do
         | 
| 67 | 
            +
              user = nil
         | 
| 68 | 
            +
              allow(User).to receive(:load).and_after_calling_original { |result| user = result }
         | 
| 69 | 
            +
             | 
| 70 | 
            +
              controller.login('joe', 'secret')
         | 
| 71 | 
            +
             | 
| 72 | 
            +
              expect(response).to include(user.created_at.to_s)
         | 
| 73 | 
            +
            end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
            it 'can check that the correct data is used (using and_capture_result_into)' do
         | 
| 76 | 
            +
              allow(User).to receive(:load).and_capture_result_into(self, :user)
         | 
| 49 77 |  | 
| 50 78 | 
             
              controller.login('joe', 'secret')
         | 
| 51 79 |  | 
| 52 | 
            -
              expect(response).to include(@user. | 
| 80 | 
            +
              expect(response).to include(@user.created_at.to_s)
         | 
| 81 | 
            +
            end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
            it 'can check that the correct data is used (using and_collect_results_into)' do
         | 
| 84 | 
            +
              users = []
         | 
| 85 | 
            +
              allow(User).to receive(:load).and_collect_results_into(users)
         | 
| 86 | 
            +
             | 
| 87 | 
            +
              controller.login('joe', 'secret')
         | 
| 88 | 
            +
             | 
| 89 | 
            +
              expect(response).to include(users.first.created_at.to_s)
         | 
| 53 90 | 
             
            end
         | 
| 54 91 | 
             
            ```
         | 
| 55 92 |  | 
| 56 | 
            -
            ### Simulate unreliable network | 
| 93 | 
            +
            ### Simulate unreliable network
         | 
| 94 | 
            +
             | 
| 95 | 
            +
            In this case, you might want to fail a call from time to time, and call the original otherwise. This should not require complex mock setup.
         | 
| 57 96 |  | 
| 58 97 | 
             
            ```ruby
         | 
| 59 98 | 
             
            it 'retries on error' do
         | 
| 60 99 | 
             
               i = 0
         | 
| 61 | 
            -
               Resource. | 
| 100 | 
            +
               allow(Resource).to receive(:get).and_before_calling_original { |*args|
         | 
| 62 101 | 
             
                  i++
         | 
| 63 102 | 
             
                  raise RuntimeError.new if i % 3==0
         | 
| 64 | 
            -
                | 
| 103 | 
            +
               }
         | 
| 65 104 |  | 
| 66 105 | 
             
               resources = Resource.get_at_least(10)
         | 
| 67 106 |  | 
| @@ -69,21 +108,23 @@ it 'retries on error' do | |
| 69 108 | 
             
            end
         | 
| 70 109 | 
             
            ```
         | 
| 71 110 |  | 
| 72 | 
            -
            ###  | 
| 111 | 
            +
            ### Shortcut a long deep call
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            Sometimes, you want to mock a particular method of some particular object. RSpec provides ```receive_message_chain``` just for that, but it creates a full mock object which will fail if sent another message. You'd ratherwant this object to otherwise behave normally, that's what you get with nested proxies.
         | 
| 73 114 |  | 
| 74 115 | 
             
            ```ruby
         | 
| 75 116 | 
             
            it 'rounds the completion ratio' do
         | 
| 76 | 
            -
               RenderingTask. | 
| 117 | 
            +
               Allow(RenderingTask).to proxy_message_chain("load.completion_ratio") {|s| s.and_return(0.2523) }
         | 
| 77 118 |  | 
| 78 | 
            -
                | 
| 119 | 
            +
               controller.show
         | 
| 79 120 |  | 
| 80 121 | 
             
               expect(response).to include('25%')
         | 
| 81 122 | 
             
            end
         | 
| 82 123 | 
             
            ```
         | 
| 83 124 |  | 
| 84 | 
            -
            ###  | 
| 125 | 
            +
            ### CAUTION : {...} vs do...end
         | 
| 85 126 |  | 
| 86 | 
            -
             | 
| 127 | 
            +
            In ruby, the convention is to use {...} blocks for one liners, and do...end otherwise. Unfortunately, the two don't have the same precedence, which means that they don't exactly work the same way. RSpecProxies in particular does not support do...end out of the box. That's why all the examples above use {...}, even for multi lines blocks.
         | 
| 87 128 |  | 
| 88 129 | 
             
            ## Contributing
         | 
| 89 130 |  | 
| @@ -92,3 +133,14 @@ Combine proxies with an inmemory database (like SQLite) while testing, and you'l | |
| 92 133 | 
             
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 93 134 | 
             
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 94 135 | 
             
            5. Create new Pull Request
         | 
| 136 | 
            +
             | 
| 137 | 
            +
            ### A word on docker and docker-compose
         | 
| 138 | 
            +
             | 
| 139 | 
            +
            If you want to contribute to RSpecProxies, you can make use of the docker-compose configuration to quickly setup an isolated ruby environment. Make sure you have [docker](https://docs.docker.com/engine/installation/) and [docker-compose](https://docs.docker.com/compose/install/) installed, then type :
         | 
| 140 | 
            +
             | 
| 141 | 
            +
            ```bash
         | 
| 142 | 
            +
            docker-compose run rubybox
         | 
| 143 | 
            +
            bundle install
         | 
| 144 | 
            +
            ```
         | 
| 145 | 
            +
             | 
| 146 | 
            +
            and you should be in a brand new container, ready to hack.
         | 
    
        data/docker-compose.yml
    ADDED
    
    
    
        data/lib/rspecproxies.rb
    CHANGED
    
    
    
        data/lib/rspecproxies/proxies.rb
    CHANGED
    
    | @@ -1,73 +1,42 @@ | |
| 1 1 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
                  result = stock_response.call(*args, &block)
         | 
| 14 | 
            -
                  yield result
         | 
| 15 | 
            -
                  result
         | 
| 16 | 
            -
                end
         | 
| 17 | 
            -
              end
         | 
| 18 | 
            -
             | 
| 19 | 
            -
              # Will capture all the results of the method into the returned
         | 
| 20 | 
            -
              # array
         | 
| 21 | 
            -
              def capture_results_from(method_name)
         | 
| 22 | 
            -
                all_results = []
         | 
| 23 | 
            -
                on_result_from(method_name) {|result| all_results << result }
         | 
| 24 | 
            -
                all_results
         | 
| 25 | 
            -
              end
         | 
| 26 | 
            -
             | 
| 27 | 
            -
              # Will capture (or override) result from the target's method in
         | 
| 28 | 
            -
              # the details[:into] instance variable
         | 
| 29 | 
            -
              def capture_result_from(target, method_name, details)
         | 
| 30 | 
            -
                into = details[:into]
         | 
| 31 | 
            -
                target.on_result_from(method_name) {|result| instance_variable_set("@#{into}", result)}
         | 
| 32 | 
            -
              end
         | 
| 33 | 
            -
             | 
| 34 | 
            -
              # Will call the given block with all the actual arguments every time
         | 
| 35 | 
            -
              # the method is called
         | 
| 36 | 
            -
              def on_call_to(method_name)
         | 
| 37 | 
            -
                stock_response = self.original_response(method_name)
         | 
| 38 | 
            -
             | 
| 39 | 
            -
                allow(self).to receive(method_name) do |*args, &block|
         | 
| 40 | 
            -
                  yield *args
         | 
| 41 | 
            -
                  stock_response.call(*args, &block)
         | 
| 3 | 
            +
            module RSpecProxies
         | 
| 4 | 
            +
              module Proxies
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                # Will call the given block with all the actual arguments every time
         | 
| 7 | 
            +
                # the method is called
         | 
| 8 | 
            +
                def and_before_calling_original
         | 
| 9 | 
            +
                  self.and_wrap_original do |m, *args, &block|
         | 
| 10 | 
            +
                    yield *args
         | 
| 11 | 
            +
                    m.call(*args, &block)
         | 
| 12 | 
            +
                  end
         | 
| 42 13 | 
             
                end
         | 
| 43 14 |  | 
| 44 | 
            -
             | 
| 45 | 
            -
             | 
| 46 | 
            -
             | 
| 47 | 
            -
             | 
| 48 | 
            -
             | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
                  final_stub = allow(self).to receive(selectors.first)
         | 
| 52 | 
            -
                  block.call(final_stub) unless block.nil?
         | 
| 53 | 
            -
                else
         | 
| 54 | 
            -
                  self.on_result_from(selectors.first) do |result|
         | 
| 55 | 
            -
                    result.proxy_chain(*selectors[1..-1], &block)
         | 
| 15 | 
            +
                # Will call the given block with it's result every time the method
         | 
| 16 | 
            +
                # returns
         | 
| 17 | 
            +
                def and_after_calling_original
         | 
| 18 | 
            +
                  self.and_wrap_original do |m, *args, &block|
         | 
| 19 | 
            +
                    result = m.call(*args, &block)
         | 
| 20 | 
            +
                    yield result
         | 
| 21 | 
            +
                    result
         | 
| 56 22 | 
             
                  end
         | 
| 57 23 | 
             
                end
         | 
| 58 | 
            -
              end
         | 
| 59 24 |  | 
| 60 | 
            -
             | 
| 25 | 
            +
                # Will capture all the results of the method into the given
         | 
| 26 | 
            +
                # array
         | 
| 27 | 
            +
                def and_collect_results_into(collector)
         | 
| 28 | 
            +
                  self.and_after_calling_original { |result| collector << result }
         | 
| 29 | 
            +
                end
         | 
| 61 30 |  | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
                 | 
| 65 | 
            -
                  self. | 
| 66 | 
            -
             | 
| 67 | 
            -
                  lambda do |*args, &block|
         | 
| 68 | 
            -
                    self.send(:method_missing, method_name, *args, &block)
         | 
| 31 | 
            +
                # Will capture (or override) result from the target's method in
         | 
| 32 | 
            +
                # the specified instance variable of target
         | 
| 33 | 
            +
                def and_capture_result_into(target, instance_variable_name)
         | 
| 34 | 
            +
                  self.and_after_calling_original do |result|
         | 
| 35 | 
            +
                    target.instance_variable_set("@#{instance_variable_name}", result)
         | 
| 69 36 | 
             
                  end
         | 
| 70 37 | 
             
                end
         | 
| 71 | 
            -
              end
         | 
| 72 38 |  | 
| 39 | 
            +
              end
         | 
| 73 40 | 
             
            end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
            RSpec::Mocks::Matchers::Receive.include(RSpecProxies::Proxies)
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module RSpecProxies
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              module ProxyChains
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                # Sets up proxies all down the selector chain, until the last where
         | 
| 8 | 
            +
                # a simple method stub is created and on which the block is called.
         | 
| 9 | 
            +
                # Allows to set up stub chains quickly and safely.
         | 
| 10 | 
            +
                #
         | 
| 11 | 
            +
                # message_chain : a dot separated message chain, like the standard
         | 
| 12 | 
            +
                # message_chain expectation
         | 
| 13 | 
            +
                def proxy_message_chain(message_chain, &last_proxy_setup_block)
         | 
| 14 | 
            +
                  proxy_message_chain_a((message_chain.split('.').map &:intern), &last_proxy_setup_block)
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                # Same as #proxy_message_chain but using an array of symbols as
         | 
| 18 | 
            +
                # message_chain instead of a dot separated string
         | 
| 19 | 
            +
                def proxy_message_chain_a(messages, &last_proxy_setup_block)
         | 
| 20 | 
            +
                  first_message = messages.first
         | 
| 21 | 
            +
                  return last_proxy_setup_block.call(receive(first_message)) if messages.size == 1
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  receive(first_message).and_wrap_original do |m, *args, &original_block|
         | 
| 24 | 
            +
                    result = m.call(*args, &original_block)
         | 
| 25 | 
            +
                    allow(result).to proxy_message_chain_a(messages.drop(1), &last_proxy_setup_block)
         | 
| 26 | 
            +
                    result
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            RSpec::Core::ExampleGroup.include(RSpecProxies::ProxyChains)
         | 
    
        data/lib/rspecproxies/version.rb
    CHANGED
    
    
    
        data/rspecproxies.gemspec
    CHANGED
    
    | @@ -18,11 +18,10 @@ Gem::Specification.new do |spec| | |
| 18 18 | 
             
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 19 19 | 
             
              spec.require_paths = ["lib"]
         | 
| 20 20 |  | 
| 21 | 
            -
              spec.add_dependency "rspec", "~> 3. | 
| 21 | 
            +
              spec.add_dependency "rspec", "~> 3.5"
         | 
| 22 22 |  | 
| 23 23 | 
             
              spec.add_development_dependency "bundler"
         | 
| 24 24 | 
             
              spec.add_development_dependency "rake"
         | 
| 25 | 
            -
              spec.add_development_dependency "rake"
         | 
| 26 25 | 
             
              spec.add_development_dependency "guard-rspec"
         | 
| 27 26 | 
             
              spec.add_development_dependency "codeclimate-test-reporter"
         | 
| 28 27 | 
             
            end
         | 
| @@ -52,16 +52,24 @@ module RSpecProxies | |
| 52 52 |  | 
| 53 53 | 
             
                it 'hooks on return from a method' do
         | 
| 54 54 | 
             
                  user = nil
         | 
| 55 | 
            -
             | 
| 56 | 
            -
                  User.on_result_from(:load) {|u| user = u}
         | 
| 55 | 
            +
                  allow(User).to receive(:load).and_after_calling_original {|u| user = u}
         | 
| 57 56 |  | 
| 58 57 | 
             
                  @controller.render('Joe')
         | 
| 59 58 |  | 
| 60 59 | 
             
                  expect(user).to eq(User.new('Joe'))
         | 
| 61 60 | 
             
                end
         | 
| 62 61 |  | 
| 62 | 
            +
                it 'calls the original method with the given block when hooking on return' do
         | 
| 63 | 
            +
                  allow(Array).to receive(:new).and_after_calling_original {}
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                  array = Array.new(2) { 4 }
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  expect(array).to eq([4,4])
         | 
| 68 | 
            +
                end
         | 
| 69 | 
            +
             | 
| 63 70 | 
             
                it 'has a shortcut to collect return values from a method' do
         | 
| 64 | 
            -
                  users =  | 
| 71 | 
            +
                  users = []
         | 
| 72 | 
            +
                  allow(User).to receive(:load).and_collect_results_into(users)
         | 
| 65 73 |  | 
| 66 74 | 
             
                  @controller.render('Joe')
         | 
| 67 75 | 
             
                  @controller.render('Jim')
         | 
| @@ -70,7 +78,7 @@ module RSpecProxies | |
| 70 78 | 
             
                end
         | 
| 71 79 |  | 
| 72 80 | 
             
                it 'has a shortcut to collect the latest return value from a method' do
         | 
| 73 | 
            -
                   | 
| 81 | 
            +
                  allow(User).to receive(:load).and_capture_result_into(self, :user)
         | 
| 74 82 |  | 
| 75 83 | 
             
                  html = @controller.render('Joe')
         | 
| 76 84 |  | 
| @@ -78,20 +86,38 @@ module RSpecProxies | |
| 78 86 | 
             
                end
         | 
| 79 87 |  | 
| 80 88 | 
             
                it 'hooks on arguments before a method call' do
         | 
| 81 | 
            -
                  User. | 
| 89 | 
            +
                  allow(User).to receive(:load).and_before_calling_original { |name|
         | 
| 82 90 | 
             
                    raise RuntimeError.new if name == 'Jim'
         | 
| 83 | 
            -
                   | 
| 91 | 
            +
                  }
         | 
| 84 92 |  | 
| 85 93 | 
             
                  expect(@controller.render('Joe')).not_to be_nil
         | 
| 86 94 | 
             
                  expect{@controller.render('Jim')}.to raise_error(RuntimeError)
         | 
| 87 95 | 
             
                end
         | 
| 88 96 |  | 
| 89 | 
            -
                it  | 
| 90 | 
            -
                   | 
| 97 | 
            +
                it 'calls the original method with the given block when hooking on arguments' do
         | 
| 98 | 
            +
                  allow(Array).to receive(:new).and_before_calling_original {}
         | 
| 99 | 
            +
             | 
| 100 | 
            +
                  array = Array.new(2) { 4 }
         | 
| 101 | 
            +
             | 
| 102 | 
            +
                  expect(array).to eq([4,4])
         | 
| 103 | 
            +
                end
         | 
| 104 | 
            +
             | 
| 105 | 
            +
                it 'can setup deep stubs on yet unloaded instances' do
         | 
| 106 | 
            +
                  puts self.class.superclass
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                  allow(User).to proxy_message_chain("load.url") {|s| s.and_return('http://pirates.net')}
         | 
| 91 109 |  | 
| 92 110 | 
             
                  html = @controller.render('Jack')
         | 
| 93 111 |  | 
| 94 112 | 
             
                  expect(html).to include('http://pirates.net')
         | 
| 95 113 | 
             
                end
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                it 'calls original methods with the given block when creating deep proxies' do
         | 
| 116 | 
            +
                  allow(Array).to proxy_message_chain('new.map') { |s| s.and_call_original }
         | 
| 117 | 
            +
             | 
| 118 | 
            +
                  array = Array.new(2) { 4 }.map {|i| i+1}
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                  expect(array).to eq([5,5])
         | 
| 121 | 
            +
                end
         | 
| 96 122 | 
             
              end
         | 
| 97 123 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,120 +1,83 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: rspecproxies
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Philou
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 | 
            -
            cert_chain:
         | 
| 11 | 
            -
            -  | 
| 12 | 
            -
              -----BEGIN CERTIFICATE-----
         | 
| 13 | 
            -
              MIIDkjCCAnqgAwIBAgIBATANBgkqhkiG9w0BAQUFADBHMRkwFwYDVQQDDBBwaGls
         | 
| 14 | 
            -
              aXBwZS5ib3VyZ2F1MRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzARBgoJkiaJk/Is
         | 
| 15 | 
            -
              ZAEZFgNjb20wHhcNMTMwOTIzMTEwOTA3WhcNMTQwOTIzMTEwOTA3WjBHMRkwFwYD
         | 
| 16 | 
            -
              VQQDDBBwaGlsaXBwZS5ib3VyZ2F1MRUwEwYKCZImiZPyLGQBGRYFZ21haWwxEzAR
         | 
| 17 | 
            -
              BgoJkiaJk/IsZAEZFgNjb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
         | 
| 18 | 
            -
              AQC8CpoqZwEbzXr55EUxdSplgn0MYZ9xPGO/XmRa8bD63n+JYWF0AS+mj452ZY18
         | 
| 19 | 
            -
              rwM+yKrKhtsA+aJJdlOafgIUnY5SrZOr7v7kgc6T2YNoUj+M00Um2jv+shQbOtV6
         | 
| 20 | 
            -
              qGp0Jw1HfPNUMVa+3pXZyAGCecN6rTnsZJIuW6KNaJUq6lEMVXanoTHgAKrH5aHd
         | 
| 21 | 
            -
              Y6ofwQL86d6LDkC1S4p86iMUWvF34w8h5ItVo+JKlPRR22rzsK/ZKgNH3lfjbS6i
         | 
| 22 | 
            -
              JWqPva70rL2xz5kCVn6DL7XhNZtqnAO4kvCQyQeWezvcoGXEnbHacKky7B+/WKec
         | 
| 23 | 
            -
              OIWEwedl6j+X0OD5OYki3QaTAgMBAAGjgYgwgYUwCQYDVR0TBAIwADALBgNVHQ8E
         | 
| 24 | 
            -
              BAMCBLAwHQYDVR0OBBYEFJnLz40Onu/dfpLSipU5FgTy6WLmMCUGA1UdEQQeMByB
         | 
| 25 | 
            -
              GnBoaWxpcHBlLmJvdXJnYXVAZ21haWwuY29tMCUGA1UdEgQeMByBGnBoaWxpcHBl
         | 
| 26 | 
            -
              LmJvdXJnYXVAZ21haWwuY29tMA0GCSqGSIb3DQEBBQUAA4IBAQBGoH72KWYACGZl
         | 
| 27 | 
            -
              cMHMJ9d/DRU7rynJ8c4xuuM4c3Ri8bGPqI/a1BAp4QPJApS4+ANXXJ220hslrekP
         | 
| 28 | 
            -
              9/ExEKFiqiywh1clih9ttuN4cHqJzCP6QHqJznQrvaYToZLxGARDf3Mwz4mFSh4W
         | 
| 29 | 
            -
              snSep53DZ1vrY2Gzmig/4PuBF4q3nhwPgxV6H3SH4/Py7QF5COZPQlCdBwPYczqW
         | 
| 30 | 
            -
              XxIbXhRVXcgjBHT0w2HsXkOwmmYvBzbrfqtTx5NswwHcIeQZB/NID7berIf9awx3
         | 
| 31 | 
            -
              yLcl1cmm5ALtJ/+Bkkmp0i4amXeTDMvq9r8PBsVsQwxYOYJBP+Umxz3PX6HjFHrQ
         | 
| 32 | 
            -
              XdkXx3oZ
         | 
| 33 | 
            -
              -----END CERTIFICATE-----
         | 
| 34 | 
            -
            date: 2014-08-24 00:00:00.000000000 Z
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2016-08-22 00:00:00.000000000 Z
         | 
| 35 12 | 
             
            dependencies:
         | 
| 36 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 37 14 | 
             
              name: rspec
         | 
| 38 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 39 16 | 
             
                requirements:
         | 
| 40 | 
            -
                - - ~>
         | 
| 17 | 
            +
                - - "~>"
         | 
| 41 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 42 | 
            -
                    version: '3. | 
| 19 | 
            +
                    version: '3.5'
         | 
| 43 20 | 
             
              type: :runtime
         | 
| 44 21 | 
             
              prerelease: false
         | 
| 45 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 46 23 | 
             
                requirements:
         | 
| 47 | 
            -
                - - ~>
         | 
| 24 | 
            +
                - - "~>"
         | 
| 48 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 49 | 
            -
                    version: '3. | 
| 26 | 
            +
                    version: '3.5'
         | 
| 50 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 51 28 | 
             
              name: bundler
         | 
| 52 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 53 30 | 
             
                requirements:
         | 
| 54 | 
            -
                - -  | 
| 31 | 
            +
                - - ">="
         | 
| 55 32 | 
             
                  - !ruby/object:Gem::Version
         | 
| 56 33 | 
             
                    version: '0'
         | 
| 57 34 | 
             
              type: :development
         | 
| 58 35 | 
             
              prerelease: false
         | 
| 59 36 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 60 37 | 
             
                requirements:
         | 
| 61 | 
            -
                - -  | 
| 38 | 
            +
                - - ">="
         | 
| 62 39 | 
             
                  - !ruby/object:Gem::Version
         | 
| 63 40 | 
             
                    version: '0'
         | 
| 64 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 65 42 | 
             
              name: rake
         | 
| 66 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 67 44 | 
             
                requirements:
         | 
| 68 | 
            -
                - -  | 
| 45 | 
            +
                - - ">="
         | 
| 69 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 70 47 | 
             
                    version: '0'
         | 
| 71 48 | 
             
              type: :development
         | 
| 72 49 | 
             
              prerelease: false
         | 
| 73 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 74 51 | 
             
                requirements:
         | 
| 75 | 
            -
                - -  | 
| 76 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 77 | 
            -
                    version: '0'
         | 
| 78 | 
            -
            - !ruby/object:Gem::Dependency
         | 
| 79 | 
            -
              name: rake
         | 
| 80 | 
            -
              requirement: !ruby/object:Gem::Requirement
         | 
| 81 | 
            -
                requirements:
         | 
| 82 | 
            -
                - - '>='
         | 
| 83 | 
            -
                  - !ruby/object:Gem::Version
         | 
| 84 | 
            -
                    version: '0'
         | 
| 85 | 
            -
              type: :development
         | 
| 86 | 
            -
              prerelease: false
         | 
| 87 | 
            -
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 88 | 
            -
                requirements:
         | 
| 89 | 
            -
                - - '>='
         | 
| 52 | 
            +
                - - ">="
         | 
| 90 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 91 54 | 
             
                    version: '0'
         | 
| 92 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 93 56 | 
             
              name: guard-rspec
         | 
| 94 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 95 58 | 
             
                requirements:
         | 
| 96 | 
            -
                - -  | 
| 59 | 
            +
                - - ">="
         | 
| 97 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 98 61 | 
             
                    version: '0'
         | 
| 99 62 | 
             
              type: :development
         | 
| 100 63 | 
             
              prerelease: false
         | 
| 101 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 102 65 | 
             
                requirements:
         | 
| 103 | 
            -
                - -  | 
| 66 | 
            +
                - - ">="
         | 
| 104 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 105 68 | 
             
                    version: '0'
         | 
| 106 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 107 70 | 
             
              name: codeclimate-test-reporter
         | 
| 108 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 109 72 | 
             
                requirements:
         | 
| 110 | 
            -
                - -  | 
| 73 | 
            +
                - - ">="
         | 
| 111 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 112 75 | 
             
                    version: '0'
         | 
| 113 76 | 
             
              type: :development
         | 
| 114 77 | 
             
              prerelease: false
         | 
| 115 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 116 79 | 
             
                requirements:
         | 
| 117 | 
            -
                - -  | 
| 80 | 
            +
                - - ">="
         | 
| 118 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 119 82 | 
             
                    version: '0'
         | 
| 120 83 | 
             
            description: Proxy doubles for RSpec
         | 
| @@ -124,16 +87,20 @@ executables: [] | |
| 124 87 | 
             
            extensions: []
         | 
| 125 88 | 
             
            extra_rdoc_files: []
         | 
| 126 89 | 
             
            files:
         | 
| 127 | 
            -
            - .gitignore
         | 
| 128 | 
            -
            - .rspec
         | 
| 129 | 
            -
            - .travis.yml
         | 
| 90 | 
            +
            - ".gitignore"
         | 
| 91 | 
            +
            - ".rspec"
         | 
| 92 | 
            +
            - ".travis.yml"
         | 
| 93 | 
            +
            - DayBook.org
         | 
| 94 | 
            +
            - Dockerfile
         | 
| 130 95 | 
             
            - Gemfile
         | 
| 131 96 | 
             
            - Guardfile
         | 
| 132 97 | 
             
            - LICENSE.txt
         | 
| 133 98 | 
             
            - README.md
         | 
| 134 99 | 
             
            - Rakefile
         | 
| 100 | 
            +
            - docker-compose.yml
         | 
| 135 101 | 
             
            - lib/rspecproxies.rb
         | 
| 136 102 | 
             
            - lib/rspecproxies/proxies.rb
         | 
| 103 | 
            +
            - lib/rspecproxies/proxy_chains.rb
         | 
| 137 104 | 
             
            - lib/rspecproxies/version.rb
         | 
| 138 105 | 
             
            - rspecproxies.gemspec
         | 
| 139 106 | 
             
            - spec/rspecproxies/proxies_spec.rb
         | 
| @@ -148,17 +115,17 @@ require_paths: | |
| 148 115 | 
             
            - lib
         | 
| 149 116 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 150 117 | 
             
              requirements:
         | 
| 151 | 
            -
              - -  | 
| 118 | 
            +
              - - ">="
         | 
| 152 119 | 
             
                - !ruby/object:Gem::Version
         | 
| 153 120 | 
             
                  version: '0'
         | 
| 154 121 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 155 122 | 
             
              requirements:
         | 
| 156 | 
            -
              - -  | 
| 123 | 
            +
              - - ">="
         | 
| 157 124 | 
             
                - !ruby/object:Gem::Version
         | 
| 158 125 | 
             
                  version: '0'
         | 
| 159 126 | 
             
            requirements: []
         | 
| 160 127 | 
             
            rubyforge_project: 
         | 
| 161 | 
            -
            rubygems_version: 2. | 
| 128 | 
            +
            rubygems_version: 2.6.4
         | 
| 162 129 | 
             
            signing_key: 
         | 
| 163 130 | 
             
            specification_version: 4
         | 
| 164 131 | 
             
            summary: Special RSpec extensions to simplify mocking by providing proxies
         | 
    
        checksums.yaml.gz.sig
    DELETED
    
    | Binary file | 
    
        data.tar.gz.sig
    DELETED
    
    | Binary file | 
    
        metadata.gz.sig
    DELETED
    
    | Binary file |