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
rails/thor
https://github.com/rails/thor
spec/line_editor/readline_spec.rb
Ruby
mit
5,240
main
2,738
require "helper" describe Thor::LineEditor::Readline do before do # Eagerly check Readline availability before mocking Thor::LineEditor::Readline.available? unless defined? ::Readline ::Readline = double("Readline") allow(::Readline).to receive(:completion_append_character=).with(nil) end...
github
rails/thor
https://github.com/rails/thor
spec/line_editor/basic_spec.rb
Ruby
mit
5,240
main
967
require "helper" describe Thor::LineEditor::Basic do describe ".available?" do it "returns true" do expect(Thor::LineEditor::Basic).to be_available end end describe "#readline" do it "uses $stdin and $stdout to get input from the user" do expect($stdout).to receive(:print).with("Enter yo...
github
rails/thor
https://github.com/rails/thor
spec/shell/html_spec.rb
Ruby
mit
5,240
main
1,520
require "helper" describe Thor::Shell::HTML do def shell @shell ||= Thor::Shell::HTML.new end describe "#say" do it "sets the color if specified" do out = capture(:stdout) { shell.say "Wow! Now we have colors!", :green } expect(out.chomp).to eq('<span style="color: green;">Wow! Now we have c...
github
rails/thor
https://github.com/rails/thor
spec/shell/color_spec.rb
Ruby
mit
5,240
main
8,614
require "helper" describe Thor::Shell::Color do def shell @shell ||= Thor::Shell::Color.new end before do allow($stdout).to receive(:tty?).and_return(true) allow(ENV).to receive(:[]).and_return(nil) allow(ENV).to receive(:[]).with("TERM").and_return("ansi") allow_any_instance_of(StringIO).to...
github
rails/thor
https://github.com/rails/thor
spec/shell/basic_spec.rb
Ruby
mit
5,240
main
22,734
# coding: utf-8 require "helper" describe Thor::Shell::Basic do def shell @shell ||= Thor::Shell::Basic.new end describe "#padding" do it "cannot be set to below zero" do shell.padding = 10 expect(shell.padding).to eq(10) shell.padding = -1 expect(shell.padding).to eq(0) end...
github
rails/thor
https://github.com/rails/thor
spec/core_ext/hash_with_indifferent_access_spec.rb
Ruby
mit
5,240
main
3,633
require "helper" require "thor/core_ext/hash_with_indifferent_access" describe Thor::CoreExt::HashWithIndifferentAccess do before do @hash = Thor::CoreExt::HashWithIndifferentAccess.new :foo => "bar", "baz" => "bee", :force => true end it "has values accessible by either strings or symbols" do expect(@h...
github
rails/thor
https://github.com/rails/thor
spec/parser/option_spec.rb
Ruby
mit
5,240
main
9,548
require "helper" require "thor/parser" describe Thor::Option do def parse(key, value) Thor::Option.parse(key, value) end def option(name, options = {}) @option ||= Thor::Option.new(name, options) end describe "#parse" do describe "with value as a symbol" do describe "and symbol is a valid...
github
rails/thor
https://github.com/rails/thor
spec/parser/argument_spec.rb
Ruby
mit
5,240
main
2,220
require "helper" require "thor/parser" describe Thor::Argument do def argument(name, options = {}) @argument ||= Thor::Argument.new(name, options) end describe "errors" do it "raises an error if name is not supplied" do expect do argument(nil) end.to raise_error(ArgumentError, "Argum...
github
rails/thor
https://github.com/rails/thor
spec/parser/options_spec.rb
Ruby
mit
5,240
main
20,587
require "helper" require "thor/parser" describe Thor::Options do def create(opts, defaults = {}, stop_on_unknown = false, exclusives = [], at_least_ones = []) relation = { exclusive_option_names: exclusives, at_least_one_option_names: at_least_ones } opts.each do |key, value| opts[key] ...
github
rails/thor
https://github.com/rails/thor
spec/parser/arguments_spec.rb
Ruby
mit
5,240
main
2,692
require "helper" require "thor/parser" describe Thor::Arguments do def create(opts = {}) arguments = opts.map do |type, default| options = {required: default.nil?, type: type, default: default} Thor::Argument.new(type.to_s, options) end arguments.sort! { |a, b| b.name <=> a.name } @opt =...
github
rails/thor
https://github.com/rails/thor
lib/thor.rb
Ruby
mit
5,240
main
22,514
require_relative "thor/base" class Thor $thor_runner ||= false class << self # Allows for custom "Command" package naming. # # === Parameters # name<String> # options<Hash> # def package_name(name, _ = {}) @package_name = name.nil? || name == "" ? nil : name end # Sets th...
github
rails/thor
https://github.com/rails/thor
lib/thor/util.rb
Ruby
mit
5,240
main
8,930
require "rbconfig" class Thor module Sandbox #:nodoc: end # This module holds several utilities: # # 1) Methods to convert thor namespaces to constants and vice-versa. # # Thor::Util.namespace_from_thor_class(Foo::Bar::Baz) #=> "foo:bar:baz" # # 2) Loading thor files and sandboxing: # # Thor...
github
rails/thor
https://github.com/rails/thor
lib/thor/error.rb
Ruby
mit
5,240
main
2,751
class Thor Correctable = if defined?(DidYouMean::SpellChecker) && defined?(DidYouMean::Correctable) # rubocop:disable Naming/ConstantName Module.new do def to_s super + DidYouMean.formatter.message_for(corrections) end def corrections @corrections ||= self.class.const_get(:Spell...
github
rails/thor
https://github.com/rails/thor
lib/thor/runner.rb
Ruby
mit
5,240
main
9,967
require_relative "../thor" require_relative "group" require "digest/sha2" require "pathname" class Thor::Runner < Thor #:nodoc: map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version def self.banner(command, all = false, subcommand = false) "thor " + command.formatted_usage(self, all, subcomm...
github
rails/thor
https://github.com/rails/thor
lib/thor/group.rb
Ruby
mit
5,240
main
9,237
require_relative "base" # Thor has a special class called Thor::Group. The main difference to Thor class # is that it invokes all commands at once. It also include some methods that allows # invocations to be done at the class method, which are not available to Thor # commands. class Thor::Group class << self # ...
github
rails/thor
https://github.com/rails/thor
lib/thor/actions.rb
Ruby
mit
5,240
main
10,679
require_relative "actions/create_file" require_relative "actions/create_link" require_relative "actions/directory" require_relative "actions/empty_directory" require_relative "actions/file_manipulation" require_relative "actions/inject_into_file" class Thor module Actions attr_accessor :behavior def self.in...
github
rails/thor
https://github.com/rails/thor
lib/thor/shell.rb
Ruby
mit
5,240
main
2,260
require "rbconfig" class Thor module Base class << self attr_writer :shell # Returns the shell used in all Thor classes. If you are in a Unix platform # it will use a colored log, otherwise it will use a basic one without color. # def shell @shell ||= if ENV["THOR_SHELL"] &...
github
rails/thor
https://github.com/rails/thor
lib/thor/command.rb
Ruby
mit
5,240
main
5,192
class Thor class Command < Struct.new(:name, :description, :long_description, :wrap_long_description, :usage, :options, :options_relation, :ancestor_name) FILE_REGEXP = /^#{Regexp.escape(File.dirname(__FILE__))}/ def initialize(name, description, long_description, wrap_long_description, usage, options = nil,...
github
rails/thor
https://github.com/rails/thor
lib/thor/rake_compat.rb
Ruby
mit
5,240
main
2,062
require "rake" require "rake/dsl_definition" class Thor # Adds a compatibility layer to your Thor classes which allows you to use # rake package tasks. For example, to use rspec rake tasks, one can do: # # require 'thor/rake_compat' # require 'rspec/core/rake_task' # # class Default < Thor # ...
github
rails/thor
https://github.com/rails/thor
lib/thor/nested_context.rb
Ruby
mit
5,240
main
294
class Thor class NestedContext def initialize @depth = 0 end def enter push yield ensure pop end def entered? @depth.positive? end private def push @depth += 1 end def pop @depth -= 1 end end end
github
rails/thor
https://github.com/rails/thor
lib/thor/base.rb
Ruby
mit
5,240
main
28,740
require_relative "command" require_relative "core_ext/hash_with_indifferent_access" require_relative "error" require_relative "invocation" require_relative "nested_context" require_relative "parser" require_relative "shell" require_relative "line_editor" require_relative "util" class Thor autoload :Actions, File....
github
rails/thor
https://github.com/rails/thor
lib/thor/line_editor.rb
Ruby
mit
5,240
main
364
require_relative "line_editor/basic" require_relative "line_editor/readline" class Thor module LineEditor def self.readline(prompt, options = {}) best_available.new(prompt, options).readline end def self.best_available [ Thor::LineEditor::Readline, Thor::LineEditor::Basic ...
github
rails/thor
https://github.com/rails/thor
lib/thor/invocation.rb
Ruby
mit
5,240
main
6,088
class Thor module Invocation def self.included(base) #:nodoc: super(base) base.extend ClassMethods end module ClassMethods # This method is responsible for receiving a name and find the proper # class and command for it. The key is an optional parameter which is # available ...
github
rails/thor
https://github.com/rails/thor
lib/thor/parser/argument.rb
Ruby
mit
5,240
main
2,098
class Thor class Argument #:nodoc: VALID_TYPES = [:numeric, :hash, :array, :string] attr_reader :name, :description, :enum, :required, :type, :default, :banner alias_method :human_name, :name def initialize(name, options = {}) class_name = self.class.name.split("::").last type = options...
github
rails/thor
https://github.com/rails/thor
lib/thor/parser/option.rb
Ruby
mit
5,240
main
4,839
class Thor class Option < Argument #:nodoc: attr_reader :aliases, :group, :lazy_default, :hide, :repeatable VALID_TYPES = [:boolean, :numeric, :hash, :array, :string] def initialize(name, options = {}) @check_default_type = options[:check_default_type] options[:required] = false unless optio...
github
rails/thor
https://github.com/rails/thor
lib/thor/parser/options.rb
Ruby
mit
5,240
main
8,771
class Thor class Options < Arguments #:nodoc: LONG_RE = /^(--\w+(?:-\w+)*)$/ SHORT_RE = /^(-[a-z])$/i EQ_RE = /^(--\w+(?:-\w+)*|-[a-z])=(.*)$/i SHORT_SQ_RE = /^-([a-z]{2,})$/i # Allow either -x -v or -xv style for single char args SHORT_NUM = /^(-[a-z])#{NUMERIC}$/i OPTS_END ...
github
rails/thor
https://github.com/rails/thor
lib/thor/parser/arguments.rb
Ruby
mit
5,240
main
4,721
class Thor class Arguments #:nodoc: NUMERIC = /[-+]?(\d*\.\d+|\d+)/ # Receives an array of args and returns two arrays, one with arguments # and one with switches. # def self.split(args) arguments = [] args.each do |item| break if item.is_a?(String) && item =~ /^-/ ar...
github
rails/thor
https://github.com/rails/thor
lib/thor/core_ext/hash_with_indifferent_access.rb
Ruby
mit
5,240
main
2,375
class Thor module CoreExt #:nodoc: # A hash with indifferent access and magic predicates. # # hash = Thor::CoreExt::HashWithIndifferentAccess.new 'foo' => 'bar', 'baz' => 'bee', 'force' => true # # hash[:foo] #=> 'bar' # hash['foo'] #=> 'bar' # hash.foo? #=> true # class...
github
rails/thor
https://github.com/rails/thor
lib/thor/shell/table_printer.rb
Ruby
mit
5,240
main
3,006
require_relative "column_printer" require_relative "terminal" class Thor module Shell class TablePrinter < ColumnPrinter BORDER_SEPARATOR = :separator def initialize(stdout, options = {}) super @formats = [] @maximas = [] @colwidth = options[:colwidth] @trunca...
github
rails/thor
https://github.com/rails/thor
lib/thor/shell/basic.rb
Ruby
mit
5,240
main
11,866
require_relative "column_printer" require_relative "table_printer" require_relative "wrapped_printer" class Thor module Shell class Basic attr_accessor :base attr_reader :padding # Initialize base, mute and padding to nil. # def initialize #:nodoc: @base = nil @mu...
github
rails/thor
https://github.com/rails/thor
lib/thor/shell/terminal.rb
Ruby
mit
5,240
main
1,035
class Thor module Shell module Terminal DEFAULT_TERMINAL_WIDTH = 80 class << self # This code was copied from Rake, available under MIT-LICENSE # Copyright (c) 2003, 2004 Jim Weirich def terminal_width result = if ENV["THOR_COLUMNS"] ENV["THOR_COLUMNS"].t...
github
rails/thor
https://github.com/rails/thor
lib/thor/shell/color.rb
Ruby
mit
5,240
main
3,716
# frozen_string_literal: true require_relative "basic" require_relative "lcs_diff" class Thor module Shell # Inherit from Thor::Shell::Basic and add set_color behavior. Check # Thor::Shell::Basic to see all available methods. # class Color < Basic include LCSDiff # Embed in a String to ...
github
rails/thor
https://github.com/rails/thor
lib/thor/shell/lcs_diff.rb
Ruby
mit
5,240
main
1,189
module LCSDiff protected # Overwrite show_diff to show diff with colors if Diff::LCS is # available. def show_diff(destination, content) #:nodoc: if diff_lcs_loaded? && ENV["THOR_DIFF"].nil? && ENV["RAILS_DIFF"].nil? actual = File.binread(destination).to_s.split("\n") content = content.to_s.spli...
github
rails/thor
https://github.com/rails/thor
lib/thor/shell/html.rb
Ruby
mit
5,240
main
3,175
require_relative "basic" require_relative "lcs_diff" class Thor module Shell # Inherit from Thor::Shell::Basic and add set_color behavior. Check # Thor::Shell::Basic to see all available methods. # class HTML < Basic include LCSDiff # The start of an HTML bold sequence. BOLD ...
github
rails/thor
https://github.com/rails/thor
lib/thor/shell/wrapped_printer.rb
Ruby
mit
5,240
main
1,028
require_relative "column_printer" require_relative "terminal" class Thor module Shell class WrappedPrinter < ColumnPrinter def print(message) width = Terminal.terminal_width - @indent paras = message.split("\n\n") paras.map! do |unwrapped| words = unwrapped.split(" ") ...
github
rails/thor
https://github.com/rails/thor
lib/thor/shell/column_printer.rb
Ruby
mit
5,240
main
773
require_relative "terminal" class Thor module Shell class ColumnPrinter attr_reader :stdout, :options def initialize(stdout, options = {}) @stdout = stdout @options = options @indent = options[:indent].to_i end def print(array) return if array.empty? ...
github
rails/thor
https://github.com/rails/thor
lib/thor/actions/empty_directory.rb
Ruby
mit
5,240
main
4,318
class Thor module Actions # Creates an empty directory. # # ==== Parameters # destination<String>:: the relative path to the destination root. # config<Hash>:: give :verbose => false to not log the status. # # ==== Examples # # empty_directory "doc" # def empty_directory(...
github
rails/thor
https://github.com/rails/thor
lib/thor/actions/create_link.rb
Ruby
mit
5,240
main
1,892
require_relative "create_file" class Thor module Actions # Create a new file relative to the destination root from the given source. # # ==== Parameters # destination<String>:: the relative path to the destination root. # source<String|NilClass>:: the relative path to the source root. # confi...
github
rails/thor
https://github.com/rails/thor
lib/thor/actions/create_file.rb
Ruby
mit
5,240
main
3,253
require_relative "empty_directory" class Thor module Actions # Create a new file relative to the destination root with the given data, # which is the return value of a block or a data string. # # ==== Parameters # destination<String>:: the relative path to the destination root. # data<String|...
github
rails/thor
https://github.com/rails/thor
lib/thor/actions/inject_into_file.rb
Ruby
mit
5,240
main
5,390
require_relative "empty_directory" class Thor module Actions WARNINGS = {unchanged_no_flag: "File unchanged! Either the supplied flag value not found or the content has already been inserted!"} # Injects the given content into a file, raising an error if the contents of # the file are not changed. Diffe...
github
rails/thor
https://github.com/rails/thor
lib/thor/actions/file_manipulation.rb
Ruby
mit
5,240
main
14,583
require "erb" class Thor module Actions # Copies the file from the relative source to the relative destination. If # the destination is not given it's assumed to be equal to the source. # # ==== Parameters # source<String>:: the relative path to the source root. # destination<String>:: the re...
github
rails/thor
https://github.com/rails/thor
lib/thor/actions/directory.rb
Ruby
mit
5,240
main
3,819
require_relative "empty_directory" class Thor module Actions # Copies recursively the files from source directory to root directory. # If any of the files finishes with .tt, it's considered to be a template # and is placed in the destination without the extension .tt. If any # empty directory is foun...
github
rails/thor
https://github.com/rails/thor
lib/thor/line_editor/readline.rb
Ruby
mit
5,240
main
1,838
class Thor module LineEditor class Readline < Basic def self.available? begin require "readline" rescue LoadError end Object.const_defined?(:Readline) end def readline if echo? ::Readline.completion_append_character = nil # ...
github
rails/thor
https://github.com/rails/thor
lib/thor/line_editor/basic.rb
Ruby
mit
5,240
main
628
class Thor module LineEditor class Basic attr_reader :prompt, :options def self.available? true end def initialize(prompt, options) @prompt = prompt @options = options end def readline $stdout.print(prompt) get_input end pri...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
rest-client.windows.gemspec
Ruby
mit
5,217
master
557
# # Gemspec for Windows platforms. We can't put these in the main gemspec because # it results in bundler platform hell when trying to build the gem. # # Set $BUILD_PLATFORM when calling gem build with this gemspec to build for # Windows platforms like x86-mingw32. # s = eval(File.read(File.join(File.dirname(__FILE__),...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
Rakefile
Ruby
mit
5,217
master
3,614
# load `rake build/install/release tasks' require 'bundler/setup' require_relative './lib/restclient/version' namespace :ruby do Bundler::GemHelper.install_tasks(:name => 'rest-client') end require "rspec/core/rake_task" desc "Run all specs" RSpec::Core::RakeTask.new('spec') desc "Run unit specs" RSpec::Core::Rak...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
rest-client.gemspec
Ruby
mit
5,217
master
1,341
# -*- encoding: utf-8 -*- require File.expand_path('../lib/restclient/version', __FILE__) Gem::Specification.new do |s| s.name = 'rest-client' s.version = RestClient::VERSION s.authors = ['REST Client Team'] s.description = 'A simple HTTP and REST client for Ruby, inspired by the Sinatra microframework style ...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/helpers.rb
Ruby
mit
5,217
master
1,647
require 'uri' module Helpers # @param [Hash] opts A hash of methods, passed directly to the double # definition. Use this to stub other required methods. # # @return double for Net::HTTPResponse def res_double(opts={}) instance_double('Net::HTTPResponse', {to_hash: {}, body: 'response body'}.merge(opt...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/spec_helper.rb
Ruby
mit
5,217
master
842
require 'webmock/rspec' require 'rest-client' require_relative './helpers' # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration RSpec.configure do |config| config.raise_errors_for_deprecations! # Run specs in random order to surface order dependencies. If you find an # order dependency and want t...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/payload_spec.rb
Ruby
mit
5,217
master
10,390
# encoding: binary require_relative '_lib' describe RestClient::Payload, :include_helpers do context "Base Payload" do it "should reset stream after to_s" do payload = RestClient::Payload::Base.new('foobar') expect(payload.to_s).to eq 'foobar' expect(payload.to_s).to eq 'foobar' end end ...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/utils_spec.rb
Ruby
mit
5,217
master
5,565
require_relative '_lib' describe RestClient::Utils do describe '.get_encoding_from_headers' do it 'assumes no encoding by default for text' do headers = {:content_type => 'text/plain'} expect(RestClient::Utils.get_encoding_from_headers(headers)). to eq nil end it 'returns nil on fail...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/abstract_response_spec.rb
Ruby
mit
5,217
master
5,880
require_relative '_lib' describe RestClient::AbstractResponse, :include_helpers do # Sample class implementing AbstractResponse used for testing. class MyAbstractResponse include RestClient::AbstractResponse attr_accessor :size def initialize(net_http_res, request) response_set_vars(net_http_...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/exceptions_spec.rb
Ruby
mit
5,217
master
3,733
require_relative '_lib' describe RestClient::Exception do it "returns a 'message' equal to the class name if the message is not set, because 'message' should not be nil" do e = RestClient::Exception.new expect(e.message).to eq "RestClient::Exception" end it "returns the 'message' that was set" do e ...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/params_array_spec.rb
Ruby
mit
5,217
master
1,104
require_relative '_lib' describe RestClient::ParamsArray do describe '.new' do it 'accepts various types of containers' do as_array = [[:foo, 123], [:foo, 456], [:bar, 789], [:empty, nil]] [ [[:foo, 123], [:foo, 456], [:bar, 789], [:empty, nil]], [{foo: 123}, {foo: 456}, {bar: 789}, ...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/request2_spec.rb
Ruby
mit
5,217
master
2,576
require_relative '_lib' describe RestClient::Request, :include_helpers do context 'params for GET requests' do it "manage params for get requests" do stub_request(:get, 'http://some/resource?a=b&c=d').with(:headers => {'Accept'=>'*/*', 'Foo'=>'bar'}).to_return(:body => 'foo', :status => 200) expect(...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/raw_response_spec.rb
Ruby
mit
5,217
master
660
require_relative '_lib' describe RestClient::RawResponse do before do @tf = double("Tempfile", :read => "the answer is 42", :open => true, :rewind => true) @net_http_res = double('net http response') @request = double('restclient request', :redirection_history => nil) @response = RestClient::RawRespo...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/response_spec.rb
Ruby
mit
5,217
master
12,621
require_relative '_lib' describe RestClient::Response, :include_helpers do before do @net_http_res = res_double(to_hash: {'Status' => ['200 OK']}, code: '200', body: 'abc') @example_url = 'http://example.com' @request = request_double(url: @example_url, method: 'get') @response = response_from_res_do...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/resource_spec.rb
Ruby
mit
5,217
master
5,788
require_relative '_lib' describe RestClient::Resource do before do @resource = RestClient::Resource.new('http://some/resource', :user => 'jane', :password => 'mypass', :headers => {'X-Something' => '1'}) end context "Resource delegation" do it "GET" do expect(RestClient::Request).to receive(:execu...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/restclient_spec.rb
Ruby
mit
5,217
master
2,739
require_relative '_lib' describe RestClient do describe "API" do it "GET" do expect(RestClient::Request).to receive(:execute).with(:method => :get, :url => 'http://some/resource', :headers => {}) RestClient.get('http://some/resource') end it "POST" do expect(RestClient::Request).to rec...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/request_spec.rb
Ruby
mit
5,217
master
52,083
require_relative './_lib' describe RestClient::Request, :include_helpers do before do @request = RestClient::Request.new(:method => :put, :url => 'http://some/resource', :payload => 'payload') @uri = double("uri") allow(@uri).to receive(:request_uri).and_return('/resource') allow(@uri).to receive(:h...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/unit/windows/root_certs_spec.rb
Ruby
mit
5,217
master
589
require_relative '../_lib' describe 'RestClient::Windows::RootCerts', :if => RestClient::Platform.windows? do let(:x509_store) { RestClient::Windows::RootCerts.instance.to_a } it 'should return at least one X509 certificate' do expect(x509_store.to_a.size).to be >= 1 end it 'should return an X50...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/integration/request_spec.rb
Ruby
mit
5,217
master
4,290
require_relative '_lib' describe RestClient::Request do before(:all) do WebMock.disable! end after(:all) do WebMock.enable! end describe "ssl verification" do it "is successful with the correct ca_file" do request = RestClient::Request.new( :method => :get, :url => 'https:...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/integration/httpbin_spec.rb
Ruby
mit
5,217
master
3,660
require_relative '_lib' require 'json' require 'zlib' describe RestClient::Request do before(:all) do WebMock.disable! end after(:all) do WebMock.enable! end def default_httpbin_url # add a hack to work around java/jruby bug # java.lang.RuntimeException: Could not generate DH keypair with ...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
spec/integration/integration_spec.rb
Ruby
mit
5,217
master
3,986
# -*- coding: utf-8 -*- require_relative '_lib' require 'base64' describe RestClient do it "a simple request" do body = 'abc' stub_request(:get, "www.example.com").to_return(:body => body, :status => 200) response = RestClient.get "www.example.com" expect(response.code).to eq 200 expect(response...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient.rb
Ruby
mit
5,217
master
5,900
require 'net/http' require 'openssl' require 'stringio' require 'uri' require File.dirname(__FILE__) + '/restclient/version' require File.dirname(__FILE__) + '/restclient/platform' require File.dirname(__FILE__) + '/restclient/exceptions' require File.dirname(__FILE__) + '/restclient/utils' require File.dirname(__FILE...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/abstract_response.rb
Ruby
mit
5,217
master
6,798
require 'cgi' require 'http-cookie' module RestClient module AbstractResponse attr_reader :net_http_res, :request, :start_time, :end_time, :duration def inspect raise NotImplementedError.new('must override in subclass') end # Logger from the request, potentially nil. def log reque...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/utils.rb
Ruby
mit
5,217
master
9,051
require 'http/accept' module RestClient # Various utility methods module Utils # Return encoding from an HTTP header hash. # # We use the RFC 7231 specification and do not impose a default encoding on # text. This differs from the older RFC 2616 behavior, which specifies # using ISO-8859-1 for...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/resource.rb
Ruby
mit
5,217
master
5,491
module RestClient # A class that can be instantiated for access to a RESTful resource, # including authentication. # # Example: # # resource = RestClient::Resource.new('http://some/resource') # jpg = resource.get(:accept => 'image/jpg') # # With HTTP basic authentication: # # resource = Rest...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/params_array.rb
Ruby
mit
5,217
master
2,045
module RestClient # The ParamsArray class is used to represent an ordered list of [key, value] # pairs. Use this when you need to include a key multiple times or want # explicit control over parameter ordering. # # Most of the request payload & parameter functions normally accept a Hash of # keys => values...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/request.rb
Ruby
mit
5,217
master
29,202
require 'tempfile' require 'cgi' require 'netrc' require 'set' begin # Use mime/types/columnar if available, for reduced memory usage require 'mime/types/columnar' rescue LoadError require 'mime/types' end module RestClient # This class is used internally by RestClient to send the request, but you can also ...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/response.rb
Ruby
mit
5,217
master
2,294
module RestClient # A Response from RestClient, you can access the response body, the code or the headers. # class Response < String include AbstractResponse # Return the HTTP response body. # # Future versions of RestClient will deprecate treating response objects # directly as strings, so...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/payload.rb
Ruby
mit
5,217
master
5,581
require 'tempfile' require 'securerandom' require 'stringio' begin # Use mime/types/columnar if available, for reduced memory usage require 'mime/types/columnar' rescue LoadError require 'mime/types' end module RestClient module Payload extend self def generate(params) if params.is_a?(RestClien...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/exceptions.rb
Ruby
mit
5,217
master
7,982
module RestClient # Hash of HTTP status code => message. # # 1xx: Informational - Request received, continuing process # 2xx: Success - The action was successfully received, understood, and # accepted # 3xx: Redirection - Further action must be taken in order to complete the # request # 4xx: ...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/platform.rb
Ruby
mit
5,217
master
1,182
require 'rbconfig' module RestClient module Platform # Return true if we are running on a darwin-based Ruby platform. This will # be false for jruby even on OS X. # # @return [Boolean] def self.mac_mri? RUBY_PLATFORM.include?('darwin') end # Return true if we are running on Windows...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/raw_response.rb
Ruby
mit
5,217
master
1,310
module RestClient # The response from RestClient on a raw request looks like a string, but is # actually one of these. 99% of the time you're making a rest call all you # care about is the body, but on the occasion you want to fetch the # headers you can: # # RestClient.get('http://example.com').headers[...
github
rest-client/rest-client
https://github.com/rest-client/rest-client
lib/restclient/windows/root_certs.rb
Ruby
mit
5,217
master
2,691
require 'openssl' require 'ffi' # Adapted from Puppet, Copyright (c) Puppet Labs Inc, # licensed under the Apache License, Version 2.0. # # https://github.com/puppetlabs/puppet/blob/bbe30e0a/lib/puppet/util/windows/root_certs.rb # Represents a collection of trusted root certificates. # # @api public class RestClient:...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
Gemfile
Ruby
mit
5,212
main
518
# frozen_string_literal: true source 'https://rubygems.org' gemspec # To hack on Cucumber together with any of these libraries, uncomment the line below: # gem 'cucumber-core', path: '../cucumber-ruby-core' # gem 'cucumber-cucumber-expressions', path: '../cucumber-expressions/ruby' # gem 'cucumber-gherkin', path: '....
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
cucumber.gemspec
Ruby
mit
5,212
main
2,430
# frozen_string_literal: true Gem::Specification.new do |s| s.name = 'cucumber' s.version = File.read(File.expand_path('VERSION', __dir__)).strip s.authors = ['Aslak Hellesøy', 'Matt Wynne', 'Steve Tooke', 'Luke Hill'] s.description = 'Behaviour Driven Development with elegance and joy' s.summ...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
Rakefile
Ruby
mit
5,212
main
349
# frozen_string_literal: true $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib") Dir['gem_tasks/**/*.rake'].each { |rake| load rake } require 'rubocop/rake_task' RuboCop::RakeTask.new require 'cucumber/rake/task' Cucumber::Rake::Task.new default_tasks = %i[spec cucumber cck] default_tasks << :examples if ENV['CI']...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
gem_tasks/examples.rake
Ruby
mit
5,212
main
339
# frozen_string_literal: true desc 'Run all examples' task :examples do Dir['examples/*'].each do |example_dir| next unless File.directory?(example_dir) puts "Running #{example_dir}" Dir.chdir(example_dir) do raise "No Rakefile in #{Dir.pwd}" unless File.file?('Rakefile') sh 'rake cucumber'...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
gem_tasks/cck.rake
Ruby
mit
5,212
main
413
# frozen_string_literal: true require 'rspec/core/rake_task' desc 'Run RSpec for the gem against the cucumber compatibility kit' RSpec::Core::RakeTask.new(:cck) do |t| t.verbose = true t.rspec_opts = '--tag cck --pattern compatibility/cck_spec.rb -f d' puts 'Testing CCK proper first' sh 'bundle exec rspec co...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/profile_steps.rb
Ruby
mit
5,212
main
259
# frozen_string_literal: true Given('the following profile(s) is/are defined:') do |profiles| write_file('cucumber.yml', profiles) end Then('the {word} profile should be used') do |profile| expect(command_line.all_output).to include_output(profile) end
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/iso-8859-1_steps.rb
Ruby
mit
5,212
main
556
# encoding: iso-8859-10 # frozen_string_literal: true # Ideally we would use Norwegian keywords here, but that won't work unless this # file is UTF-8 encoded. # Alternatively, it would be possible to use Norwegian keywords and encode the # file as UTF-8. # # In both cases, stepdef arguments will be sent in as UTF-8, r...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/scenarios_and_steps.rb
Ruby
mit
5,212
main
2,664
# frozen_string_literal: true Given('the standard step definitions') do write_file( 'features/step_definitions/steps.rb', [ step_definition('/^this step passes$/', ''), step_definition('/^this step raises an error$/', "raise 'error'"), step_definition('/^this step is pending$/', 'pending'),...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/html_steps.rb
Ruby
mit
5,212
main
205
# frozen_string_literal: true Then('output should be html with title {string}') do |title| document = Nokogiri::HTML.parse(command_line.stdout) expect(document.xpath('//title').text).to eq(title) end
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/cucumber_cli_steps.rb
Ruby
mit
5,212
main
379
# frozen_string_literal: true Then('I should see the CLI help') do expect(command_line.stdout).to include('Usage:') end Then('cucumber lists all the supported languages') do sample_languages = %w[Arabic български Pirate English 日本語] sample_languages.each do |language| expect(command_line.stdout.force_encodi...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/message_steps.rb
Ruby
mit
5,212
main
1,299
# frozen_string_literal: true Then('messages types should be:') do |expected_types| message_types = command_line.stdout(format: :messages).map(&:keys).flatten.compact expect(expected_types.split("\n")).to eq(message_types) end Then('output should be valid NDJSON') do expect { command_line.stdout(format: :messa...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/command_line_steps.rb
Ruby
mit
5,212
main
1,976
# frozen_string_literal: true When('I run `cucumber{}`') do |args| execute_cucumber(args) end When('I run `bundle exec ruby {}`') do |filename| execute_ruby(filename) end When('I run `(bundle exec )rake {word}`') do |task| execute_rake(task) end When('I run the feature with the progress formatter') do execu...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/cucumber_steps.rb
Ruby
mit
5,212
main
1,745
# frozen_string_literal: true Given('a directory without standard Cucumber project directory structure') do FileUtils.cd('.') do FileUtils.rm_rf 'features' if File.directory?('features') end end Given('log only formatter is declared') do write_file('features/support/log_only_formatter.rb', [ 'class LogO...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/filesystem_steps.rb
Ruby
mit
5,212
main
368
# frozen_string_literal: true Given('a directory named {string}') do |path| FileUtils.mkdir_p(path) end Given('a file named {string} with:') do |path, content| write_file(path, content) end Given('an empty file named {string}') do |path| write_file(path, '') end Then('a file named {string} should exist') do |...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/junit_steps.rb
Ruby
mit
5,212
main
282
# frozen_string_literal: true Then('the junit output file {string} should contain:') do |actual_file, text| actual = File.read("#{File.expand_path('.')}/#{actual_file}") actual = remove_self_ref(replace_junit_time(actual)) expect(actual).to be_similar_output_than(text) end
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/step_definitions/json_steps.rb
Ruby
mit
5,212
main
640
# frozen_string_literal: true Then('it should fail with JSON:') do |json| expect(command_line).to have_failed actual = normalise_json(JSON.parse(command_line.stdout)) expected = JSON.parse(json) expect(actual).to eq expected end Then('it should pass with JSON:') do |json| expect(command_line).to have_succe...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/support/step_definitions.rb
Ruby
mit
5,212
main
683
# frozen_string_literal: true module StepDefinitionsWorld def step_definition(expression, content, keyword: 'Given') if content.is_a?(String) one_line_step_definition(keyword, expression, content) else block_step_definition(keyword, expression, content) end end def one_line_step_definiti...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/support/env.rb
Ruby
mit
5,212
main
1,621
# frozen_string_literal: true require 'cucumber/formatter/ansicolor' require 'securerandom' require 'nokogiri' CUCUMBER_FEATURES_PATH = 'features/lib' Before do |scenario| @original_cwd = Dir.pwd # We limit the length to avoid issues on Windows where sometimes the creation # of the temporary directory fails du...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/support/parameter_types.rb
Ruby
mit
5,212
main
427
# frozen_string_literal: true ParameterType( name: 'list', regexp: /.*/, transformer: ->(s) { s.split(/,\s+/) }, use_for_snippets: false ) class ExecutionStatus def initialize(name) @passed = name == 'pass' end def validates?(exit_code) @passed ? exit_code.zero? : exit_code.positive? end end ...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/support/json.rb
Ruby
mit
5,212
main
1,456
# frozen_string_literal: true module JSONWorld def normalise_json(json) json.each do |feature| elements = feature.fetch('elements') { [] } elements.each do |scenario| normalise_scenario_json(scenario) end end end private def normalise_scenario_json(scenario) scenario['st...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/support/feature_factory.rb
Ruby
mit
5,212
main
1,338
# frozen_string_literal: true module FeatureFactory def create_feature(name = generate_feature_name) gherkin = <<~GHERKIN Feature: #{name} #{yield} GHERKIN write_file filename(name), gherkin end def create_feature_ja(name = generate_feature_name) gherkin = <<~GHERKIN # language...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/support/output.rb
Ruby
mit
5,212
main
1,449
# frozen_string_literal: true require 'rspec/expectations' def clean_output(output) output.split("\n").map do |line| next if line.include?(CUCUMBER_FEATURES_PATH) line .gsub(/\e\[([;\d]+)?m/, '') # Drop colors .gsub(/^.*cucumber_process\.rb.*$\n/, '') .gsub(/^\d+m\d+\.\d+...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
features/lib/support/command_line.rb
Ruby
mit
5,212
main
4,095
# frozen_string_literal: true require 'rspec/expectations' require 'rspec/mocks' require 'rake' require 'cucumber/rake/task' class MockKernel attr_reader :exit_status def exit(status) @exit_status = status status unless status.zero? end end class CommandLine include ::RSpec::Mocks::ExampleMethods ...
github
cucumber/cucumber-ruby
https://github.com/cucumber/cucumber-ruby
lib/simplecov_setup.rb
Ruby
mit
5,212
main
512
# frozen_string_literal: true if ENV['SIMPLECOV'] begin # Suppress warnings in order not to pollute stdout which tests expectations rely on $VERBOSE = nil if defined?(JRUBY_VERSION) require 'simplecov' SimpleCov.root(File.expand_path("#{File.dirname(__FILE__)}/..")) SimpleCov.start do add...