Class: Rspec::PendingFor::Build

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec/pending_for/build.rb

Overview

SRP: Describe the RubyEngine and/or RubyVersion(s) that will be pended or skipped and with what message

Constant Summary collapse

INTERPRETER_MATRIX =

Keys are the

{
  "unknown" => "MRI < 1.9 (probably)",
  "ruby" => "MRI >= 1.9",
  "ree" => "Ruby Enterprise Edition",
  "jruby" => "JRuby",
  "macruby" => "MacRuby",
  "rbx" => "Rubinius",
  "maglev" => "MagLev",
  "ironruby" => "IronRuby",
  "cardinal" => "Cardinal",
  "truffleruby" => "Truffle Ruby",
}.freeze
BROKEN_STRING =
"Behavior is broken"
BUG_STRING =
"due to a bug in the Ruby engine"
VERSIONS_STRING =
"in Ruby versions"
"https://github.com/galtzo-floss/rspec-pending_for/issues"
RELEVANT_VERSIONS_PROC =
lambda { |rv| "#{BROKEN_STRING} #{VERSIONS_STRING} #{rv} #{BUG_STRING}" }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Build

Returns a new instance of Build.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/rspec/pending_for/build.rb', line 43

def initialize(options = {})
  # Normalize versions without enumerating ranges
  raw_versions = options[:versions]
  @relevant_versions = if raw_versions.nil?
    []
  elsif raw_versions.is_a?(Array)
    raw_versions
  elsif raw_versions.is_a?(Range)
    [raw_versions]
  else
    [raw_versions]
  end
  @relevant_engine = options[:engine].nil? ? nil : options[:engine].to_s
  @reason = options[:reason]
  warn_about_unrecognized_engine
  # If engine is nil, then any matching versions should be pended
  @message = if @relevant_engine.nil?
    no_engine_specified
  elsif RubyEngine.is?(@relevant_engine)
    engine_specified_and_relevant
  end
end

Instance Attribute Details

#messageObject (readonly)

Returns the value of attribute message.



41
42
43
# File 'lib/rspec/pending_for/build.rb', line 41

def message
  @message
end

#reasonObject (readonly)

Returns the value of attribute reason.



41
42
43
# File 'lib/rspec/pending_for/build.rb', line 41

def reason
  @reason
end

#relevant_engineObject (readonly)

Returns the value of attribute relevant_engine.



41
42
43
# File 'lib/rspec/pending_for/build.rb', line 41

def relevant_engine
  @relevant_engine
end

#relevant_versionsObject (readonly)

Returns the value of attribute relevant_versions.



41
42
43
# File 'lib/rspec/pending_for/build.rb', line 41

def relevant_versions
  @relevant_versions
end

Instance Method Details

#current_matches_specified?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/rspec/pending_for/build.rb', line 66

def current_matches_specified?
  !message.nil?
end