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-0.8.8 spec/support/private_api_formatter.rb
ably-0.8.7 spec/support/private_api_formatter.rb
ably-0.8.6 spec/support/private_api_formatter.rb
ably-rest-0.8.6 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-rest-0.8.5 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-0.8.5 spec/support/private_api_formatter.rb
ably-0.8.4 spec/support/private_api_formatter.rb
ably-rest-0.8.3 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-0.8.3 spec/support/private_api_formatter.rb
ably-rest-0.8.2 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-0.8.2 spec/support/private_api_formatter.rb
ably-0.8.1 spec/support/private_api_formatter.rb
ably-rest-0.8.1 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-0.8.0 spec/support/private_api_formatter.rb
ably-0.7.6 spec/support/private_api_formatter.rb
ably-rest-0.7.5 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-0.7.5 spec/support/private_api_formatter.rb
ably-0.7.4 spec/support/private_api_formatter.rb
ably-rest-0.7.3 lib/submodules/ably-ruby/spec/support/private_api_formatter.rb
ably-0.7.2 spec/support/private_api_formatter.rb