slayer 0.4.0.beta2 → 0.4.0.beta3
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/.githooks/pre-push +8 -1
- data/.gitignore +5 -2
- data/.rspec +3 -0
- data/.rubocop.yml +12 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +9 -0
- data/Dockerfile +16 -0
- data/README.md +45 -4
- data/Rakefile +13 -6
- data/bin/console +1 -1
- data/bin/helpers/docker +12 -0
- data/bin/rubo_fix +6 -0
- data/bin/run_tests +19 -0
- data/bin/setup +1 -1
- data/bin/ssh_to_container +3 -0
- data/docker-compose.yml +19 -0
- data/docker/start.sh +7 -0
- data/lib/slayer/command.rb +8 -5
- data/lib/slayer/minitest.rb +66 -0
- data/lib/slayer/rspec.rb +46 -10
- data/lib/slayer/service.rb +42 -4
- data/lib/slayer/version.rb +1 -1
- data/slayer.gemspec +4 -2
- metadata +48 -10
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: bc1abc0497cd05cba5c5a1aecbd39cafe49f6fa9
         | 
| 4 | 
            +
              data.tar.gz: 8678738d7df065faa235dd87fae989fc5d13ec0a
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2f0eac2da4477755087461d3604032a0c144f02816b9d6a35d490b58dbdd533fb4c29423439ae0872343a3175c6317617fdbdb94d43827a44d5f998d0bd41cf4
         | 
| 7 | 
            +
              data.tar.gz: 749f72cead7773c2a66d134649dadd0b4b924f495c51e6b46b7a32ef7964f7741990afa1b594f6a0da368b51a29fd4fe705a43f36060865d83b1a41f5e14abad
         | 
    
        data/.githooks/pre-push
    CHANGED
    
    | @@ -1,7 +1,14 @@ | |
| 1 1 | 
             
            #!/usr/bin/env bash
         | 
| 2 2 |  | 
| 3 | 
            +
            if [[ $DOCKER_CONTAINER -ne 1 ]]; then
         | 
| 4 | 
            +
                if [[ $(docker-compose ps -q | wc -l) -gt 0 ]]; then
         | 
| 5 | 
            +
                    source bin/helpers/docker
         | 
| 6 | 
            +
                    runOnDocker ruby
         | 
| 7 | 
            +
                fi
         | 
| 8 | 
            +
            fi
         | 
| 9 | 
            +
             | 
| 3 10 | 
             
            echo "Starting unit tests"
         | 
| 4 | 
            -
            bundle exec rake  | 
| 11 | 
            +
            bundle exec rake spec
         | 
| 5 12 | 
             
            if [ $? -ne 0 ]; then
         | 
| 6 13 | 
             
                echo ""
         | 
| 7 14 | 
             
                echo ""
         | 
    
        data/.gitignore
    CHANGED
    
    
    
        data/.rspec
    ADDED
    
    
    
        data/.rubocop.yml
    CHANGED
    
    | @@ -5,8 +5,12 @@ AllCops: | |
| 5 5 | 
             
              Include:
         | 
| 6 6 | 
             
                - 'lib/**/*.rb'
         | 
| 7 7 | 
             
                - 'test/**/*.rb'
         | 
| 8 | 
            +
                - 'spec/**/*.rb'
         | 
| 9 | 
            +
                - '**/Gemfile'
         | 
| 10 | 
            +
                - '**/Rakefile'
         | 
| 8 11 | 
             
              Exclude:
         | 
| 9 12 | 
             
                - 'bin/**/*'
         | 
| 13 | 
            +
                - 'test/fixtures/**/*.rb'
         | 
| 10 14 |  | 
| 11 15 |  | 
| 12 16 | 
             
            Style/RedundantSelf:
         | 
| @@ -21,19 +25,19 @@ Style/GuardClause: | |
| 21 25 | 
             
            Style/ClassAndModuleChildren:
         | 
| 22 26 | 
             
              Enabled: false
         | 
| 23 27 |  | 
| 24 | 
            -
             | 
| 28 | 
            +
            Layout/EmptyLinesAroundClassBody:
         | 
| 25 29 | 
             
              Enabled: false
         | 
| 26 30 |  | 
| 27 31 | 
             
            Style/FrozenStringLiteralComment:
         | 
| 28 32 | 
             
              Enabled: false
         | 
| 29 33 |  | 
| 30 | 
            -
             | 
| 34 | 
            +
            Layout/CommentIndentation:
         | 
| 31 35 | 
             
              Enabled: false
         | 
| 32 36 |  | 
| 33 37 | 
             
            Style/BracesAroundHashParameters:
         | 
| 34 38 | 
             
              Enabled: false
         | 
| 35 39 |  | 
| 36 | 
            -
             | 
| 40 | 
            +
            Layout/IndentationConsistency:
         | 
| 37 41 | 
             
              EnforcedStyle: rails
         | 
| 38 42 |  | 
| 39 43 | 
             
            Metrics/LineLength:
         | 
| @@ -42,9 +46,13 @@ Metrics/LineLength: | |
| 42 46 | 
             
            Metrics/ClassLength:
         | 
| 43 47 | 
             
              Max: 120
         | 
| 44 48 |  | 
| 45 | 
            -
             | 
| 49 | 
            +
            Layout/EmptyLineBetweenDefs:
         | 
| 46 50 | 
             
              AllowAdjacentOneLineDefs: true
         | 
| 47 51 |  | 
| 52 | 
            +
            Naming/UncommunicativeMethodParamName:
         | 
| 53 | 
            +
              AllowedNames:
         | 
| 54 | 
            +
                - _
         | 
| 55 | 
            +
             | 
| 48 56 | 
             
            # Temporarily disabled until this can be resolved in the todo file
         | 
| 49 57 | 
             
            # Style/Documentation:
         | 
| 50 58 | 
             
            #   Exclude:
         | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/CHANGELOG.md
    ADDED
    
    | @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            # Changelog
         | 
| 2 | 
            +
            All notable changes to this project will be documented in this file.
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
         | 
| 5 | 
            +
            and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## [Unreleased]
         | 
| 8 | 
            +
            ### Added
         | 
| 9 | 
            +
            - Added documentation for CHANGELOG to README
         | 
    
        data/Dockerfile
    ADDED
    
    
    
        data/README.md
    CHANGED
    
    | @@ -238,7 +238,7 @@ To use with RSpec, update your `spec_helper.rb` file to include: | |
| 238 238 |  | 
| 239 239 | 
             
            `require 'slayer/rspec'`
         | 
| 240 240 |  | 
| 241 | 
            -
            This provides you with two new matchers: `be_successful_result` and `be_failed_result`, both of which can be chained with a `with_status`  | 
| 241 | 
            +
            This provides you with two new matchers: `be_successful_result` and `be_failed_result`, both of which can be chained with a `with_status`, `with_message`, or `with_value` expectations:
         | 
| 242 242 |  | 
| 243 243 | 
             
            ```ruby
         | 
| 244 244 | 
             
            RSpec.describe RSpecCommand do
         | 
| @@ -248,15 +248,19 @@ RSpec.describe RSpecCommand do | |
| 248 248 |  | 
| 249 249 | 
             
                  it { is_expected.to be_success_result }
         | 
| 250 250 | 
             
                  it { is_expected.not_to be_failed_result }
         | 
| 251 | 
            -
                  it { is_expected. | 
| 251 | 
            +
                  it { is_expected.to be_success_result.with_status(:no_status) }
         | 
| 252 | 
            +
                  it { is_expected.to be_success_result.with_message("message") }
         | 
| 253 | 
            +
                  it { is_expected.to be_success_result.with_value("value") }
         | 
| 252 254 | 
             
                end
         | 
| 253 255 |  | 
| 254 256 | 
             
                context 'should fail' do
         | 
| 255 257 | 
             
                  subject(:result) { RSpecCommand.call(should_pass: false) }
         | 
| 256 258 |  | 
| 257 259 | 
             
                  it { is_expected.to be_failed_result }
         | 
| 258 | 
            -
                  it { is_expected.not_to  | 
| 259 | 
            -
                  it { is_expected. | 
| 260 | 
            +
                  it { is_expected.not_to be_success_result }
         | 
| 261 | 
            +
                  it { is_expected.to be_failed_result.with_status(:no_status) }
         | 
| 262 | 
            +
                  it { is_expected.to be_failed_result.with_message("message") }
         | 
| 263 | 
            +
                  it { is_expected.to be_failed_result.with_value("value") }
         | 
| 260 264 | 
             
                end
         | 
| 261 265 | 
             
              end
         | 
| 262 266 | 
             
            end
         | 
| @@ -264,6 +268,35 @@ end | |
| 264 268 |  | 
| 265 269 | 
             
            ### Minitest
         | 
| 266 270 |  | 
| 271 | 
            +
            To use with Minitest, update your 'test_helper' file to include:
         | 
| 272 | 
            +
             | 
| 273 | 
            +
            `require slayer/minitest`
         | 
| 274 | 
            +
             | 
| 275 | 
            +
            This provides you with new assertions: `assert_success` and `assert_failed`:
         | 
| 276 | 
            +
             | 
| 277 | 
            +
            ```ruby
         | 
| 278 | 
            +
            require "minitest/autorun"
         | 
| 279 | 
            +
             | 
| 280 | 
            +
            class MinitestCommandTest < Minitest::Test
         | 
| 281 | 
            +
              def setup
         | 
| 282 | 
            +
                @success_result = MinitestCommand.call(should_pass: true)
         | 
| 283 | 
            +
                @failed_result = MinitestCommand.call(should_pass: false)
         | 
| 284 | 
            +
              end
         | 
| 285 | 
            +
             | 
| 286 | 
            +
              def test_is_success
         | 
| 287 | 
            +
                assert_success @success_result, status: :no_status, message: 'message', value: 'value'
         | 
| 288 | 
            +
                refute_failed @success_result, status: :no_status, message: 'message', value: 'value'
         | 
| 289 | 
            +
              end
         | 
| 290 | 
            +
             | 
| 291 | 
            +
              def test_is_failed
         | 
| 292 | 
            +
                assert_failed @failed_result, status: :no_status, message: 'message', value: 'value'
         | 
| 293 | 
            +
                refute_success @failed_result, status: :no_status, message: 'message', value: 'value'
         | 
| 294 | 
            +
              end
         | 
| 295 | 
            +
            end
         | 
| 296 | 
            +
            ```
         | 
| 297 | 
            +
             | 
| 298 | 
            +
            **Note:** There is no current integration for `Minitest::Spec`.
         | 
| 299 | 
            +
             | 
| 267 300 | 
             
            ## Rails Integration
         | 
| 268 301 |  | 
| 269 302 | 
             
            While Slayer is independent of any framework, we do offer a first-class integration with Ruby on Rails. To install the Rails extensions, add this line to your application's Gemfile:
         | 
| @@ -349,10 +382,18 @@ To install this gem onto your local machine, run `bundle exec rake install`. To | |
| 349 382 |  | 
| 350 383 | 
             
            To generate documentation run `yard`. To view undocumented files run `yard stats --list-undoc`.
         | 
| 351 384 |  | 
| 385 | 
            +
            ### Development w/ Docker
         | 
| 386 | 
            +
             | 
| 387 | 
            +
                $ docker-compose up
         | 
| 388 | 
            +
                $ bin/ssh_to_container
         | 
| 389 | 
            +
                $ bin/console
         | 
| 390 | 
            +
             | 
| 352 391 | 
             
            ## Contributing
         | 
| 353 392 |  | 
| 354 393 | 
             
            Bug reports and pull requests are welcome on GitHub at https://github.com/apsislabs/slayer.
         | 
| 355 394 |  | 
| 395 | 
            +
            Any PRs should be accompanied with documentation in `README.md`, and changes documented in [`CHANGELOG.md`](https://keepachangelog.com/).
         | 
| 396 | 
            +
             | 
| 356 397 | 
             
            ## License
         | 
| 357 398 |  | 
| 358 399 | 
             
            The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
         | 
    
        data/Rakefile
    CHANGED
    
    | @@ -1,10 +1,17 @@ | |
| 1 1 | 
             
            require 'bundler/gem_tasks'
         | 
| 2 | 
            -
            require ' | 
| 2 | 
            +
            require 'rspec/core/rake_task'
         | 
| 3 3 |  | 
| 4 | 
            -
             | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 7 | 
            -
               | 
| 4 | 
            +
            RSpec::Core::RakeTask.new(:spec)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            if defined? Chandler
         | 
| 7 | 
            +
              # Set Chandler options
         | 
| 8 | 
            +
              Chandler::Tasks.configure do |config|
         | 
| 9 | 
            +
                config.changelog_path = 'CHANGELOG.md'
         | 
| 10 | 
            +
                config.github_repository = 'apsislabs/slayer'
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              # Add chandler as a prerequisite for `rake release`
         | 
| 14 | 
            +
              task 'release:rubygem_push' => 'chandler:push'
         | 
| 8 15 | 
             
            end
         | 
| 9 16 |  | 
| 10 | 
            -
            task default: : | 
| 17 | 
            +
            task default: :spec
         | 
    
        data/bin/console
    CHANGED
    
    
    
        data/bin/helpers/docker
    ADDED
    
    
    
        data/bin/rubo_fix
    ADDED
    
    
    
        data/bin/run_tests
    ADDED
    
    | @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            #!/usr/bin/env bash
         | 
| 2 | 
            +
            source bin/helpers/docker
         | 
| 3 | 
            +
            runOnDocker ruby
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            echo "== Starting unit tests =="
         | 
| 6 | 
            +
            bundle exec rake test
         | 
| 7 | 
            +
            if [ $? -ne 0 ]; then
         | 
| 8 | 
            +
                echo -e "\n== Tests failed; push aborted! ==\n"
         | 
| 9 | 
            +
                exit 1
         | 
| 10 | 
            +
            fi
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            echo "== Starting rubocop =="
         | 
| 13 | 
            +
            bundle exec rubocop --format worst --format simple --format offenses
         | 
| 14 | 
            +
            if [ $? -ne 0 ]; then
         | 
| 15 | 
            +
                echo -e "\n== Rubocop failed; push aborted! ==\n"
         | 
| 16 | 
            +
                echo -e "To auto-correct errors run:"
         | 
| 17 | 
            +
                echo -e "\tbin/rubo_fix"
         | 
| 18 | 
            +
                exit 1
         | 
| 19 | 
            +
            fi
         | 
    
        data/bin/setup
    CHANGED
    
    
    
        data/docker-compose.yml
    ADDED
    
    | @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            version: '3'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            services:
         | 
| 4 | 
            +
              ruby:
         | 
| 5 | 
            +
                build: .
         | 
| 6 | 
            +
                volumes:
         | 
| 7 | 
            +
                  - bundle_cache:/bundle
         | 
| 8 | 
            +
                  - .:/app
         | 
| 9 | 
            +
                environment:
         | 
| 10 | 
            +
                  - BUNDLE_JOBS=5
         | 
| 11 | 
            +
                  - BUNDLE_PATH=/bundle
         | 
| 12 | 
            +
                  - BUNDLE_BIN=/bundle/bin
         | 
| 13 | 
            +
                  - GEM_HOME=/bundle
         | 
| 14 | 
            +
                  - DOCKER_CONTAINER=1
         | 
| 15 | 
            +
                command:
         | 
| 16 | 
            +
                  - docker/start.sh
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            volumes:
         | 
| 19 | 
            +
              bundle_cache:
         | 
    
        data/docker/start.sh
    ADDED
    
    
    
        data/lib/slayer/command.rb
    CHANGED
    
    | @@ -3,14 +3,17 @@ module Slayer | |
| 3 3 | 
             
                singleton_skip_hook :call
         | 
| 4 4 |  | 
| 5 5 | 
             
                class << self
         | 
| 6 | 
            -
                  def method_added(name)
         | 
| 7 | 
            -
                    return unless name == :call
         | 
| 8 | 
            -
                    super(name)
         | 
| 9 | 
            -
                  end
         | 
| 10 | 
            -
             | 
| 11 6 | 
             
                  def call(*args, &block)
         | 
| 12 7 | 
             
                    self.new.call(*args, &block)
         | 
| 13 8 | 
             
                  end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  private
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  def inherited(klass)
         | 
| 13 | 
            +
                    super(klass)
         | 
| 14 | 
            +
                    klass.wrap_service_methods!
         | 
| 15 | 
            +
                    klass.only_hook :call
         | 
| 16 | 
            +
                  end
         | 
| 14 17 | 
             
                end
         | 
| 15 18 |  | 
| 16 19 | 
             
                def call
         | 
| @@ -0,0 +1,66 @@ | |
| 1 | 
            +
            # :nocov:
         | 
| 2 | 
            +
            require 'minitest/assertions'
         | 
| 3 | 
            +
            # rubocop:disable Style/Documentation
         | 
| 4 | 
            +
            # rubocop:disable Metrics/MethodLength
         | 
| 5 | 
            +
            module Minitest::Assertions
         | 
| 6 | 
            +
              def assert_success(result, status: nil, message: nil, value: nil)
         | 
| 7 | 
            +
                assert result.success?, 'Expected command to succeed.'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                unless status.nil?
         | 
| 10 | 
            +
                  assert_equal(
         | 
| 11 | 
            +
                    status,
         | 
| 12 | 
            +
                    result.status,
         | 
| 13 | 
            +
                    "Expected command to succeed with status: :#{status}, got: :#{result.status}"
         | 
| 14 | 
            +
                  )
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                unless message.nil?
         | 
| 18 | 
            +
                  assert_equal(
         | 
| 19 | 
            +
                    message,
         | 
| 20 | 
            +
                    result.message,
         | 
| 21 | 
            +
                    "Expected command to succeed with message: #{message}, got: #{result.message}"
         | 
| 22 | 
            +
                  )
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                unless value.nil?
         | 
| 26 | 
            +
                  assert_equal(
         | 
| 27 | 
            +
                    value,
         | 
| 28 | 
            +
                    result.value,
         | 
| 29 | 
            +
                    "Expected command to succeed with value: #{value}, got: #{result.value}"
         | 
| 30 | 
            +
                  )
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
              alias refute_failed assert_success
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def refute_success(result, status: nil, message: nil, value: nil)
         | 
| 36 | 
            +
                refute result.success?, 'Expected command to fail.'
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                unless status.nil?
         | 
| 39 | 
            +
                  refute_equal(
         | 
| 40 | 
            +
                    status,
         | 
| 41 | 
            +
                    result.status,
         | 
| 42 | 
            +
                    "Expected command to fail with status: :#{status}, got: :#{result.status}"
         | 
| 43 | 
            +
                  )
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
                unless message.nil?
         | 
| 47 | 
            +
                  refute_equal(
         | 
| 48 | 
            +
                    message,
         | 
| 49 | 
            +
                    result.message,
         | 
| 50 | 
            +
                    "Expected command to fail with message: #{message}, got: #{result.message}"
         | 
| 51 | 
            +
                  )
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                unless value.nil?
         | 
| 55 | 
            +
                  refute_equal(
         | 
| 56 | 
            +
                    value,
         | 
| 57 | 
            +
                    result.value,
         | 
| 58 | 
            +
                    "Expected command to fail with value: #{value}, got: #{result.value}"
         | 
| 59 | 
            +
                  )
         | 
| 60 | 
            +
                end
         | 
| 61 | 
            +
              end
         | 
| 62 | 
            +
              alias assert_failed refute_success
         | 
| 63 | 
            +
            end
         | 
| 64 | 
            +
            # rubocop:enable Style/Documentation
         | 
| 65 | 
            +
            # rubocop:enable Metrics/MethodLength
         | 
| 66 | 
            +
            # :nocov:
         | 
    
        data/lib/slayer/rspec.rb
    CHANGED
    
    | @@ -1,42 +1,78 @@ | |
| 1 1 | 
             
            require 'rspec/expectations'
         | 
| 2 | 
            -
             | 
| 2 | 
            +
            # rubocop:disable Metrics/BlockLength
         | 
| 3 3 | 
             
            RSpec::Matchers.define :be_success_result do
         | 
| 4 4 | 
             
              match do |result|
         | 
| 5 | 
            -
                result. | 
| 5 | 
            +
                status_matches = @status.nil? || @status == result.status
         | 
| 6 | 
            +
                message_matches = @message.nil? || @message == result.message
         | 
| 7 | 
            +
                value_matches = @value.nil? || @value == result.value
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                result.success? && status_matches && message_matches && value_matches
         | 
| 6 10 | 
             
              end
         | 
| 7 11 |  | 
| 8 12 | 
             
              chain :with_status do |status|
         | 
| 9 13 | 
             
                @status = status
         | 
| 10 14 | 
             
              end
         | 
| 11 15 |  | 
| 16 | 
            +
              chain :with_message do |message|
         | 
| 17 | 
            +
                @message = message
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              chain :with_value do |value|
         | 
| 21 | 
            +
                @value = value
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              # :nocov:
         | 
| 12 25 | 
             
              failure_message do |result|
         | 
| 13 | 
            -
                return 'expected command to succeed' if @status.nil?
         | 
| 14 | 
            -
                return "expected command to succeed with status :#{@status}, but got :#{result.status}"
         | 
| 26 | 
            +
                return 'expected command to succeed' if @status.nil? && @value.nil? && @message.nil?
         | 
| 27 | 
            +
                return "expected command to succeed with status: :#{@status}, but got: :#{result.status}" unless @status.nil?
         | 
| 28 | 
            +
                return "expected command to succeed with value: #{@value}, but got: #{result.value}" unless @value.nil?
         | 
| 29 | 
            +
                return "expected command to succeed with message: #{@message}, but got: :#{result.message}" unless @message.nil?
         | 
| 15 30 | 
             
              end
         | 
| 16 31 |  | 
| 17 32 | 
             
              failure_message_when_negated do |result|
         | 
| 18 | 
            -
                return "expected command not to have  | 
| 33 | 
            +
                return "expected command not to have message: #{@message}" if !@message.nil? && result.message == @message
         | 
| 34 | 
            +
                return "expected command not to have value: #{@value}" if !@value.nil? && result.value == @value
         | 
| 35 | 
            +
                return "expected command not to have status :#{@status}" if !@status.nil? && result.status == @status
         | 
| 19 36 | 
             
                return 'expected command to fail'
         | 
| 20 37 | 
             
              end
         | 
| 38 | 
            +
              # :nocov:
         | 
| 21 39 | 
             
            end
         | 
| 22 40 |  | 
| 23 41 | 
             
            RSpec::Matchers.define :be_failed_result do
         | 
| 24 42 | 
             
              match do |result|
         | 
| 25 | 
            -
                 | 
| 26 | 
            -
                 | 
| 43 | 
            +
                status_matches = @status.nil? || @status == result.status
         | 
| 44 | 
            +
                message_matches = @message.nil? || @message == result.message
         | 
| 45 | 
            +
                value_matches = @value.nil? || @value == result.value
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                result.failure? && status_matches && message_matches && value_matches
         | 
| 27 48 | 
             
              end
         | 
| 28 49 |  | 
| 29 50 | 
             
              chain :with_status do |status|
         | 
| 30 51 | 
             
                @status = status
         | 
| 31 52 | 
             
              end
         | 
| 32 53 |  | 
| 54 | 
            +
              chain :with_message do |message|
         | 
| 55 | 
            +
                @message = message
         | 
| 56 | 
            +
              end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
              chain :with_value do |value|
         | 
| 59 | 
            +
                @value = value
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
              # :nocov:
         | 
| 33 63 | 
             
              failure_message do |result|
         | 
| 34 | 
            -
                return 'expected command to fail' if @status.nil?
         | 
| 35 | 
            -
                return "expected command to fail with status :#{@status}, but got :#{result.status}"
         | 
| 64 | 
            +
                return 'expected command to fail' if @status.nil? && @value.nil? && @message.nil?
         | 
| 65 | 
            +
                return "expected command to fail with status: :#{@status}, but got: :#{result.status}" unless @status.nil?
         | 
| 66 | 
            +
                return "expected command to fail with value: #{@value}, but got: #{result.value}" unless @value.nil?
         | 
| 67 | 
            +
                return "expected command to fail with message: #{@message}, but got: :#{result.message}" unless @message.nil?
         | 
| 36 68 | 
             
              end
         | 
| 37 69 |  | 
| 38 70 | 
             
              failure_message_when_negated do |result|
         | 
| 39 | 
            -
                return "expected command  | 
| 71 | 
            +
                return "expected command to have message: #{@message}" if !@message.nil? && result.message == @message
         | 
| 72 | 
            +
                return "expected command to have value: #{@value}" if !@value.nil? && result.value == @value
         | 
| 73 | 
            +
                return "expected command to have status :#{@status}" if !@status.nil? && result.status == @status
         | 
| 40 74 | 
             
                return 'expected command to succeed'
         | 
| 41 75 | 
             
              end
         | 
| 76 | 
            +
              # :nocov:
         | 
| 42 77 | 
             
            end
         | 
| 78 | 
            +
            # rubocop:enable Metrics/BlockLength
         | 
    
        data/lib/slayer/service.rb
    CHANGED
    
    | @@ -5,8 +5,24 @@ module Slayer | |
| 5 5 | 
             
              class Service
         | 
| 6 6 | 
             
                include Hook
         | 
| 7 7 |  | 
| 8 | 
            -
                skip_hook | 
| 9 | 
            -
             | 
| 8 | 
            +
                skip_hook(
         | 
| 9 | 
            +
                  :pass,
         | 
| 10 | 
            +
                  :flunk,
         | 
| 11 | 
            +
                  :flunk!,
         | 
| 12 | 
            +
                  :try!,
         | 
| 13 | 
            +
                  :wrap_service_methods?,
         | 
| 14 | 
            +
                  :__opt_in
         | 
| 15 | 
            +
                )
         | 
| 16 | 
            +
                singleton_skip_hook(
         | 
| 17 | 
            +
                  :pass,
         | 
| 18 | 
            +
                  :flunk,
         | 
| 19 | 
            +
                  :flunk!,
         | 
| 20 | 
            +
                  :try!,
         | 
| 21 | 
            +
                  :wrap_service_methods?,
         | 
| 22 | 
            +
                  :wrap_service_methods!,
         | 
| 23 | 
            +
                  :do_not_wrap_service_methods!,
         | 
| 24 | 
            +
                  :__opt_in
         | 
| 25 | 
            +
                )
         | 
| 10 26 |  | 
| 11 27 | 
             
                attr_accessor :result
         | 
| 12 28 |  | 
| @@ -35,6 +51,22 @@ module Slayer | |
| 35 51 | 
             
                    return r.value if r.success?
         | 
| 36 52 | 
             
                    flunk!(value: value || r.value, status: status || r.status, message: message || r.message)
         | 
| 37 53 | 
             
                  end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  def wrap_service_methods!
         | 
| 56 | 
            +
                    @__opt_in = true
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  def wrap_service_methods?
         | 
| 60 | 
            +
                    __opt_in
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                  private
         | 
| 64 | 
            +
             | 
| 65 | 
            +
                    def __opt_in
         | 
| 66 | 
            +
                      @__opt_in = false unless defined?(@__opt_in)
         | 
| 67 | 
            +
                      @__opt_in == true
         | 
| 68 | 
            +
                    end
         | 
| 69 | 
            +
             | 
| 38 70 | 
             
                end
         | 
| 39 71 |  | 
| 40 72 | 
             
                def pass(*args)
         | 
| @@ -53,6 +85,10 @@ module Slayer | |
| 53 85 | 
             
                  self.class.try!(*args, &block)
         | 
| 54 86 | 
             
                end
         | 
| 55 87 |  | 
| 88 | 
            +
                def wrap_service_methods?
         | 
| 89 | 
            +
                  self.class.wrap_service_methods?
         | 
| 90 | 
            +
                end
         | 
| 91 | 
            +
             | 
| 56 92 | 
             
                # Make sure child classes also hook correctly
         | 
| 57 93 | 
             
                def self.inherited(klass)
         | 
| 58 94 | 
             
                  klass.include Hook
         | 
| @@ -63,6 +99,8 @@ module Slayer | |
| 63 99 |  | 
| 64 100 | 
             
                # rubocop:disable Metrics/MethodLength
         | 
| 65 101 | 
             
                def self.__service_hook(_, instance, service_block)
         | 
| 102 | 
            +
                  return yield unless wrap_service_methods?
         | 
| 103 | 
            +
             | 
| 66 104 | 
             
                  begin
         | 
| 67 105 | 
             
                    result = yield
         | 
| 68 106 | 
             
                  rescue ResultFailureError => error
         | 
| @@ -94,5 +132,5 @@ module Slayer | |
| 94 132 | 
             
                private_class_method :inherited
         | 
| 95 133 | 
             
                private_class_method :__service_hook
         | 
| 96 134 |  | 
| 97 | 
            -
              end | 
| 98 | 
            -
            end | 
| 135 | 
            +
              end
         | 
| 136 | 
            +
            end
         | 
    
        data/lib/slayer/version.rb
    CHANGED
    
    
    
        data/slayer.gemspec
    CHANGED
    
    | @@ -20,14 +20,16 @@ Gem::Specification.new do |spec| | |
| 20 20 |  | 
| 21 21 | 
             
              spec.add_dependency 'virtus', '~> 1.0'
         | 
| 22 22 |  | 
| 23 | 
            -
              spec.add_development_dependency 'bundler', '~>  | 
| 23 | 
            +
              spec.add_development_dependency 'bundler', '~> 2.0'
         | 
| 24 24 | 
             
              spec.add_development_dependency 'byebug', '~> 9.0'
         | 
| 25 | 
            +
              spec.add_development_dependency 'chandler'
         | 
| 25 26 | 
             
              spec.add_development_dependency 'coveralls'
         | 
| 26 27 | 
             
              spec.add_development_dependency 'minitest', '~> 5.0'
         | 
| 27 28 | 
             
              spec.add_development_dependency 'minitest-reporters', '~> 1.1'
         | 
| 29 | 
            +
              spec.add_development_dependency 'rspec', '~> 3.5'
         | 
| 28 30 | 
             
              spec.add_development_dependency 'mocha', '~> 1.2'
         | 
| 29 | 
            -
              spec.add_development_dependency 'rubocop', '~> 0.48.1'
         | 
| 30 31 | 
             
              spec.add_development_dependency 'rake', '~> 10.0'
         | 
| 32 | 
            +
              spec.add_development_dependency 'rubocop', '= 0.57.2'
         | 
| 31 33 | 
             
              spec.add_development_dependency 'simplecov', '~> 0.13'
         | 
| 32 34 | 
             
              spec.add_development_dependency 'yard', '~> 0.9'
         | 
| 33 35 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: slayer
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.4.0. | 
| 4 | 
            +
              version: 0.4.0.beta3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Wyatt Kirby
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: exe
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date:  | 
| 12 | 
            +
            date: 2019-03-30 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: virtus
         | 
| @@ -31,14 +31,14 @@ dependencies: | |
| 31 31 | 
             
                requirements:
         | 
| 32 32 | 
             
                - - "~>"
         | 
| 33 33 | 
             
                  - !ruby/object:Gem::Version
         | 
| 34 | 
            -
                    version: ' | 
| 34 | 
            +
                    version: '2.0'
         | 
| 35 35 | 
             
              type: :development
         | 
| 36 36 | 
             
              prerelease: false
         | 
| 37 37 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 38 38 | 
             
                requirements:
         | 
| 39 39 | 
             
                - - "~>"
         | 
| 40 40 | 
             
                  - !ruby/object:Gem::Version
         | 
| 41 | 
            -
                    version: ' | 
| 41 | 
            +
                    version: '2.0'
         | 
| 42 42 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 43 43 | 
             
              name: byebug
         | 
| 44 44 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -53,6 +53,20 @@ dependencies: | |
| 53 53 | 
             
                - - "~>"
         | 
| 54 54 | 
             
                  - !ruby/object:Gem::Version
         | 
| 55 55 | 
             
                    version: '9.0'
         | 
| 56 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 57 | 
            +
              name: chandler
         | 
| 58 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 59 | 
            +
                requirements:
         | 
| 60 | 
            +
                - - ">="
         | 
| 61 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 62 | 
            +
                    version: '0'
         | 
| 63 | 
            +
              type: :development
         | 
| 64 | 
            +
              prerelease: false
         | 
| 65 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 66 | 
            +
                requirements:
         | 
| 67 | 
            +
                - - ">="
         | 
| 68 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 69 | 
            +
                    version: '0'
         | 
| 56 70 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 57 71 | 
             
              name: coveralls
         | 
| 58 72 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -96,33 +110,33 @@ dependencies: | |
| 96 110 | 
             
                  - !ruby/object:Gem::Version
         | 
| 97 111 | 
             
                    version: '1.1'
         | 
| 98 112 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 99 | 
            -
              name:  | 
| 113 | 
            +
              name: rspec
         | 
| 100 114 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 101 115 | 
             
                requirements:
         | 
| 102 116 | 
             
                - - "~>"
         | 
| 103 117 | 
             
                  - !ruby/object:Gem::Version
         | 
| 104 | 
            -
                    version: ' | 
| 118 | 
            +
                    version: '3.5'
         | 
| 105 119 | 
             
              type: :development
         | 
| 106 120 | 
             
              prerelease: false
         | 
| 107 121 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 108 122 | 
             
                requirements:
         | 
| 109 123 | 
             
                - - "~>"
         | 
| 110 124 | 
             
                  - !ruby/object:Gem::Version
         | 
| 111 | 
            -
                    version: ' | 
| 125 | 
            +
                    version: '3.5'
         | 
| 112 126 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 113 | 
            -
              name:  | 
| 127 | 
            +
              name: mocha
         | 
| 114 128 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 115 129 | 
             
                requirements:
         | 
| 116 130 | 
             
                - - "~>"
         | 
| 117 131 | 
             
                  - !ruby/object:Gem::Version
         | 
| 118 | 
            -
                    version:  | 
| 132 | 
            +
                    version: '1.2'
         | 
| 119 133 | 
             
              type: :development
         | 
| 120 134 | 
             
              prerelease: false
         | 
| 121 135 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 122 136 | 
             
                requirements:
         | 
| 123 137 | 
             
                - - "~>"
         | 
| 124 138 | 
             
                  - !ruby/object:Gem::Version
         | 
| 125 | 
            -
                    version:  | 
| 139 | 
            +
                    version: '1.2'
         | 
| 126 140 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 127 141 | 
             
              name: rake
         | 
| 128 142 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -137,6 +151,20 @@ dependencies: | |
| 137 151 | 
             
                - - "~>"
         | 
| 138 152 | 
             
                  - !ruby/object:Gem::Version
         | 
| 139 153 | 
             
                    version: '10.0'
         | 
| 154 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 155 | 
            +
              name: rubocop
         | 
| 156 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 157 | 
            +
                requirements:
         | 
| 158 | 
            +
                - - '='
         | 
| 159 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 160 | 
            +
                    version: 0.57.2
         | 
| 161 | 
            +
              type: :development
         | 
| 162 | 
            +
              prerelease: false
         | 
| 163 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 164 | 
            +
                requirements:
         | 
| 165 | 
            +
                - - '='
         | 
| 166 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 167 | 
            +
                    version: 0.57.2
         | 
| 140 168 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 141 169 | 
             
              name: simplecov
         | 
| 142 170 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -176,22 +204,32 @@ files: | |
| 176 204 | 
             
            - ".githooks/pre-push"
         | 
| 177 205 | 
             
            - ".gitignore"
         | 
| 178 206 | 
             
            - ".hound.yml"
         | 
| 207 | 
            +
            - ".rspec"
         | 
| 179 208 | 
             
            - ".rubocop.yml"
         | 
| 180 209 | 
             
            - ".rubocop_todo.yml"
         | 
| 181 210 | 
             
            - ".travis.yml"
         | 
| 211 | 
            +
            - CHANGELOG.md
         | 
| 212 | 
            +
            - Dockerfile
         | 
| 182 213 | 
             
            - Gemfile
         | 
| 183 214 | 
             
            - LICENSE.txt
         | 
| 184 215 | 
             
            - README.md
         | 
| 185 216 | 
             
            - Rakefile
         | 
| 186 217 | 
             
            - bin/console
         | 
| 218 | 
            +
            - bin/helpers/docker
         | 
| 187 219 | 
             
            - bin/install-githooks
         | 
| 220 | 
            +
            - bin/rubo_fix
         | 
| 221 | 
            +
            - bin/run_tests
         | 
| 188 222 | 
             
            - bin/setup
         | 
| 223 | 
            +
            - bin/ssh_to_container
         | 
| 224 | 
            +
            - docker-compose.yml
         | 
| 225 | 
            +
            - docker/start.sh
         | 
| 189 226 | 
             
            - lib/ext/string_ext.rb
         | 
| 190 227 | 
             
            - lib/slayer.rb
         | 
| 191 228 | 
             
            - lib/slayer/command.rb
         | 
| 192 229 | 
             
            - lib/slayer/errors.rb
         | 
| 193 230 | 
             
            - lib/slayer/form.rb
         | 
| 194 231 | 
             
            - lib/slayer/hook.rb
         | 
| 232 | 
            +
            - lib/slayer/minitest.rb
         | 
| 195 233 | 
             
            - lib/slayer/result.rb
         | 
| 196 234 | 
             
            - lib/slayer/result_matcher.rb
         | 
| 197 235 | 
             
            - lib/slayer/rspec.rb
         |