Sha256: 24301c74eda5b976cbaac5bd9080a6ffa927680b52997a9fc73962187035965b

Contents?: true

Size: 1016 Bytes

Versions: 82

Compression:

Stored size: 1016 Bytes

Contents

module Ably::RSpec
  # PrivateApiFormatter is an RSpec Formatter that prefixes all tests that are part of a Private API with '(private)'
  #
  # Private API methods are tested for this library, but every implementation of the Ably client library
  # will likely be different and thus the private API method tests are not shared.
  #
  # Filter private API tests with `rspec --tag ~api_private`
  #
  class PrivateApiFormatter
    ::RSpec::Core::Formatters.register self, :example_started

    def initialize(output)
      @output = output
    end

    def example_started(notification)
      if notification.example.metadata[:api_private]
        notification.example.metadata[:description] = "#{yellow('(private)')} #{green(notification.example.metadata[:description])}"
      end
    end

    private
    def colorize(color_code, string)
      "\e[#{color_code}m#{string}\e[0m"
    end

    def yellow(string)
      colorize(33, string)
    end


    def green(string)
      colorize(32, string)
    end
  end
end

Version data entries

82 entries across 82 versions & 2 rubygems

Version Path
ably-rest-1.2.7 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.2.7 spec/support/private_api_formatter.rb
ably-rest-1.2.6 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.2.6 spec/support/private_api_formatter.rb
ably-rest-1.2.4 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.2.4 spec/support/private_api_formatter.rb
ably-rest-1.2.3 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.2.3 spec/support/private_api_formatter.rb
ably-rest-1.2.2 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.2.2 spec/support/private_api_formatter.rb
ably-rest-1.2.1 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.2.1 spec/support/private_api_formatter.rb
ably-rest-1.2.0 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.2.0 spec/support/private_api_formatter.rb
ably-rest-1.1.8 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.1.8 spec/support/private_api_formatter.rb
ably-rest-1.1.7 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.1.7 spec/support/private_api_formatter.rb
ably-rest-1.1.6 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-1.1.6 spec/support/private_api_formatter.rb