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
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
ruby_basics/9_debugging/exercises/debugging_exercises.rb
Ruby
mit
308
main
1,883
# First, we're going to practice reading the Stack Trace # Don't look at this method prior to running the test # Type 'rspec' into the terminal to run Rspec # Once this test fails, have a look at the Stack Trace # Try to see if you can work your way from the last line, the bottom of the stack # To the top, the first li...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
ruby_basics/6_arrays/spec/array_exercises_spec.rb
Ruby
mit
308
main
4,660
require 'spec_helper' require_relative '../exercises/array_exercises' RSpec.describe 'Array Exercises' do describe 'nil array exercise' do it 'returns an array containing 5 nil values' do expect(nil_array(5)).to eq([nil, nil, nil, nil, nil]) end # remove the 'x' from the line below to unskip the ...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
ruby_basics/6_arrays/exercises/array_exercises.rb
Ruby
mit
308
main
1,384
def nil_array(number) # return an array containing `nil` the given number of times end def first_element(array) # return the first element of the array end def third_element(array) # return the third element of the array end def last_three_elements(array) # return the last 3 elements of the array end def ad...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
recursion/4_permutations/exercises/permutation_exercises.rb
Ruby
mit
308
main
745
def permutations(array) # Write a method that takes in an array of integers and returns an array of # all possible permutations of the original array. The permutations of a set # are the different ways the elements can be arranged. # # For simplicity, the integers are guaranteed to not repeat. # # Example...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
recursion/4_permutations/spec/permutation_exercises_spec.rb
Ruby
mit
308
main
1,180
require 'spec_helper' require_relative '../exercises/permutation_exercises' RSpec.describe '#permutations' do it "returns 1 possible permutation for a set containing 0 numbers" do expect(permutations([])).to eq [[]] end xit "returns 2 possible permutations for a set containing 2 numbers" do expect(permu...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
recursion/3_total_integers/exercises/total_integers_exercises.rb
Ruby
mit
308
main
443
def total_integers(array) # Count the total number of integers inside of the given array # The array may be nested, and the integers inside these "inner" layers must also be counted # # Example: `total_integers([0, 1, [5]]) == 3` # # NOTE: you may notice that `Array#flatten` would make quick work of this, ...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
recursion/3_total_integers/spec/total_integers_exercises_spec.rb
Ruby
mit
308
main
1,927
require 'spec_helper' require_relative '../exercises/total_integers_exercises' RSpec.describe '#total_integers' do # This shared context ensures that the solution uses recursion # and doesn't take a shortcut by using Array#flatten shared_context 'array that should not use flatten' do before do allow(te...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
recursion/2_contains/exercises/contains_exercises.rb
Ruby
mit
308
main
301
def contains?(hash, search_value) # Write a method that recursively searches for a value in a nested hash. # It should return `true` if the object contains that value. # # Examples: # contains?({ foo: { bar: "baz" } }, "baz") # true # contains?({ foo: { bar: "baz" } }, "egg") # false end
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
recursion/2_contains/spec/contains_spec.rb
Ruby
mit
308
main
1,237
require_relative "../exercises/contains_exercises" describe "#contains?" do let(:nested_hash) do { data: { duplicate: "e", stuff: { thing: { banana: "banana", more_stuff: { something: "foo" } } }, info: { ...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
recursion/5_pascal/exercises/pascal_exercises.rb
Ruby
mit
308
main
766
def pascal(row_number) # Pascal's triangle is modeled as follows: # - The first row is `1`. # - Each row can be considered to have a hidden `0` to either sides of it. So the first row could also be said to be `0, 1, 0` # - To obtain the next row, we take each number and add it with its rightmost neighbor. # ...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
recursion/5_pascal/spec/pascal_exercises_spec.rb
Ruby
mit
308
main
825
require 'spec_helper' require_relative '../exercises/pascal_exercises' RSpec.describe '#pascal' do it 'gets the first row of the pascal triangle' do expect(pascal(1)).to eq([1]) end xit 'gets the second row of the pascal triangle' do expect(pascal(2)).to eq([1, 1]) end xit 'gets the third row of th...
github
TheOdinProject/ruby-exercises
https://github.com/TheOdinProject/ruby-exercises
recursion/1_factorial/spec/factorial_spec.rb
Ruby
mit
308
main
628
require "spec_helper" require_relative "../exercises/factorial" RSpec.describe "Factorial" do describe "factorial exercise" do it "returns 1 when passed the number 1" do expect(factorial(1)).to eq(1) end xit "returns 24 when passed the number 4" do expect(factorial(4)).to eq(24) end ...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
Rakefile
Ruby
mit
307
master
652
#!/usr/bin/env rake require "bundler/setup" require "bundler/gem_tasks" require "appraisal" begin # RSpec 2 require "rspec/core/rake_task" RSpec::Core::RakeTask.new do |t| t.pattern = "spec/**/*_spec.rb" t.rspec_opts = "--color --format documentation --backtrace" end rescue LoadError # RSpec 1 ...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
Appraisals
Ruby
mit
307
master
258
version_info = RUBY_VERSION.split(".") major = version_info.first.to_i minor = version_info[1].to_i hotfix = version_info.last.to_i appraise "rails-6.1" do gem "activerecord", "~> 6.1.0" end appraise "rails-7.0" do gem "activerecord", "~> 7.0.0" end
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
google-authenticator.gemspec
Ruby
mit
307
master
1,513
# -*- encoding: utf-8 -*- require File.expand_path('../lib/google-authenticator-rails/version', __FILE__) version_info = RUBY_VERSION.split(".") major = version_info.first.to_i minor = version_info[1].to_i hotfix = version_info.last.to_i Gem::Specification.new do |gem| gem.authors = ["Jared McFarland"] g...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
spec/google_authenticator_spec.rb
Ruby
mit
307
master
10,462
require 'spec_helper' describe GoogleAuthenticatorRails do def get_secret 'LMFMFDV3UGN7LBO4FEMVQVJOK7F7FLLE' end describe '#generate_password' do subject { GoogleAuthenticatorRails::generate_password(get_secret, counter) } context 'counter = 1' do let(:counter) { 1 } it { should == "664...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
spec/spec_helper.rb
Ruby
mit
307
master
3,845
ENV['RAILS_ENV'] = 'test' require 'time' require 'rails' require 'active_record' require 'action_controller' require 'rotp' require 'bundler' require 'bundler/setup' require 'simplecov' SimpleCov.start require 'google-authenticator-rails' module MockControllerBase def self.included(klass) klass.class_eval do ...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
spec/session/persistance_spec.rb
Ruby
mit
307
master
2,365
require 'spec_helper' describe GoogleAuthenticatorRails::Session::Base do let(:controller) { MockController.new } let(:user) { User.create(:password => "password", :email => "email@example.com") } # Instantiate the controller so it activates UserSession before { controller.send(:activate_google_authen...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
spec/session/activation_spec.rb
Ruby
mit
307
master
1,732
require 'spec_helper' describe GoogleAuthenticatorRails::Session::Base do describe 'ClassMethods' do context 'thread safety' do let(:thread_count) { 100 } let(:controllers) { thread_count.times.map { MockController.new } } let(:threads) do controllers.map do |controller| Thre...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
spec/action_controller/integration_spec.rb
Ruby
mit
307
master
1,192
require 'spec_helper' describe GoogleAuthenticatorRails::ActionController::Integration do describe '::included' do context 'ApplicationController already defined' do # Autoload ApplicationController. before { ApplicationController } subject { lambda { MockControllerWithApplicationController.se...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
spec/action_controller/rails_adapter_spec.rb
Ruby
mit
307
master
355
require 'spec_helper' describe GoogleAuthenticatorRails::ActionController::RailsAdapter do describe '#cookies' do let(:controller) { MockController.new } let(:adapter) { GoogleAuthenticatorRails::ActionController::RailsAdapter.new(controller) } after { adapter.cookies } specify { controller.s...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
lib/google-authenticator-rails.rb
Ruby
mit
307
master
2,067
# Stuff the gem requires # require 'active_support' require 'active_record' require 'openssl' require 'rotp' require 'rqrcode' # Stuff the gem is # GOOGLE_AUTHENTICATOR_RAILS_PATH = File.dirname(__FILE__) + "/google-authenticator-rails/" [ "version", "action_controller", "active_record", "session" ].each do ...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
lib/tasks/google_authenticator.rake
Ruby
mit
307
master
2,661
namespace :google_authenticator do def do_encrypt(args, already_encrypted, op_name) model_names = if args[:optional_model_list] args.extras.unshift(args[:optional_model_list]) else # Adapted from https://stackoverflow.com/a/8248849/7478194 ...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
lib/google-authenticator-rails/session.rb
Ruby
mit
307
master
220
SESSION_GOOGLE_AUTHENTICATOR_RAILS_PATH = GOOGLE_AUTHENTICATOR_RAILS_PATH + "session/" [ "activation", "persistence", "base" ].each do |library| require SESSION_GOOGLE_AUTHENTICATOR_RAILS_PATH + library end
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
lib/google-authenticator-rails/action_controller/rails_adapter.rb
Ruby
mit
307
master
1,532
module GoogleAuthenticatorRails module ActionController class RailsAdapter class LoadedTooLateError < StandardError def initialize super("GoogleAuthenticatorRails is trying to prepend a before_filter in ActionController::Base. Because you've already defined" + " ApplicationContr...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
lib/google-authenticator-rails/session/base.rb
Ruby
mit
307
master
1,150
module GoogleAuthenticatorRails module Session # This is where the heart of the session control logic works. # GoogleAuthenticatorRails works in the same way as Authlogic. It assumes that you've created a class based on # GoogleAuthenticatorRails::Session::Base with the name of the model you want to au...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
lib/google-authenticator-rails/session/activation.rb
Ruby
mit
307
master
1,344
module GoogleAuthenticatorRails module Session module Activation class ControllerMissingError < StandardError; end def self.included(klass) klass.class_eval do extend ClassMethods include InstanceMethods end end end module ClassMethods # Eve...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
lib/google-authenticator-rails/session/persistence.rb
Ruby
mit
307
master
2,204
module GoogleAuthenticatorRails module Session module Persistence class TokenNotFound < StandardError; end def self.included(klass) klass.class_eval do extend ClassMethods include InstanceMethods end end end module ClassMethods def find ...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
lib/google-authenticator-rails/active_record/helpers.rb
Ruby
mit
307
master
3,574
module GoogleAuthenticatorRails # :nodoc: mattr_accessor :secret_encryptor module ActiveRecord # :nodoc: module Helpers # Returns and memoizes the plain text google secret for this instance, irrespective of the # name of the google secret storage column and whether secret encryption is enabled fo...
github
jaredonline/google-authenticator
https://github.com/jaredonline/google-authenticator
lib/google-authenticator-rails/active_record/acts_as_google_authenticated.rb
Ruby
mit
307
master
5,468
module GoogleAuthenticatorRails # :nodoc: module ActiveRecord # :nodoc: module ActsAsGoogleAuthenticated # :nodoc: def self.included(base) base.extend ClassMethods end # This is the single integration point. Monkey patch ActiveRecord::Base # to include the ActsAsGoogleAuthenticat...
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
rspec_junit_formatter.gemspec
Ruby
mit
307
main
1,092
Gem::Specification.new do |s| s.name = "rspec_junit_formatter" s.version = "0.6.0" s.platform = Gem::Platform::RUBY s.author = "Samuel Cochran" s.email = "sj26@sj26.com" s.homepage = "https://github.com/sj26/rspec_junit_formatter" s.summary = "RSpec JUnit XML formatter" s...
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
Appraisals
Ruby
mit
307
main
890
appraise "rspec-2-x" do gem "rspec", "~> 2.14", "< 2.99" gem "rake", "~> 10.0" # Rake.last_comment end appraise "rspec-3-0" do gem "rspec", "~> 3.0.0" gem "rake", "~> 10.0" # Rake.last_comment end appraise "rspec-3-1" do gem "rspec", "~> 3.1.0" gem "rake", "~> 10.0" # Rake.last_comment end appraise "rspe...
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
Rakefile
Ruby
mit
307
main
219
require "bundler/gem_tasks" require "appraisal" require "rspec/core/rake_task" RSpec::Core::RakeTask.new(:spec) task :default => :spec if !ENV["APPRAISAL_INITIALIZED"] && !ENV["CI"] task :default => :appraisal end
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
example/spec/spec_helper.rb
Ruby
mit
307
main
342
RSpec.configure do |config| # register around filter that captures stderr and stdout config.around(:each) do |example| $stdout = StringIO.new $stderr = StringIO.new example.run example.metadata[:stdout] = $stdout.string example.metadata[:stderr] = $stderr.string $stdout = STDOUT $stde...
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
example/spec/shared_examples.rb
Ruby
mit
307
main
206
shared_examples "shared examples" do context "in a shared example" do it "succeeds" do expect(true).to be(true) end it "also fails" do expect(false).to be(true) end end end
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
example/spec/example_spec.rb
Ruby
mit
307
main
1,065
require "spec_helper" require_relative "shared_examples" describe "some example specs" do it "should succeed" do expect(true).to be(true) end it "should fail" do expect(false).to be(true) end it "should raise" do raise ArgumentError end it "should be pending" do if defined? skip ...
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
spec/rspec_junit_formatter_spec.rb
Ruby
mit
307
main
6,517
require "pty" require "stringio" require "nokogiri" require "rspec_junit_formatter" describe RspecJunitFormatter do TMP_DIR = File.expand_path("../../tmp", __FILE__) EXAMPLE_DIR = File.expand_path("../../example", __FILE__) before(:all) { ENV.delete("TEST_ENV_NUMBER") } # Make sure this doesn't exist by default...
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
lib/rspec_junit_formatter.rb
Ruby
mit
307
main
5,986
# frozen_string_literal: true require "socket" require "time" require "rspec/core" require "rspec/core/formatters/base_formatter" # Dumps rspec results as a JUnit XML file. # Based on XML schema: http://windyroad.org/dl/Open%20Source/JUnit.xsd class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter # rs...
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
lib/rspec_junit_formatter/rspec2.rb
Ruby
mit
307
main
1,940
# frozen_string_literal: true class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter attr_reader :started def start(example_count) @started = Time.now super end def dump_summary(duration, example_count, failure_count, pending_count) super xml_dump end private def result_of(e...
github
sj26/rspec_junit_formatter
https://github.com/sj26/rspec_junit_formatter
lib/rspec_junit_formatter/rspec3.rb
Ruby
mit
307
main
4,302
# frozen_string_literal: true class RSpecJUnitFormatter < RSpec::Core::Formatters::BaseFormatter RSpec::Core::Formatters.register self, :start, :stop, :dump_summary def start(notification) @start_notification = notification @started = Time.now super end def stop(notification) @exa...
github
davidesantangelo/webinspector
https://github.com/davidesantangelo/webinspector
webinspector.gemspec
Ruby
mit
307
master
1,943
# frozen_string_literal: true lib = File.expand_path('lib', __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require File.expand_path('lib/web_inspector/version', __dir__) Gem::Specification.new do |spec| spec.name = 'webinspector' spec.version = WebInspector::VERSION spec.authors...
github
davidesantangelo/webinspector
https://github.com/davidesantangelo/webinspector
lib/web_inspector.rb
Ruby
mit
307
master
304
# frozen_string_literal: true require File.expand_path(File.join(File.dirname(__FILE__), 'web_inspector/page')) require File.expand_path(File.join(File.dirname(__FILE__), 'web_inspector/version')) module WebInspector module_function def new(url, options = {}) Page.new(url, options) end end
github
davidesantangelo/webinspector
https://github.com/davidesantangelo/webinspector
lib/web_inspector/page.rb
Ruby
mit
307
master
10,380
# frozen_string_literal: true require 'nokogiri' require 'uri' require 'open-uri' require 'open_uri_redirections' require 'faraday' require 'public_suffix' # Explicitly load Faraday::Retry if available begin require 'faraday/retry' rescue LoadError # Faraday retry is not available end require File.expand_path(Fi...
github
davidesantangelo/webinspector
https://github.com/davidesantangelo/webinspector
lib/web_inspector/meta.rb
Ruby
mit
307
master
2,500
# frozen_string_literal: true module WebInspector class Meta def initialize(page) @page = page end def meta_tags { 'name' => meta_tags_by('name'), 'http-equiv' => meta_tags_by('http-equiv'), 'property' => meta_tags_by('property'), 'charset' => [charset_from_me...
github
davidesantangelo/webinspector
https://github.com/davidesantangelo/webinspector
lib/web_inspector/request.rb
Ruby
mit
307
master
1,090
# frozen_string_literal: true require 'addressable/uri' module WebInspector class Request def initialize(url) @url = url end def url normalized_uri end def host uri.host end def domain suffix_domain end def scheme uri.scheme end def port...
github
davidesantangelo/webinspector
https://github.com/davidesantangelo/webinspector
lib/web_inspector/inspector.rb
Ruby
mit
307
master
16,317
# frozen_string_literal: true require File.expand_path(File.join(File.dirname(__FILE__), 'meta')) module WebInspector class Inspector attr_reader :page, :url, :host, :meta def initialize(page) @page = page @meta = WebInspector::Meta.new(page).meta @base_url = nil end def set_url(...
github
davidesantangelo/webinspector
https://github.com/davidesantangelo/webinspector
spec/webinspector_spec.rb
Ruby
mit
307
master
9,191
# frozen_string_literal: true require 'spec_helper' describe WebInspector do let(:url) { 'http://www.example.com' } let(:google_url) { 'http://www.google.com' } it 'has a version number' do expect(WebInspector::VERSION).not_to be nil end it 'should receive response code 200' do page = WebInspector...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
pharos-cluster.gemspec
Ruby
apache-2.0
307
master
2,050
lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "pharos/version" files = Dir['README.md', 'LICENSE', 'licenses/*', 'bin/*', 'lib/**/*', 'addons/**/*'] require_paths = ['lib'] Gem::Specification.new do |spec| spec.name = "pharos-cluster" spec.vers...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/spec_helper.rb
Ruby
apache-2.0
307
master
5,581
require_relative '../lib/pharos_cluster' require 'fakefs/spec_helpers' require_relative 'support/fixtures_helper' require_relative 'support/exit_with_error_helper' # This file was generated by the `rspec --init` command. Conventionally, all # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. #...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/kubeadm_spec.rb
Ruby
apache-2.0
307
master
3,204
require "pharos/phases/configure_master" describe Pharos::Kubeadm::ConfigGenerator do let(:master) { Pharos::Configuration::Host.new(address: 'test', private_address: 'private', role: 'master') } let(:config_hosts_count) { 1 } let(:config) { Pharos::Config.new( hosts: (1..config_hosts_count).map { |i| Pha...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/config_spec.rb
Ruby
apache-2.0
307
master
10,781
describe Pharos::Config do let(:hosts) { [ { 'address' => '192.0.2.1', 'role' => 'master' }, ] } let(:data) { { 'hosts' => hosts, } } subject { described_class.load(data) } describe '#dig' do let(:data) do { 'hosts' => hosts, 'network' => { 'provider' => 'calico' } ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/up_command_spec.rb
Ruby
apache-2.0
307
master
2,552
describe Pharos::UpCommand do subject { described_class.new('') } describe '#humanize_duration' do it 'formats duration as expected' do expect(subject.humanize_duration(1019)).to eq "16 minutes 59 seconds" expect(subject.humanize_duration(1020)).to eq "17 minutes" expect(subject.humanize_dura...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/yaml_file_spec.rb
Ruby
apache-2.0
307
master
1,756
require 'yaml' describe Pharos::YamlFile do context 'for a yaml file with .yml extension' do subject { described_class.new(fixtures_path('yaml/erb/no_erb.yml')) } it 'returns the plain yaml content' do expect(subject.load).to match hash_including( 'test' => { 'result' => 'success' } ) ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/command_spec.rb
Ruby
apache-2.0
307
master
2,390
describe Pharos::Command do before do allow(ENV).to receive(:[]).with('DEBUG').and_return(nil) allow(ENV).to receive(:[]).and_call_original end subject do Class.new(described_class) do def execute puts "hello" end end end it 'can display help' do expect{subject.run('p...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/version_command_spec.rb
Ruby
apache-2.0
307
master
362
describe Pharos::VersionCommand, if: Pharos.oss? do subject { described_class.new('') } it 'outputs version' do expect{subject.run([])}.to output(/Kontena Pharos:\n.+?version (\S+)/m).to_stdout end context '--version' do it 'outputs version' do expect{subject.run(['--version'])}.to output(/.+?ve...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/kube_stack_spec.rb
Ruby
apache-2.0
307
master
1,655
describe Pharos::Kube::Stack do describe "for a trivial test stack" do let(:client) { instance_double(K8s::Client) } subject do described_class.load('test', fixtures_path('stacks/test')) end it "has the correct name" do expect(subject.name).to eq 'test' end it "has the resource"...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/cluster_manager_spec.rb
Ruby
apache-2.0
307
master
580
describe Pharos::ClusterManager do let(:hosts) do [ Pharos::Configuration::Host.new(address: '1.1.1.1', role: 'master') ] end let(:subject) do described_class.new(Pharos::Config.new( hosts: hosts )) end let(:transport) do instance_double(Pharos::Transport::Base) end before(:each) ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/reset_command_spec.rb
Ruby
apache-2.0
307
master
2,195
describe Pharos::ResetCommand do subject { described_class.new('') } let(:hosts) do [ { address: '10.0.0.1', role: 'master' }, { address: '10.0.0.2', role: 'master' }, { address: '10.0.0.3', role: 'worker' } ] end let(:data) { { hosts: hosts } } let(:config) { Pharos::Config.new(da...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phase_spec.rb
Ruby
apache-2.0
307
master
1,184
require "pharos/phase" describe Pharos::Phase do let(:host) { double(:host) } let(:config) { double(:config) } let(:cluster_context) { {} } let(:subject) { described_class.new(host, config: config, cluster_context: cluster_context) } describe '#worker_pool' do it 'returns FixedThreadPool' do pool ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/host/configurer_spec.rb
Ruby
apache-2.0
307
master
4,976
require 'recursive-open-struct' describe Pharos::Host::Configurer do let(:test_config_class) do Class.new(described_class) do register_config 'test', '1.0.0' register_config 'test', '1.1.0' end end let(:host) { instance_double(Pharos::Configuration::Host) } before do Pharos::Host::Con...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/host/ubuntu/ubuntu_xenial_spec.rb
Ruby
apache-2.0
307
master
1,396
require 'pharos/config' require 'pharos/host/ubuntu/ubuntu_xenial' describe Pharos::Host::UbuntuXenial do let(:host) do host = Pharos::Configuration::Host.new(peer_address: '192.168.100') host.cpu_arch = Pharos::Configuration::CpuArch.new(id: 'amd64') host end let(:ssh) { instance_double(Pharos::Tran...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/command_options/load_config_spec.rb
Ruby
apache-2.0
307
master
3,330
describe Pharos::CommandOptions::LoadConfig do let(:arguments) { [] } subject do Class.new(Pharos::Command) do options :load_config option '--master-only', :flag, 'master only' def config @config ||= load_config(master_only: master_only?) end end.new('').tap do |subject| ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/command_options/tf_json_spec.rb
Ruby
apache-2.0
307
master
1,201
describe Pharos::CommandOptions::TfJson do let(:arguments) { [] } subject do Class.new(Pharos::Command) do options :load_config, :tf_json def config @config ||= load_config end end.new('').tap do |subject| subject.parse(arguments) end end describe '#load_config' do...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/validate_configuration_changes_spec.rb
Ruby
apache-2.0
307
master
945
require 'pharos/config' require 'pharos/phases/validate_configuration_changes' describe Pharos::Phases::ValidateConfigurationChanges do let(:host) { double( :host, address: '10.10.10.2', user: 'root', ssh_key_path: '~/.ssh/id_rsa.pub', container_runtime: 'docker', hostname: 'n...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/label_node_spec.rb
Ruby
apache-2.0
307
master
3,504
require 'pharos/phases/label_node' describe Pharos::Phases::LabelNode do let(:host) { Pharos::Configuration::Host.new(address: '192.0.2.2', labels: { foo: 'bar' } ) } let(:config) { Pharos::Config.new(hosts: [host]) } let(:subject) { described_class.new('localhost', config: config) } let(:kube_client) { inst...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/configure_encryption_secrets_spec.rb
Ruby
apache-2.0
307
master
1,492
require "pharos/phases/configure_secrets_encryption" describe Pharos::Phases::ConfigureSecretsEncryption do let(:master) { Pharos::Configuration::Host.new(address: 'test', private_address: 'private', role: 'master') } let(:host) { Pharos::Configuration::Host.new(role: 'worker') } let(:config) do Pharos::Con...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/gather_facts_spec.rb
Ruby
apache-2.0
307
master
5,435
require 'pharos/phases/gather_facts' describe Pharos::Phases::GatherFacts do let(:host) do Pharos::Configuration::Host.new( address: '192.0.2.1', role: 'master' ) end let(:config) { Pharos::Config.new(hosts: [host]) } let(:ssh) { instance_double(Pharos::Transport::SSH) } subject { descr...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/validate_version_spec.rb
Ruby
apache-2.0
307
master
2,886
describe "Pharos::Phases::ValidateVersion", if: Pharos.oss? do before :all do Pharos::Phases.send(:remove_const, :ValidateVersion) if Pharos::Phases.const_defined?(:ValidateVersion) load File.expand_path(File.join(__dir__, '../../../lib/pharos/phases/validate_version.rb')) end let(:host) { Pharos::Config...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/configure_kubelet_spec.rb
Ruby
apache-2.0
307
master
4,260
require "pharos/host/configurer" require "pharos/phases/configure_kubelet" describe Pharos::Phases::ConfigureKubelet do let(:host_resolvconf) { Pharos::Configuration::ResolvConf.new( nameserver_localhost: false, systemd_resolved_stub: false, ) } let(:host_osrelease) { Pharos::Configuration::OsRelease...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/migrate_master_spec.rb
Ruby
apache-2.0
307
master
318
require 'pharos/phases/migrate_master' describe Pharos::Phases::MigrateMaster do let(:host) { instance_double(Pharos::Configuration::Host) } let(:ssh) { instance_double(Pharos::Transport::SSH) } subject { described_class.new(host) } before do allow(host).to receive(:transport).and_return(ssh) end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/reconfigure_kubelet_spec.rb
Ruby
apache-2.0
307
master
2,637
require "pharos/host/configurer" require "pharos/phases/reconfigure_kubelet" describe Pharos::Phases::ReconfigureKubelet do let(:host) { instance_double(Pharos::Configuration::Host) } let(:ssh) { instance_double(Pharos::Transport::SSH) } subject { described_class.new(host) } before do allow(host).to recei...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/configure_calico_spec.rb
Ruby
apache-2.0
307
master
2,458
require "pharos/phases/configure_calico" describe Pharos::Phases::ConfigureCalico do let(:host) { Pharos::Configuration::Host.new(address: '192.0.2.1') } let(:config_network) { { }} let(:config) { Pharos::Config.new( hosts: [host], network: config_network, addons: {}, etcd: {}, kube...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/join_node_spec.rb
Ruby
apache-2.0
307
master
1,113
require 'pharos/config' require 'pharos/phases/join_node' describe Pharos::Phases::JoinNode do let(:host) do Pharos::Configuration::Host.new( address: '10.10.10.2', user: 'root', ssh_key_path: '~/.ssh/id_rsa.pub', container_runtime: 'docker', hostname: 'node-1' ) end let(:s...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/validate_host_spec.rb
Ruby
apache-2.0
307
master
9,132
require 'pharos/phases/validate_host' describe Pharos::Phases::ValidateHost do let(:network_config) { {} } let(:config) { Pharos::Config.new( hosts: [ Pharos::Configuration::Host.new( address: '192.0.2.1', role: 'master' ), ], network: network_config, ) } l...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/configure_weave_spec.rb
Ruby
apache-2.0
307
master
2,090
require 'pharos/phases/configure_weave' describe Pharos::Phases::ConfigureWeave do let(:config) do double(:config, hosts: [ Pharos::Configuration::Host.new( address: '10.1.1.2' ) ]) end subject { described_class.new(double, config: config) } describe '#configured_password', fakefs...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/configure_client_spec.rb
Ruby
apache-2.0
307
master
1,618
require 'pharos/config' require 'pharos/phases/configure_client' describe Pharos::Phases::ConfigureClient do let(:host) do Pharos::Configuration::Host.new( address: '10.10.10.2', user: 'root', ssh_key_path: '~/.ssh/id_rsa.pub', role: 'master' ) end let(:config) { Pharos::Config.ne...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/upgrade_master_spec.rb
Ruby
apache-2.0
307
master
509
require "pharos/phases/upgrade_master" describe Pharos::Phases::UpgradeMaster do let(:master) { Pharos::Configuration::Host.new(address: 'test') } let(:config) { Pharos::Config.new( hosts: (1..2).map { |i| Pharos::Configuration::Host.new() }, network: {}, addons: {}, etcd: {} ) } let(:c...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/configure_dns_spec.rb
Ruby
apache-2.0
307
master
5,848
require "pharos/kube" require "pharos/phases/configure_dns" describe Pharos::Phases::ConfigureDNS do let(:master) { Pharos::Configuration::Host.new(address: 'test') } let(:config_hosts_count) { 1 } let(:config_dns_replicas) { nil } let(:config) { Pharos::Config.new( hosts: (1..config_hosts_count).map { |...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/phases/migrate_worker_spec.rb
Ruby
apache-2.0
307
master
318
require 'pharos/phases/migrate_worker' describe Pharos::Phases::MigrateWorker do let(:host) { instance_double(Pharos::Configuration::Host) } let(:ssh) { instance_double(Pharos::Transport::SSH) } subject { described_class.new(host) } before do allow(host).to receive(:transport).and_return(ssh) end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/core_ext/string_casing_spec.rb
Ruby
apache-2.0
307
master
2,305
describe Pharos::CoreExt::StringCasing do context 'as a module' do subject { "fooBar".extend(described_class) } it 'underscores a string' do expect(subject.underscore).to eq "foo_bar" end end context 'as a refinement' do using Pharos::CoreExt::StringCasing describe '#underscore' do ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/core_ext/deep_transform_keys_spec.rb
Ruby
apache-2.0
307
master
2,165
describe Pharos::CoreExt::DeepTransformKeys do describe '#deep_transform_keys' do context 'as a module' do subject { { foo: { bar: [ { baz: 1 } ] } } } it 'deep transforms keys' do subject.extend(described_class) expect(subject.deep_transform_keys(&:to_s)).to eq( { 'foo' => {...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/configuration/host_route_spec.rb
Ruby
apache-2.0
307
master
2,329
require 'pharos/config' describe Pharos::Configuration::Route do describe '#self.parse' do { 'default via 192.0.2.1 dev eth0 onlink' => {prefix: 'default', via: '192.0.2.1', dev: 'eth0', options: 'onlink'}, '10.18.0.0/16 dev eth0 proto kernel scope link src 10.18.0.13' => {prefix: '10.18.0.0/16', ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/configuration/cpu_arch_spec.rb
Ruby
apache-2.0
307
master
443
require 'pharos/config' describe Pharos::Configuration::CpuArch do let(:subject) do described_class.new( id: 'amd64' ) end describe '#supported?' do it 'returns true when valid id and version' do expect(subject.supported?).to be_truthy end it 'returns false if invalid version' ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/configuration/host_spec.rb
Ruby
apache-2.0
307
master
6,635
require 'pharos/config' describe Pharos::Configuration::Host do let(:subject) do described_class.new( address: '192.168.100.100', role: 'master', user: 'root' ) end describe '#labels' do context 'for master' do it 'returns external-ip and node role only by default' do ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/terraform/json_parser_spec.rb
Ruby
apache-2.0
307
master
838
require 'pharos/terraform/json_parser' describe Pharos::Terraform::JsonParser do let(:subject) do described_class.new({ pharos_cluster: { value: { hosts: [], addons: {} }, type: ['tuple', {}] } }.to_json) end describe '#valid?' do it 'returns ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/terraform/legacy_json_parser_spec.rb
Ruby
apache-2.0
307
master
1,406
require 'pharos/terraform/legacy_json_parser' describe Pharos::Terraform::LegacyJsonParser do let(:subject) { described_class.new(fixture('terraform/tf.json')) } describe '#hosts' do it 'parses valid terraform json file' do hosts = subject.hosts expect(hosts.size).to eq(4) expect(hosts.sele...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/kubeadm/kubelet_config_spec.rb
Ruby
apache-2.0
307
master
2,928
require "pharos/phases/configure_master" describe Pharos::Kubeadm::KubeletConfig do let(:master) { Pharos::Configuration::Host.new(address: 'test', private_address: 'private', role: 'master') } let(:config_hosts_count) { 1 } let(:config) { Pharos::Config.new( hosts: (1..config_hosts_count).map { |i| Pharo...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/kubeadm/cluster_config_spec.rb
Ruby
apache-2.0
307
master
15,918
require "pharos/phases/configure_master" describe Pharos::Kubeadm::ClusterConfig do let(:master) { Pharos::Configuration::Host.new(address: 'test', private_address: 'private', role: 'master') } let(:config_hosts_count) { 1 } let(:config) { Pharos::Config.new( hosts: (1..config_hosts_count).map { |i| Pharo...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/kubeadm/kubeproxy_config_spec.rb
Ruby
apache-2.0
307
master
1,410
require "pharos/phases/configure_master" describe Pharos::Kubeadm::KubeProxyConfig do let(:master) { Pharos::Configuration::Host.new(address: 'test', private_address: 'private', role: 'master') } let(:config_hosts_count) { 1 } let(:config) { Pharos::Config.new( hosts: (1..config_hosts_count).map { |i| Pha...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/pharos/kubeadm/init_config_spec.rb
Ruby
apache-2.0
307
master
792
require "pharos/phases/configure_master" describe Pharos::Kubeadm::InitConfig do let(:master) { Pharos::Configuration::Host.new(address: 'test', private_address: 'private', role: 'master') } let(:config_hosts_count) { 1 } let(:config) { Pharos::Config.new( hosts: (1..config_hosts_count).map { |i| Pharos::...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
spec/support/fixtures_helper.rb
Ruby
apache-2.0
307
master
228
module FixturesHelper FIXTURES_PATH = File.expand_path('../fixtures', __dir__) def fixtures_path(*joinables) File.join(*[FIXTURES_PATH] + joinables) end def fixture(file) IO.read(fixtures_path(file)) end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
examples/vagrant/ubuntu/Vagrantfile
Ruby
apache-2.0
307
master
1,575
# frozen_string_literal: true # -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
examples/vagrant/centos7/Vagrantfile
Ruby
apache-2.0
307
master
1,426
# frozen_string_literal: true # -*- mode: ruby -*- # vi: set ft=ruby : # All Vagrant configuration is done below. The "2" in Vagrant.configure # configures the configuration version (we support older styles for # backwards compatibility). Please don't change it unless you know what # you're doing. Vagrant.configure("...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos_cluster.rb
Ruby
apache-2.0
307
master
540
# frozen_string_literal: true require "clamp" require_relative "pharos/autoload" require_relative "pharos/version" require_relative "pharos/command" require_relative "pharos/error" require_relative "pharos/root_command" module Pharos KUBE_VERSION = ENV.fetch('KUBE_VERSION') { '1.18.8' } CNI_VERSION = '0.8.7' CO...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/cluster_manager.rb
Ruby
apache-2.0
307
master
5,150
# frozen_string_literal: true require 'pathname' module Pharos class ClusterManager include Pharos::Logging using Pharos::CoreExt::Colorize attr_reader :config, :context def self.phase_dirs @phase_dirs ||= [ File.join(__dir__, 'phases') ] end # @param config [Pharos::C...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/exec_command.rb
Ruby
apache-2.0
307
master
1,954
# frozen_string_literal: true module Pharos class ExecCommand < Pharos::Command using Pharos::CoreExt::Colorize options :filtered_hosts, :tf_json usage "[OPTIONS] -- [COMMANDS] ..." parameter "[COMMAND] ...", "Run command on host" banner "Opens SSH sessions to hosts in the Kontena Pharos cluste...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/yaml_file.rb
Ruby
apache-2.0
307
master
2,306
# frozen_string_literal: true require 'yaml' require 'erb' require_relative 'yaml_file/namespace' require 'yaml/safe_load_stream' module Pharos # Reads YAML files and optionally performs ERB evaluation class YamlFile using YAMLSafeLoadStream ParseError = Class.new(StandardError) attr_reader :content...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/root_command.rb
Ruby
apache-2.0
307
master
997
# frozen_string_literal: true require_relative 'up_command' require_relative 'reset_command' require_relative 'version_command' require_relative 'kubeconfig_command' require_relative 'exec_command' require_relative 'terraform_command' require_relative 'worker_up_command' module Pharos class RootCommand < Pharos::Co...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport.rb
Ruby
apache-2.0
307
master
797
# frozen_string_literal: true require 'net/ssh' require 'net/ssh/proxy/jump' module Pharos module Transport def self.for(host, **options) if host.local? Local.new('localhost', **options) else opts = {} opts[:keys] = [host.ssh_key_path] if host.ssh_key_path opts[:send_...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/worker_up_command.rb
Ruby
apache-2.0
307
master
6,409
# frozen_string_literal: true module Pharos class WorkerUpCommand < Pharos::Command using Pharos::CoreExt::Colorize using Pharos::CoreExt::DeepTransformKeys banner <<~BANNER Initialize a local or remote host as a Pharos cluster worker. #{'Note:'.yellow} - Use #{'pharos exec -r maste...