class GitCommander::RSpec::PluginHelpers::MockGemfile

nodoc

Constants

DEFAULT_GEM_SOURCE

Attributes

gems[R]
options[R]

Public Class Methods

new() click to toggle source
# File lib/git_commander/rspec/plugin_helpers.rb, line 17
def initialize
  @gems = {}
  @source = DEFAULT_GEM_SOURCE
end

Public Instance Methods

gem(name, *options) click to toggle source
# File lib/git_commander/rspec/plugin_helpers.rb, line 22
def gem(name, *options)
  @gems[name] = options || []
end
gem_definition(name, *options) click to toggle source
# File lib/git_commander/rspec/plugin_helpers.rb, line 39
def gem_definition(name, *options)
  ["gem '#{name}'", *Array(options).map { |o| gem_option_to_s(o) }].join(", ")
end
gem_option_to_s(option) click to toggle source
# File lib/git_commander/rspec/plugin_helpers.rb, line 43
def gem_option_to_s(option)
  return "" if option.to_s.empty?

  case option
  when Hash
    option.map { |k, v| "#{k}: '#{v}'" }
  else
    "'#{option}'"
  end
end
gemfile_lines() click to toggle source
# File lib/git_commander/rspec/plugin_helpers.rb, line 32
def gemfile_lines
  [
    source,
    *@gems.map { |name, options| gem_definition(name, *options) }
  ]
end
source(value = nil) click to toggle source
# File lib/git_commander/rspec/plugin_helpers.rb, line 26
def source(value = nil)
  return "source: '#{@source}'" if value.nil?

  @source = value
end