source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/scrubber_spec.rb
Ruby
mit
231
main
689
require 'spec_helper' describe Approvals::Scrubber do describe "defaults" do let(:path) { File.expand_path('.') } subject { Approvals::Scrubber.new("I am currently at #{path}") } it "has a sensible to_s" do expect(subject.to_s).to eq("I am currently at {{current_dir}}") end it "unscrubs"...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/namers/default_namer_spec.rb
Ruby
mit
231
main
722
require 'spec_helper' describe Approvals::Namers::DefaultNamer do subject { Approvals::Namers::DefaultNamer.new("a f!$^%&*(unky name") } it "normalizes the name" do expect(subject.name).to eq 'a_funky_name' end context "when configured" do before :each do Approvals.configure do |c| c.a...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/namers/rspec_namer_spec.rb
Ruby
mit
231
main
825
require 'spec_helper' describe Approvals::Namers::RSpecNamer do it "uses non-$%^&*funky example description" do |example| expect(Approvals::Namers::RSpecNamer.new(example).name).to eq 'approvals_namers_rspecnamer_uses_non_funky_example_description' end it "has a decent default" do |example| expect(Appr...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/namers/directory_namer_spec.rb
Ruby
mit
231
main
845
require 'spec_helper' describe Approvals::Namers::DirectoryNamer do it "uses non-$%^&*funky example description" do |example| expect(Approvals::Namers::DirectoryNamer.new(example).name).to eq 'approvals_namers_directorynamer/uses_non_funky_example_description' end it "has a decent default" do |example| ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/reporters/first_working_reporter_spec.rb
Ruby
mit
231
main
929
require 'spec_helper' describe Approvals::Reporters::FirstWorkingReporter do let(:no) { double(:working_in_this_environment? => false) } let(:yes) { double(:working_in_this_environment? => true) } let(:yes_too) { double(:working_in_this_environment? => true) } it "when at least one reporter works it is work...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/reporters/launcher_spec.rb
Ruby
mit
231
main
720
require 'spec_helper' describe Approvals::Reporters::Launcher do it "has a vimdiff launcher" do expect(described_class.vimdiff.call('one', 'two')).to eq("vimdiff one two") end it "has an opendiff launcher" do expect(described_class.opendiff.call('one', 'two')).to eq("opendiff one two") end it "has ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/reporters/html_image_reporter_spec.rb
Ruby
mit
231
main
941
require 'spec_helper' describe Approvals::Reporters::HtmlImageReporter do subject { Approvals::Reporters::HtmlImageReporter.instance } it "creates the template" do scrubber = Approvals::Scrubber.new(subject.html("spec/fixtures/one.png", "spec/fixtures/two.png")) expect(scrubber.to_s).to eq('<html><head><...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/reporters/reporter_spec.rb
Ruby
mit
231
main
628
require 'spec_helper' describe Approvals::Reporters::Reporter do it "is not approved by default" do expect(Approvals::Reporters::Reporter.new).not_to be_approved_when_reported end it "takes a launcher" do move = lambda {|received, approved| "echo \"mv #{received} #{approved}\"" } expect(...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/reporters/opendiff_reporter_spec.rb
Ruby
mit
231
main
502
require 'spec_helper' describe Approvals::Reporters::OpendiffReporter do it "has a nice launcher" do skip "Breaks off execution of the tests. Horrible." one = 'spec/fixtures/one.txt' two = 'spec/fixtures/two.txt' executable = Approvals::Executable.new(Approvals::Reporters::OpendiffReporter.instance....
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/reporters/image_magick_reporter_spec.rb
Ruby
mit
231
main
484
require 'spec_helper' describe Approvals::Reporters::ImageMagickReporter do subject { Approvals::Reporters::ImageMagickReporter.instance } it "creates the appropriate command" do result = subject.create_command_line("spec/fixtures/one.png", "spec/fixtures/two.png") expected = "compare spec/fixtures/one.pn...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/extensions/rspec_approvals_spec.rb
Ruby
mit
231
main
2,308
require 'approvals/rspec' shared_context 'verify examples' do specify "a string" do verify do "We have, I fear, confused power with greatness." end end specify "an array" do verify do array = [ "abc", 123, :zomg_fooooood, %w(cheese burger ribs steak bacon)...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
spec/verifiers/json_verifier_spec.rb
Ruby
mit
231
main
923
require 'spec_helper' describe Approvals::Verifiers::JsonVerifier do subject(:instance) do described_class.new(received_path, approved_path) end context "with same json content but different formatting" do let(:received_path) do "./spec/fixtures/json_approval_with_different_whitespace/received.jso...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals.rb
Ruby
mit
231
main
433
require 'json' require 'fileutils' require 'nokogiri' require_relative 'approvals/error' require 'zeitwerk' loader = Zeitwerk::Loader.for_gem loader.inflector.inflect( 'dsl' => 'DSL', 'rspec' => 'RSpec', 'rspec_namer' => 'RSpecNamer', ) loader.setup module Approvals extend DSL def self.pro...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/scrubber.rb
Ruby
mit
231
main
601
module Approvals class Scrubber def initialize(string, hash = nil) @hash = hash @string = scrub(string) end def hash @hash ||= { 'current_dir' => File.expand_path('.') } end def scrub(string) hash.each do |key, value| string = string.gsub(value, wrap...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/rspec.rb
Ruby
mit
231
main
505
if defined? RSpec require 'approvals/extensions/rspec/dsl' require 'approvals/namers/rspec_namer' require 'approvals/namers/directory_namer' RSpec.configure do |c| c.include Approvals::RSpec::DSL c.add_setting :approvals_path, :default => 'spec/fixtures/approvals/' c.add_setting :approvals_namer_cl...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/configuration.rb
Ruby
mit
231
main
465
require 'singleton' module Approvals def self.configure(&block) block.call Approvals::Configuration.instance end def self.configuration Approvals::Configuration.instance end class Configuration include Singleton attr_writer :approvals_path attr_writer :excluded_json_keys def appro...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/approval.rb
Ruby
mit
231
main
2,819
require 'erb' # It is referenced on line 69 module Approvals class Approval class << self attr_accessor :namer end attr_reader :subject, :namer, :failure def initialize(subject, options = {}) @subject = subject @namer = options[:namer] || default_namer(options[:name]) @format ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/cli.rb
Ruby
mit
231
main
1,197
# don't require the approvals library here, as it will reset the dotfile. # or find a better way to reset the dotfile before a run. module Approvals class CLI < Thor desc "verify", "Go through all failing approvals with a diff tool" method_option :diff, :type => :string, :default => 'diff -N', :aliases => '-...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/error.rb
Ruby
mit
231
main
464
module Approvals # FIXME: Naming Things class ApprovalError < Exception attr_accessor :received_path, :approved_path def received_exists? received_path && File.exist?(received_path) end def received_text received_exists? && IO.read(received_path) end def approved_exists? ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/filter.rb
Ruby
mit
231
main
980
module Approvals class Filter attr_reader :filters def initialize(filters) @filters = filters @placeholder = {} end def apply hash_or_array if @filters.any? censored(hash_or_array) else hash_or_array end end def censored value, key=nil if ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/writer.rb
Ruby
mit
231
main
705
module Approvals module Writer extend Writers REGISTRY = { json: Writers::JsonWriter.new, xml: Writers::XmlWriter.new, html: Writers::HtmlWriter.new, hash: Writers::HashWriter.new, array: Writers::ArrayWriter.new, txt: Writers::TextWriter.new, } def self.fo...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/combination_approvals.rb
Ruby
mit
231
main
679
module Approvals class CombinationApprovals def self.verify_all_combinations(*arg_variations, namer:) combo = new() arg_variations.each do |list| combo.arg(list) end output = "" combo.all_combinations.each do |args| begin result = yield *args rescue...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/system_command.rb
Ruby
mit
231
main
214
module Approvals module SystemCommand def self.exists?(executable) if SystemUtils.windows? `where #{executable}` != "" else `which #{executable}` != "" end end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/dotfile.rb
Ruby
mit
231
main
590
module Approvals module Dotfile def self.reset File.truncate(path, 0) if File.exist?(path) end def self.append(text) unless includes?(text) write text end end module Private private def path File.join(Approvals.project_dir, '.approvals') end ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/executable.rb
Ruby
mit
231
main
264
module Approvals class Executable attr_accessor :command, :on_failure def initialize(command, &block) self.command = command self.on_failure = block end def to_s inspect end def inspect command end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/image_magick_reporter.rb
Ruby
mit
231
main
432
module Approvals module Reporters class ImageMagickReporter include Singleton def working_in_this_environment? Approvals::SystemCommand.exists? "compare" end def create_command_line(received, approved) "compare #{received} #{approved} -compose Src x:" end def...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/reporter.rb
Ruby
mit
231
main
511
module Approvals module Reporters class Reporter attr_reader :launcher def initialize(&launcher) @launcher = launcher || default_launcher end def report(received, approved) launch(received, approved) end def approved_when_reported? false end ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/first_working_reporter.rb
Ruby
mit
231
main
478
module Approvals module Reporters class FirstWorkingReporter attr_accessor :reporters def initialize(*reporters) self.reporters = reporters end def working_in_this_environment? reporters.any?(&:working_in_this_environment?) end def report(received, approved) ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/image_reporter.rb
Ruby
mit
231
main
229
module Approvals module Reporters class ImageReporter < FirstWorkingReporter include Singleton def initialize super(ImageMagickReporter.instance, HtmlImageReporter.instance) end end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/launcher.rb
Ruby
mit
231
main
1,305
module Approvals module Reporters module Launcher REPORTERS = [:opendiff, :diffmerge, :vimdiff, :tortoisediff, :filelauncher] module_function def memoized(instance_variable) unless self.instance_variable_get(instance_variable) value = yield self.instance_variable_se...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/html_image_reporter.rb
Ruby
mit
231
main
992
module Approvals module Reporters class HtmlImageReporter include Singleton def working_in_this_environment? true end def report(received, approved) display html(received, approved) end def html(received, approved) template(File.expand_path(received),...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/vimdiff_reporter.rb
Ruby
mit
231
main
275
module Approvals module Reporters class VimdiffReporter < Reporter include Singleton def self.report(received, approved) instance.report(received, approved) end def default_launcher Launcher.vimdiff end end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/tortoisediff_reporter.rb
Ruby
mit
231
main
285
module Approvals module Reporters class TortoisediffReporter < Reporter include Singleton def self.report(received, approved) instance.report(received, approved) end def default_launcher Launcher.tortoisediff end end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/opendiff_reporter.rb
Ruby
mit
231
main
277
module Approvals module Reporters class OpendiffReporter < Reporter include Singleton def self.report(received, approved) instance.report(received, approved) end def default_launcher Launcher.opendiff end end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/filelauncher_reporter.rb
Ruby
mit
231
main
291
module Approvals module Reporters class FilelauncherReporter < Reporter include Singleton def self.report(received, approved = nil) instance.report(received, approved) end def default_launcher Launcher.filelauncher end end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/reporters/diffmerge_reporter.rb
Ruby
mit
231
main
279
module Approvals module Reporters class DiffmergeReporter < Reporter include Singleton def self.report(received, approved) instance.report(received, approved) end def default_launcher Launcher.diffmerge end end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/namers/rspec_namer.rb
Ruby
mit
231
main
683
module Approvals module Namers class RSpecNamer attr_reader :name def initialize(example) @name = name_for_example(example) @output_dir = nil end def name_for_example(example) normalize example.full_description end def normalize(string) string...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/namers/default_namer.rb
Ruby
mit
231
main
474
module Approvals module Namers class DefaultNamer attr_reader :name def initialize(name = nil) raise ArgumentError.new("DefaultNamer: You must specify a name") if name.nil? @name = normalize(name) end def normalize(string) string.strip.squeeze(" ").gsub(/[\ :-]+/, ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/namers/directory_namer.rb
Ruby
mit
231
main
758
module Approvals module Namers class DirectoryNamer < RSpecNamer private def name_for_example(example) directorize example end def directorize(example) approvals_path = lambda do |metadata| description = normalize metadata[:description] example_group =...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/verifiers/json_verifier.rb
Ruby
mit
231
main
498
module Approvals module Verifiers class JsonVerifier def initialize(received_path, approved_path) self.received_path = received_path self.approved_path = approved_path end def verify approved == received end private attr_accessor :approved_path, :rece...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/extensions/rspec/dsl.rb
Ruby
mit
231
main
1,496
require 'rspec/expectations' module Approvals module RSpec module DSL def executable(command, &block) Approvals::Executable.new(command, &block) end def verify(options = {}, &block) # Workaround to support both Rspec 2 and 3 # RSpec.current_example is the Rspec 3 way ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/writers/array_writer.rb
Ruby
mit
231
main
419
module Approvals module Writers class ArrayWriter < TextWriter using HashInspectRefinements def format(data) filter(data).map.with_index do |value, i| "[#{i.inspect}] #{value.inspect()}\n" end.join end def filter(data) filter = ::Approvals::Filter.new(::...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/writers/xml_writer.rb
Ruby
mit
231
main
256
module Approvals module Writers class XmlWriter < TextWriter def extension 'xml' end def format(data) Nokogiri::XML(data.to_s.strip,&:noblanks).to_xml(:indent => 2, :encoding => 'UTF-8') end end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/writers/text_writer.rb
Ruby
mit
231
main
333
module Approvals module Writers class TextWriter def extension 'txt' end def write(data, path) FileUtils.mkdir_p(File.dirname(path)) File.open(path, 'w') do |f| f.write format(data) end end def format(data) data.to_s end e...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/writers/hash_writer.rb
Ruby
mit
231
main
415
module Approvals module Writers class HashWriter < TextWriter def format(data) lines = filter(data).map do |key, value| "\t#{key.inspect} => #{value.inspect}" end.join("\n") "{\n#{lines}\n}\n" end def filter data filter = ::Approvals::Filter.new(::Appr...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/writers/hash_inspect_refinements.rb
Ruby
mit
231
main
329
module Approvals module Writers module HashInspectRefinements refine Hash do def inspect "{#{map { |k, v| "#{k.inspect}=>#{v.inspect}" }.join(', ')}}" end end refine Array do def inspect "[#{map(&:inspect).join(', ')}]" end end end ...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/writers/json_writer.rb
Ruby
mit
231
main
665
module Approvals module Writers class JsonWriter < TextWriter def extension 'json' end def format(data) hash_or_array = filter(parse_data(data)) JSON.pretty_generate(hash_or_array) + "\n" end private def parse_data(data) if data.respond_to?(:...
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/writers/html_writer.rb
Ruby
mit
231
main
261
module Approvals module Writers class HtmlWriter < TextWriter def extension 'html' end def format(data) Nokogiri::HTML(data.to_s.strip,&:noblanks).to_xhtml(:indent => 2, :encoding => 'UTF-8') end end end end
github
approvals/ApprovalTests.Ruby
https://github.com/approvals/ApprovalTests.Ruby
lib/approvals/writers/binary_writer.rb
Ruby
mit
231
main
1,091
module Approvals module Writers class BinaryWriter EXCEPTION_WRITER = Proc.new do |data, file| raise "BinaryWriter#callback missing" end def initialize(opts = {}) @autoregister = opts[:autoregister] || true @detect = opts[:detect] @extension = opts[:extension] ||...
github
tablexi/capistrano3-unicorn
https://github.com/tablexi/capistrano3-unicorn
capistrano3-unicorn.gemspec
Ruby
mit
231
master
719
lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) Gem::Specification.new do |gem| gem.name = "capistrano3-unicorn" gem.version = '0.2.1' gem.authors = ["Matthew Lineen"] gem.email = ["matthew@lineen.com"] gem.description = "Unico...
github
tablexi/capistrano3-unicorn
https://github.com/tablexi/capistrano3-unicorn
examples/unicorn.rb
Ruby
mit
231
master
1,231
# paths app_path = "/home/example/www.example.com" working_directory "#{app_path}/current" pid "#{app_path}/current/tmp/pids/unicorn.pid" # listen listen "/tmp/unicorn-www.example.com.socket", :backlog => 64 # logging stderr_path "log/unicorn.stderr.log" stdout_path "log/unicorn.stdout.log" # workers w...
github
tablexi/capistrano3-unicorn
https://github.com/tablexi/capistrano3-unicorn
lib/capistrano3/tasks/unicorn.rake
Ruby
mit
231
master
3,106
namespace :load do task :defaults do set :unicorn_pid, -> { File.join(current_path, "tmp", "pids", "unicorn.pid") } set :unicorn_rack_env, -> { fetch(:rails_env) ? fetch(:rails_env) : "deployment" } set :unicorn_config_path, -> { File.join(current_path, "config", "unicorn", "#{fetch(:unicorn_rack_env)}.rb...
github
zolrath/marky_markov
https://github.com/zolrath/marky_markov
marky_markov.gemspec
Ruby
mit
231
master
3,617
## This is the rakegem gemspec template. Make sure you read and understand ## all of the comments. Some sections require modification, and others can ## be deleted if you don't need them. Once you understand the contents of ## this file, feel free to delete any comments that begin with two hash marks. ## You can find c...
github
zolrath/marky_markov
https://github.com/zolrath/marky_markov
lib/marky_markov.rb
Ruby
mit
231
master
6,623
#!/usr/bin/env ruby -i #A Markov Chain generator. require_relative 'marky_markov/persistent_dictionary' require_relative 'marky_markov/markov_sentence_generator' # @version = 0.3.5 # @author Matt Furden # Module containing TemporaryDictionary and Dictionary for creation of # Markov Chain Dictionaries and generating s...
github
zolrath/marky_markov
https://github.com/zolrath/marky_markov
lib/marky_markov/markov_dictionary.rb
Ruby
mit
231
master
1,876
# @private class MarkovDictionary # :nodoc: attr_reader :dictionary, :depth, :capitalized_words def initialize(depth=2) @dictionary = {} @capitalized_words = [] @depth = depth @split_words = /(\.\s+)|(\.$)|([?!])|[\s]+/ @split_sentence = /(?<=[.!?])\s+/ end # If File does not exist. class...
github
zolrath/marky_markov
https://github.com/zolrath/marky_markov
lib/marky_markov/markov_sentence_generator.rb
Ruby
mit
231
master
3,654
# Messing about with the NullObject pattern, can't apply it in too many # places in this one. Need to evaluate what else could be used in this # aside from my first instinct of defaulting to [] # @private class NullObject # :nodoc: def method_missing (*args, &block) self end def nil?; true; end def <<(*); e...
github
zolrath/marky_markov
https://github.com/zolrath/marky_markov
lib/marky_markov/persistent_dictionary.rb
Ruby
mit
231
master
2,225
require 'msgpack' require_relative 'markov_dictionary' # @private class PersistentDictionary < MarkovDictionary # :nodoc: class DepthNotInRangeError < Exception # :nodoc: end # Creates a PersistentDictionary object using the supplied dictionary file. # # @param [File] dictionary Name of dictionary file to ...
github
zolrath/marky_markov
https://github.com/zolrath/marky_markov
spec/marky_markov/marky_markov_spec.rb
Ruby
mit
231
master
4,813
require 'spec_helper' require 'marky_markov' describe MarkyMarkov do let(:onedictcompare) { { ["The"] => ["cat"], ["cat"] => ["likes"], ["likes"] => ["pie"], ["pie"] => ["and"], ["and"] => ["chainsaws"], ["chainsaws"] => ["!"]} } let(:twodictcompare) { {["The", "cat"] => ["...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
pdk.gemspec
Ruby
apache-2.0
231
main
1,722
lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'pdk/version' Gem::Specification.new do |spec| spec.name = 'pdk' spec.version = PDK::VERSION spec.authors = ['Puppet, Inc.'] spec.email = ['pdk-maintainers@puppet.com'] spec.summary = 'A key part ...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
Gemfile
Ruby
apache-2.0
231
main
853
source 'https://rubygems.org' # Specify your gem's dependencies in pdk.gemspec gemspec group :development do gem 'ruby-prof' gem 'yard' gem 'fuubar' gem 'pry' gem 'pry-stack_explorer' end group :test do gem 'parallel' gem 'parallel_tests' gem 'rake' gem 'rexml' gem 'rspec', '~> 3.0' gem 'ruboc...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
Rakefile
Ruby
apache-2.0
231
main
2,734
require 'bundler/gem_tasks' require 'puppet_litmus/rake_tasks' if Bundler.rubygems.find_name('puppet_litmus').any? require 'rspec/core/rake_task' require 'rubocop/rake_task' build_defs_file = 'ext/build_defaults.yaml' if File.exist?(build_defs_file) begin require 'yaml' @build_defaults ||= YAML.load_file(bui...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/spec_helper_acceptance.rb
Ruby
apache-2.0
231
main
4,602
require 'fileutils' require 'serverspec' require 'tmpdir' require 'open3' require 'pdk/generate/module' require 'pdk/util/template_uri' require 'tempfile' require 'json' # Sets default puppet/ruby versions to be used within the tests # Duplicates of this are found within spec_helper.rb and spec_helper_package.rb and s...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/spec_helper.rb
Ruby
apache-2.0
231
main
2,337
if ENV.fetch('COVERAGE', nil) == 'yes' require 'simplecov' require 'simplecov-console' SimpleCov.formatters = [ SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::Console ] SimpleCov.start do track_files 'lib/**/*.rb' add_filter '/spec' # do not track vendored files add_fil...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/support/validators.rb
Ruby
apache-2.0
231
main
2,665
require 'pdk/validate/validator' # A mock validator which doesn't raise an error class MockSuccessValidator < PDK::Validate::Validator def name 'mocksuccess' end def invoke(report) report.add_event( file: 'pass.txt', source: name, state: :passed, severity: 'ok' ) 0 end...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/support/mock_configuration.rb
Ruby
apache-2.0
231
main
1,887
RSpec.shared_context 'mock configuration' do let(:default_answer_file_content) { nil } let(:system_answers_content) { nil } let(:user_config_content) { nil } let(:system_config_content) { nil } let(:new_config) do PDK::Config.new.tap do |item| item.user_config.read_only! item.system_config.re...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/support/valid_in_context.rb
Ruby
apache-2.0
231
main
592
RSpec.shared_examples_for 'only valid in specified PDK contexts' do |*context_class| describe '.valid_in_context?' do [ PDK::Context::None.new(nil), PDK::Context::Module.new(nil, nil), PDK::Context::ControlRepo.new(nil, nil) ].each do |pdk_context| context "in #{pdk_context.display_nam...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/support/file_based_namespaces.rb
Ruby
apache-2.0
231
main
6,501
RSpec.shared_examples 'a file based namespace' do |content, expected_settings| before do allow(PDK::Util::Filesystem).to receive(:mkdir_p) end describe '#parse_file' do context 'when the file contains valid data' do before do expect(subject).to receive(:load_data).and_return(content) ...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/support/run_outside_module.rb
Ruby
apache-2.0
231
main
370
RSpec.shared_context 'run outside module' do let(:mock_context) { PDK::Context::None.new(nil) } before do msg = 'must be run from inside a valid module (no metadata.json found)' allow(PDK::CLI::Util).to receive(:ensure_in_module!).with(any_args).and_raise(PDK::CLI::ExitWithError, msg) allow(PDK).to rec...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/support/hash_with_defaults_including.rb
Ruby
apache-2.0
231
main
835
# Similar to RSpec’s built-in #hash_including, but does not require the keys of # `expected` to be present in `actual` -- what matters is that for all keys in # `expected`, the value in `actual` and `expected` is the same. # # hash = Hash.new { |hash, key| 9000 } # moo(hash) # # This passes: # # expect(some...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/support/packaged_install.rb
Ruby
apache-2.0
231
main
643
RSpec.shared_context 'packaged install' do let(:package_cachedir) { '/package/share/cache' } before do allow(PDK::Util).to receive_messages(package_install?: true, package_cachedir:) allow(PDK::Util::Filesystem).to receive(:file?).with(/PDK_VERSION/).and_return(true) allow(PDK::Util::Filesystem).to rec...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/support/exit_with_status.rb
Ruby
apache-2.0
231
main
652
RSpec::Matchers.define(:exit_with_status) do |expected_status| supports_block_expectations match do |block| expectation_passed = false begin block.call rescue SystemExit => e expectation_passed = values_match?(expected_status, e.status) rescue StandardError nil end expec...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/support/it_accepts_metadata_json_targets.rb
Ruby
apache-2.0
231
main
219
RSpec.shared_examples_for 'it accepts metadata.json targets' do describe '.pattern' do it 'matches metadata.json in the root' do expect(described_class.pattern).to include('metadata.json') end end end
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk_spec.rb
Ruby
apache-2.0
231
main
3,138
require 'spec_helper' require 'pdk' describe PDK do describe '.logger', use_stubbed_logger: false do subject { described_class.logger } it { is_expected.to be_an_instance_of(described_class::Logger) } end describe '.config' do subject(:config) { described_class.config } it { is_expected.to be_...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/validate_spec.rb
Ruby
apache-2.0
231
main
3,714
require 'spec_helper' require 'pdk/validate' describe PDK::Validate do before do # Remove any memoized variables described_class.instance_variable_set(:@validator_hash, nil) end describe '#validators' do it 'is not empty' do expect(described_class.validators).not_to be_empty end it 'a...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/bolt_spec.rb
Ruby
apache-2.0
231
main
2,173
require 'spec_helper' require 'pdk/util' describe PDK::Bolt do describe '.bolt_project_root?' do # We use NUL here because that should never be a valid directory name. But it will work with RSpec mocking. let(:test_path) { '\x00path/test' } before do allow(PDK::Util::Filesystem).to receive(:file?)...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/logger_spec.rb
Ruby
apache-2.0
231
main
1,134
require 'spec_helper' require 'pdk/logger' describe PDK::Logger do subject(:pdk_logger) { described_class.new } context 'by default' do it 'prints info messages to stdout' do expect($stderr).to receive(:write).with(a_string_matching(/test message/)) pdk_logger.info('test message') end it...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/control_repo_spec.rb
Ruby
apache-2.0
231
main
4,682
require 'spec_helper' require 'pdk/util' describe PDK::ControlRepo do RSpec.shared_examples 'a discoverable control repo' do before do allow(PDK::Util).to receive(:find_upwards).with('environment.conf').and_return(environment_path) allow(described_class).to receive(:control_repo_root?).and_return(con...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/report_spec.rb
Ruby
apache-2.0
231
main
5,013
require 'spec_helper' require 'pdk/report' describe PDK::Report do ['junit', 'text'].each do |report_format| it "can format the report as #{report_format}" do expect(described_class.formats).to include(report_format) expect(subject).to respond_to("write_#{report_format}") end end it 'default...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/template_spec.rb
Ruby
apache-2.0
231
main
1,725
require 'spec_helper' require 'pdk/template' describe PDK::Template do let(:pdk_context) { PDK::Context::None.new(nil) } let(:template_uri) { PDK::Util::TemplateURI.new(PDK::Util::TemplateURI::PDK_TEMPLATE_URL) } describe '.with' do context 'when not passed a block' do it 'raises an ArgumentError' do ...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util_spec.rb
Ruby
apache-2.0
231
main
21,620
require 'spec_helper' require 'pdk/util' describe PDK::Util do let(:pdk_version) { '1.2.3' } let(:template_url) { 'metadata-templates' } let(:template_ref) { nil } let(:mock_metadata) do instance_double( PDK::Module::Metadata, data: { 'pdk-version' => pdk_version, 'template-url'...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/cli_spec.rb
Ruby
apache-2.0
231
main
2,564
require 'spec_helper' require 'pdk/cli' def deprecated_runtime? Gem::Version.new(RbConfig::CONFIG['ruby_version']) < Gem::Version.new('2.4.0') end describe PDK::CLI do context 'when invoking help' do it 'outputs basic help' do expect($stdout).to receive(:puts).with(a_string_matching(/NAME.*USAGE.*DESCRI...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/config_spec.rb
Ruby
apache-2.0
231
main
18,231
require 'spec_helper' require 'securerandom' require 'tty/prompt/test' require 'pdk/config' describe PDK::Config do subject(:config) { described_class.new } include_context 'mock configuration' def mock_file(path, content) allow(PDK::Util::Filesystem).to receive(:file?).with(PDK::Util::Filesystem.expand_pa...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/context_spec.rb
Ruby
apache-2.0
231
main
11,864
require 'spec_helper' require 'pdk/context' require 'tmpdir' require 'fileutils' class MockContext < PDK::Context::AbstractContext def initialize(context_path, prefix, parent_context = nil) # rubocop:disable Lint/MissingSuper @prefix = prefix @parent_context = parent_context @root_path = context_path e...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/vendored_file_spec.rb
Ruby
apache-2.0
231
main
4,315
require 'spec_helper' require 'net/https' require 'pdk/util/vendored_file' describe PDK::Util::VendoredFile do describe '#read' do subject(:vendored_file_read) { described_class.new(file_name, url).read } let(:url) { 'https://test.com/test_file' } let(:file_name) { 'test_file' } let(:package_cached...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/ruby_version_spec.rb
Ruby
apache-2.0
231
main
6,567
require 'spec_helper' require 'pdk/util/ruby_version' describe PDK::Util::RubyVersion do let(:instance) { described_class.new } shared_context 'is a package install' do let(:pdk_package_basedir) do File.join('/', 'path', 'to', 'pdk') end let(:package_cachedir) do File.join(pdk_package_bas...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/version_spec.rb
Ruby
apache-2.0
231
main
1,816
require 'spec_helper' require 'pdk/util/version' describe PDK::Util::Version do context 'Getting the version_string' do subject(:version_string) { described_class.version_string } it { is_expected.not_to be_nil } end context 'when running from a checkout' do before do allow(PDK::Util).to rece...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/changelog_generator_spec.rb
Ruby
apache-2.0
231
main
8,040
require 'spec_helper' require 'pdk/util/changelog_generator' describe PDK::Util::ChangelogGenerator do describe '#generate_changelog' do let(:command) { double(PDK::CLI::Exec::InteractiveCommand, :context= => nil) } # rubocop:disable RSpec/VerifiedDoubles let(:command_stdout) { 'Success' } let(:command_e...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/puppet_version_spec.rb
Ruby
apache-2.0
231
main
12,822
require 'spec_helper' require 'pdk/util/puppet_version' require 'json' describe PDK::Util::PuppetVersion do let(:cache_versions) do ['6.29.0', '7.23.0'] end let(:rubygems_versions) do ['7.23.0', '6.29.0'] end shared_context 'with a mocked rubygems response' do before do mock_fetcher = ins...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/git_spec.rb
Ruby
apache-2.0
231
main
4,726
require 'spec_helper' require 'pdk/util/git' describe PDK::Util::Git do before do described_class.clear_cached_information end describe '.repo?' do subject { described_class.repo?(maybe_repo) } let(:maybe_repo) { 'pdk-templates' } context 'when maybe_repo is a directory' do before do ...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/env_spec.rb
Ruby
apache-2.0
231
main
2,311
require 'spec_helper' require 'pdk/util/env' require 'securerandom' def on_windows Gem.win_platform? end describe PDK::Util::Env do before do ENV[env_name] = env_val end after do ENV.delete(env_name) end let(:env_name) { "#{SecureRandom.hex(10)}ABCabc" } let(:env_val) { 'PDK::Util::Env test va...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/bundler_spec.rb
Ruby
apache-2.0
231
main
22,015
require 'spec_helper' require 'pdk/util/bundler' RSpec.describe PDK::Util::Bundler do describe 'class methods' do # Default to non-package install include_context 'not packaged install' let(:gemfile) { '/Gemfile' } let(:gemfile_lock) { "#{gemfile}.lock" } let(:bundle_helper) do instance_do...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/filesystem_spec.rb
Ruby
apache-2.0
231
main
3,236
require 'spec_helper' require 'pdk/util/filesystem' require 'stringio' describe PDK::Util::Filesystem do describe '.read_file' do subject(:read_file) { described_class.read_file(path, nil_on_error:) } let(:path) { File.join('path', 'to', 'my', 'file') } let(:nil_on_error) { false } context 'when gi...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/template_uri_spec.rb
Ruby
apache-2.0
231
main
22,711
require 'spec_helper' require 'pdk/util/template_uri' require 'addressable' describe PDK::Util::TemplateURI do subject(:template_uri) do described_class.new(opts_or_uri) end include_context 'mock configuration' before do PDK.config.set(['user', 'module_defaults', 'template-url'], nil) allow(PDK::...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/util/puppet_strings_spec.rb
Ruby
apache-2.0
231
main
7,116
require 'spec_helper' require 'pdk/util/puppet_strings' describe PDK::Util::PuppetStrings do describe '.puppet' do before do allow(PDK::Util::Bundler).to receive(:ensure_binstubs!).with('puppet') allow(PDK::Util).to receive(:module_root).and_return(module_root) allow(PDK::Util::RubyVersion).to ...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/report/event_spec.rb
Ruby
apache-2.0
231
main
14,685
require 'spec_helper' require 'pdk/report/event' describe PDK::Report::Event do subject { event } let(:junit_event) { event.to_junit } let(:event) { described_class.new(default_data.merge(data)) } let(:default_data) do { file: 'testfile.rb', source: 'test-validator', state: :passed }...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/module/convert_spec.rb
Ruby
apache-2.0
231
main
28,819
require 'spec_helper' require 'set' require 'pdk/module/convert' describe PDK::Module::Convert do let(:module_root) { File.join('path', 'to', 'module') } let(:pdk_context) { PDK::Context::Module.new(module_root, module_root) } def module_path(relative_path) File.join(module_root, relative_path) end sha...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/module/release_spec.rb
Ruby
apache-2.0
231
main
15,568
require 'spec_helper' require 'pdk/module/release' require 'puppet/modulebuilder' require 'puppet_forge' describe PDK::Module::Release do let(:module_path) { nil } let(:options) { {} } let(:instance) { described_class.new(module_path, options) } let(:module_root) { '/path/somewhere' } let(:metadata_hash) do ...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/module/update_spec.rb
Ruby
apache-2.0
231
main
14,234
require 'spec_helper' require 'pdk/module/update' describe PDK::Module::Update do let(:module_root) { File.join('path', 'to', 'update') } let(:options) { {} } let(:mock_metadata) do instance_double( PDK::Module::Metadata, data: { 'name' => 'mock-module', 'template-url' => template...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/module/update_manager_spec.rb
Ruby
apache-2.0
231
main
9,023
require 'spec_helper' require 'pdk/module/update_manager' describe PDK::Module::UpdateManager do subject(:update_manager) { described_class.new } let(:dummy_file) { File.join(Dir.pwd, 'test_file') } describe '#initialize' do it 'has no pending changes by default' do expect(update_manager).not_to be_c...
github
puppetlabs/pdk
https://github.com/puppetlabs/pdk
spec/unit/pdk/module/metadata_spec.rb
Ruby
apache-2.0
231
main
9,026
require 'spec_helper' require 'pdk/module/metadata' describe PDK::Module::Metadata do describe '.from_file' do let(:metadata_json_path) { '/tmp/metadata.json' } let(:metadata_json_content) do { 'name' => 'foo-bar', 'version' => '0.1.0' }.to_json end before do allow(...