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 | basecamp/easymon | https://github.com/basecamp/easymon | app/controllers/easymon/checks_controller.rb | Ruby | mit | 218 | master | 3,295 | require_dependency "easymon/application_controller"
require "benchmark"
module Easymon
class ChecksController < ApplicationController
# Rails 5+ deprecates `before_filter` in favor of `before_action`. Alias
# the latter for forward compatibility.
unless defined?(before_action)
class << self
... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/test_helper.rb | Ruby | mit | 218 | master | 1,204 | # Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require "rails/test_help"
Rails.backtrace_cleaner.remove_silencers!
# Load support files
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
# Load fixtures from the engi... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/controllers/easymon/checks_controller_test.rb | Ruby | mit | 218 | master | 4,122 | require "test_helper"
module Easymon
class ChecksControllerTest < ActionController::TestCase
setup do
@routes = Easymon::Engine.routes
Easymon.authorize_with = nil
end
test "index when no checks are defined" do
get :index
assert_response :service_unavailable
assert_equal "N... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/dummy/config/routes.rb | Ruby | mit | 218 | master | 719 | Rails.application.routes.draw do
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
# Can be used by load balancers and uptime monitors to verify that the app is live.
get... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/dummy/config/application.rb | Ruby | mit | 218 | master | 1,073 | require_relative "boot"
require "rails/all"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
require "easymon"
module Dummy
class Application < Rails::Application
config.load_defaults Rails::VERSION::STRING.to_f
... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/dummy/config/initializers/easymon.rb | Ruby | mit | 218 | master | 463 | if Rails.env.development?
Easymon::Repository.add("redis", Easymon::RedisCheck.new(YAML.load_file(Rails.root.join("config/redis.yml"), aliases: true)[Rails.env].symbolize_keys))
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base), :critical)
Easymon::Repository.add("memcached", ... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/dummy/config/environments/test.rb | Ruby | mit | 218 | master | 2,453 | # The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
Rails.application.configure do
# Settings... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/repository_test.rb | Ruby | mit | 218 | master | 1,909 | require "test_helper"
class RepositoryTest < ActiveSupport::TestCase
test "we can add a check to the repository" do
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base))
check = Easymon::Repository.fetch("database")
assert_equal 1, Easymon::Repository.repository.size, E... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checklist_test.rb | Ruby | mit | 218 | master | 2,446 | require "test_helper"
class ChecklistTest < ActiveSupport::TestCase
def setup
Easymon::Repository.add("database", Easymon::ActiveRecordCheck.new(ActiveRecord::Base))
Easymon::Repository.add("redis", Easymon::RedisCheck.new(YAML.load_file(Rails.root.join("config/redis.yml"), aliases: true)[Rails.env].symboliz... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/split_active_record_check_test.rb | Ruby | mit | 218 | master | 1,581 | require "test_helper"
class SplitActiveRecordCheckTest < ActiveSupport::TestCase
test "#run sets success conditions on successful run" do
primary = ActiveRecord::Base.connection
replica = Easymon::Replica.connection
check = Easymon::SplitActiveRecordCheck.new { [ primary, replica ] }
results = chec... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/active_record_mysql_writeable_check_test.rb | Ruby | mit | 218 | master | 781 | require "test_helper"
class ActiveRecordMysqlWriteableCheckTest < ActiveSupport::TestCase
test "#check returns a successful result on a good run" do
check = create_check
results = check.check
assert_equal(true, results[0])
assert_equal("@@read_only is 0", results[1])
end
test "#check returns a ... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/traffic_enabled_check_test.rb | Ruby | mit | 218 | master | 608 | require "test_helper"
class TrafficEnabledCheckTest < ActiveSupport::TestCase
test "#check sets success conditions on successful run" do
# Using a file we know exists in the test
check = Easymon::TrafficEnabledCheck.new("config/redis.yml")
results = check.check
assert_equal(true, results[0])
ass... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/redis_check_test.rb | Ruby | mit | 218 | master | 943 | require "test_helper"
class RedisCheckTest < ActiveSupport::TestCase
test "#run sets success conditions on successful run" do
Redis.any_instance.stubs(:ping).returns("PONG")
check = create_check
results = check.check
assert_equal("Up", results[1])
assert_equal(true, results[0])
end
test "#r... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/multi_active_record_check_test.rb | Ruby | mit | 218 | master | 2,222 | require "test_helper"
class MultiActiveRecordCheckTest < ActiveSupport::TestCase
test "#run sets success conditions on successful run" do
primary = ActiveRecord::Base.connection
primary_replica = Easymon::PrimaryReplica.connection
other_replica = Easymon::OtherReplica.connection
check = Easymon::Mul... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/active_record_check_on_postgresql_test.rb | Ruby | mit | 218 | master | 693 | require "test_helper"
class ActiveRecordCheckOnPostgresqlTest < ActiveSupport::TestCase
test "#check returns a successful result on a good run" do
check = create_check
results = check.check
assert_equal(true, results[0])
assert_equal("Up", results[1])
end
test "#check returns a failed result on... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/semaphore_check_test.rb | Ruby | mit | 218 | master | 599 | require "test_helper"
class SemaphoreCheckTest < ActiveSupport::TestCase
test "#run sets success conditions on successful run" do
check = Easymon::SemaphoreCheck.new("config/redis.yml")
results = check.check
assert_equal(true, results[0])
assert_equal("config/redis.yml is in place!", results[1])
e... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/http_check_test.rb | Ruby | mit | 218 | master | 1,167 | require "test_helper"
class HttpCheckTest < ActiveSupport::TestCase
test "#run sets success conditions on successful run" do
Net::HTTP.any_instance.stubs(:request).returns(Net::HTTPSuccess.new(1.1, 200, "OK"))
check = create_check
results = check.check
assert_equal("Up", results[1])
assert_equa... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/redis_writeable_check_test.rb | Ruby | mit | 218 | master | 807 | require "test_helper"
class RedisWriteableCheckTest < ActiveSupport::TestCase
test "#run sets success conditions on successful run" do
Redis.any_instance.stubs(:set).returns("OK")
check = create_check
results = check.check
assert_equal("Writeable", results[1])
assert_equal(true, results[0])
en... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/active_record_check_test.rb | Ruby | mit | 218 | master | 805 | require "test_helper"
class ActiveRecordCheckTest < ActiveSupport::TestCase
test "#check returns a successful result on a good run" do
check = create_check
results = check.check
assert_equal(true, results[0])
assert_equal("Up", results[1])
end
test "#check returns a failed result on a failed ru... |
github | basecamp/easymon | https://github.com/basecamp/easymon | test/unit/checks/memcached_check_test.rb | Ruby | mit | 218 | master | 1,104 | require "test_helper"
class MemcachedCheckTest < ActiveSupport::TestCase
test "#run sets success conditions on successful run" do
Rails.cache.stubs(:write).returns(true)
Rails.cache.stubs(:read).returns(1)
check = Easymon::MemcachedCheck.new(Rails.cache)
results = check.check
assert_equal("Up", ... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | Gemfile | Ruby | mit | 217 | master | 296 | source 'https://rubygems.org'
group :test do
gem 'mail', :require => false
gem 'net-ping', :require => false
gem 'tinder', :require => false
gem 'rake'
gem 'fakeweb'
gem 'minitest', '~> 2.0.2', :platforms => :ruby_18
gem 'ruby-debug', :platforms => :ruby_18
end |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | Rakefile | Ruby | mit | 217 | master | 508 | $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
require 'rake/testtask'
require "outpost/version"
desc 'Default: run tests'
task :default => :test
desc 'Run tests.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Build a g... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | outpost.gemspec | Ruby | mit | 217 | master | 782 | $:.push File.expand_path("../lib", __FILE__)
require "outpost/version"
Gem::Specification.new do |s|
s.name = "outpost"
s.version = Outpost::VERSION.dup
s.description = "Simple service monitoring with a clean DSL for configuration."
s.summary = "Simple service monitoring with a clean DSL for con... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/scout_config.rb | Ruby | mit | 217 | master | 889 | module Outpost
# Provides the DSL used to configure Scouts in Outposts.
class ScoutConfig
attr_reader :options, :reports
def initialize
@reports = {}
@options = {}
end
# Reads/writes any options. It will passed down to the Scout.
# @param [Object] args Any argument that will be pas... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/scout.rb | Ruby | mit | 217 | master | 6,978 | module Outpost
# Scouts are responsible for gathering data about a something specific that is
# a part of your system. For example, a HTTP Scout is responsible for getting
# the response code (200 for OK, 404 for Page Not Found, etc.), response
# body and any other thing you might want to know.
#
#
# Scou... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/report.rb | Ruby | mit | 217 | master | 1,099 | module Outpost
# Contain the status report of an Outpost execution. Holds the name,
# description and status of the reported item.
class Report
# Summarizes the list of statuses in a single status only.
# The logic is rather simple - it will return the lowest status
# present in the list.
#
# ... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/application.rb | Ruby | mit | 217 | master | 5,691 | module Outpost
# This class is the basic structure of an Outpost application. It provides
# the basic DSL for you to configure the monitoring of your services.
# Example:
#
# class ExampleSuccess < Outpost::Application
# name "Example"
# using Outpost::Scouts::Http => 'master http server' do
# ... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/expectations/response_body.rb | Ruby | mit | 217 | master | 1,286 | module Outpost
module Expectations
# Module containing response_body matching expectations. Extend your Scout
# with ResponseBody and it will gain response_body evaluation powers!
#
# It respond to the following rules:
# * match => If the response body matches the associated regular expression
... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/expectations/response_time.rb | Ruby | mit | 217 | master | 1,013 | module Outpost
module Expectations
# Module containing response_time matching expectations. Extend your Scout
# with ResponseTime and it will evaluate timely expressions, all in
# milisseconds.
#
# It respond to the following rules:
# * less_than => If the response time is less than the associ... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/expectations/response_code.rb | Ruby | mit | 217 | master | 760 | module Outpost
module Expectations
# Module containing response_code logic. It is the simplest of all,
# it is a simple direct equality check. Extend your Scout to win instant
# response_code checking.
module ResponseCode
# Installs the response code expectation
def self.extended(base)
... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/scouts/ping.rb | Ruby | mit | 217 | master | 1,095 | require 'net/ping/external'
require 'outpost/expectations'
module Outpost
module Scouts
# Uses system's "ping" command line tool to check if the server is
# responding in a timely manner.
#
# * Responds to response_time expectation
# ({Outpost::Expectations::ResponseTime})
class Ping < Outp... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/scouts/http.rb | Ruby | mit | 217 | master | 2,604 | require 'net/http'
require 'net/https'
require 'outpost/expectations'
module Outpost
module Scouts
# Uses ruby's own Net:HTTP to send HTTP requests and evaluate response
# body, response time and response code.
#
# * Responds to response_time expectation
# ({Outpost::Expectations::ResponseTime}... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/scouts/tcp.rb | Ruby | mit | 217 | master | 1,128 | require 'net/ping/tcp'
require 'outpost/expectations'
module Outpost
module Scouts
# Uses net/ping tcp pinger to check if port is open
#
# * Responds to response_time expectation
# ({Outpost::Expectations::ResponseTime})
class Tcp < Ping
extend Outpost::Expectations::ResponseTime
at... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/notifiers/campfire.rb | Ruby | mit | 217 | master | 1,957 | begin
require 'tinder'
rescue LoadError => e
puts "Please install tinder gem: gem install tinder"
raise
end
module Outpost
module Notifiers
# The Campfire notifier issues Outpost notifications to the 37signals'
# Campfire web app (http://campfirenow.com). It issues messages about
# the system statu... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | lib/outpost/notifiers/email.rb | Ruby | mit | 217 | master | 1,967 | begin
require 'mail'
rescue LoadError => e
puts "Please install mail gem: gem install mail"
raise
end
module Outpost
module Notifiers
# The Email notifier issues Outpost notifications to through email. It
# uses the 'mail' gem send the emails. You can see mail's documentation
# in order to change ... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/test_helper.rb | Ruby | mit | 217 | master | 456 | require 'rubygems'
require 'bundler'
Bundler.setup(:default, :test)
require 'ruby-debug' unless RUBY_VERSION > '1.9'
require 'ostruct'
require 'minitest/spec'
require 'minitest/autorun'
# Integration test helpers
require 'support/requests'
require 'support/stubs'
require 'support/nothing_raised'
require 'outpost'
re... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/support/nothing_raised.rb | Ruby | mit | 217 | master | 254 | module Support
module NothingRaised
# Inspired by assert_raises from minitest
def assert_nothing_raised(&block)
block.call
rescue Exception => e
flunk "No exception expected, but #{mu_pp(e.class)} was raised."
end
end
end |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/support/requests.rb | Ruby | mit | 217 | master | 348 | require 'fakeweb'
FakeWeb.allow_net_connect = false
FakeWeb.register_uri(:get, "http://localhost:9595", :body => 'Up and running!', :status => 200)
FakeWeb.register_uri(:get, "http://localhost:9595/fail", :body => 'Omg fail', :status => 500)
FakeWeb.register_uri(:get, "http://localhost:9595/warning", :body => 'Omg nee... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/support/stubs.rb | Ruby | mit | 217 | master | 204 | module Support
module Stubs
def build_stub(params={})
OpenStruct.new.tap do |stub|
params.each do |key, val|
stub.send "#{key}=", val
end
end
end
end
end |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/integration/more_complex_test.rb | Ruby | mit | 217 | master | 3,010 | require 'test_helper'
require 'outpost/scouts'
describe "using more complex application integration test" do
class ExamplePingAndHttp < Outpost::Application
using Outpost::Scouts::Http => 'master http server' do
options :host => 'localhost', :port => 9595, :path => '/'
report :up, :response_body => ... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/integration/basic_application_test.rb | Ruby | mit | 217 | master | 2,197 | require 'test_helper'
require 'outpost/scouts/http'
describe "basic application integration test" do
class ExampleSuccess < Outpost::Application
using Outpost::Scouts::Http => 'master http server' do
options :host => 'localhost', :port => 9595
report :up, :response_code => 200
end
end
class... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/integration/notifiers_test.rb | Ruby | mit | 217 | master | 1,281 | require 'test_helper'
require 'outpost/scouts'
require 'outpost/notifiers'
describe "using notifiers" do
class ExampleMailNotifier < Outpost::Application
notify Outpost::Notifiers::Email, {
:from => 'outpost@example.com',
:to => 'sleep_deprived_admin@example.com',
:subject => 'System 1... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/integration/reporting_test.rb | Ruby | mit | 217 | master | 982 | require 'test_helper'
require 'outpost/scouts'
describe "using only report data integration test" do
class RetrieveServerData < Outpost::Application
using Outpost::Scouts::Http => 'master http server' do
options :host => 'localhost', :port => 9595, :path => '/'
end
using Outpost::Scouts::Ping => ... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/integration/no_subclassing_test.rb | Ruby | mit | 217 | master | 1,103 | require 'test_helper'
require 'outpost/scouts/http'
require 'outpost/notifiers/email'
describe "creating outpost apps without subclassing" do
before do
Mail.defaults do
delivery_method :test
end
end
after(:each) do
Mail::TestMailer.deliveries = []
end
it "should report up when everything... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/application_test.rb | Ruby | mit | 217 | master | 5,435 | require 'test_helper'
describe Outpost::Application do
class ScoutMock
class << self
attr_accessor :status
end
def initialize(*args); end
def run ; self.class.status ; end
def report_data; ; {} ; end
end
class NotifierMock
class << self
attr_accessor :last_m... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/scout_config_test.rb | Ruby | mit | 217 | master | 711 | require 'test_helper'
describe Outpost::ScoutConfig do
before(:each) do
@config = Outpost::ScoutConfig.new
end
it "should assign options accordingly" do
@config.options :host => 'localhost'
assert_equal({:host => 'localhost'}, @config.options)
end
it "should assign reports accordingly" do
... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/report_test.rb | Ruby | mit | 217 | master | 961 | require 'test_helper'
describe Outpost::Report do
it "should report up when all are up" do
assert_equal :up, Outpost::Report.summarize([:up, :up, :up, :up])
end
it "should report down when mixed statuses" do
assert_equal :down, Outpost::Report.summarize([:up, :down, :up, :up])
end
it "should report... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/scout_test.rb | Ruby | mit | 217 | master | 4,259 | require 'test_helper'
describe Outpost::Scout do
NoisyError = Class.new(StandardError)
class ScoutExample < Outpost::Scout
attr_accessor :response
expect :response, lambda {|scout, status| scout.response == status }
def setup(*args); end
def execute(*args); end
end
class ReportingScoutExampl... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/scouts/ping_test.rb | Ruby | mit | 217 | master | 1,263 | require 'test_helper'
describe Outpost::Scouts::Ping do
class PingStub
def initialize(ping_successful, duration=nil)
@ping_successful = ping_successful
@duration = duration
end
def ping(*args); @ping_successful; end
def duration; @duration; end
end
it "should set th... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/scouts/http_test.rb | Ruby | mit | 217 | master | 2,387 | require 'test_helper'
require 'ostruct'
describe Outpost::Scouts::Http do
class NetHttpStub
class Get
def initialize(*args); end
end
def initialize *args; end
def use_ssl= *args; end
def request(*args, &block)
self.class.response
end
class << self
def response(*args, ... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/scouts/tcp_test.rb | Ruby | mit | 217 | master | 849 | require 'test_helper'
describe Outpost::Scouts::Tcp do
it "should set the time of ping in milliseconds" do
cls = Class.new do
def initialize(host, port, timeout)
end
def duration
0.01
end
def ping?
true
end
end
config = config_stub(:port => 9595, :p... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/notifiers/email_test.rb | Ruby | mit | 217 | master | 3,146 | require 'test_helper'
require 'tmpdir'
describe Outpost::Notifiers::Email do
before(:each) do
Mail.defaults do
delivery_method :test
end
end
after(:each) do
Mail::TestMailer.deliveries = []
end
describe "#initialize" do
it "should raise error when :from is not present" do
asser... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/notifiers/campfire_test.rb | Ruby | mit | 217 | master | 1,847 | require 'test_helper'
describe Outpost::Notifiers::Campfire do
class CampfireMock
class << self
attr_accessor :mock
end
def initialize(*args); end
def find_room_by_name(room); self.class.mock; end
end
describe "#initialize" do
it "should raise argument error if t... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/expectations/response_code_test.rb | Ruby | mit | 217 | master | 1,692 | require 'test_helper'
require 'ostruct'
describe Outpost::Expectations::ResponseCode do
class SubjectCode
class << self
attr_reader :expectation, :evaluation_method
def expect(expectation, evaluation_method)
@expectation = expectation
@evaluation_method = evaluation_method
... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/expectations/response_body_test.rb | Ruby | mit | 217 | master | 2,694 | require 'test_helper'
describe Outpost::Expectations::ResponseBody do
class SubjectBody
class << self
attr_reader :expectation, :evaluation_method
def expect(expectation, evaluation_method)
@expectation = expectation
@evaluation_method = evaluation_method
end
end
... |
github | vinibaggio/outpost | https://github.com/vinibaggio/outpost | test/outpost/expectations/response_time_test.rb | Ruby | mit | 217 | master | 2,270 | require 'test_helper'
describe Outpost::Expectations::ResponseTime do
class SubjectTime
class << self
attr_reader :expectation, :evaluation_method
def expect(expectation, evaluation_method)
@expectation = expectation
@evaluation_method = evaluation_method
end
end
... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | curlyq.gemspec | Ruby | mit | 217 | main | 1,414 | # Ensure we require the local version and not one we might have installed already
require File.join([File.dirname(__FILE__),'lib','curly','version.rb'])
spec = Gem::Specification.new do |s|
s.name = 'curlyq'
s.version = Curly::VERSION
s.author = 'Brett Terpstra'
s.email = 'me@brettterpstra.com'
s.homepage = '... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | Rakefile | Ruby | mit | 217 | main | 3,398 | require 'rake/clean'
require 'rake/testtask'
require 'rubygems'
require 'rubygems/package_task'
require 'rdoc/task'
require 'yard'
require 'parallel_tests'
require 'parallel_tests/tasks'
require 'tty-spinner'
YARD::Rake::YardocTask.new do |t|
t.files = ['lib/curly/*.rb']
t.options = ['--markup=markdown', '--no-priva... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/curlyq_images_test.rb | Ruby | mit | 217 | main | 789 | # frozen_string_literal: true
require 'json'
require 'yaml'
require 'helpers/curlyq-helpers'
require 'test_helper'
# Tests for tags command
class CurlyQImagesTest < Test::Unit::TestCase
include CurlyQHelpers
def test_images_query
result = curlyq('images', '-t', 'img', '-q', '[alt$=screenshot]', 'https://bre... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/curlyq_scrape_test.rb | Ruby | mit | 217 | main | 2,211 | # frozen_string_literal: true
require 'json'
require 'yaml'
require 'helpers/curlyq-helpers'
require 'test_helper'
# Tests for tags command
class CurlyQScrapeTest < Test::Unit::TestCase
include CurlyQHelpers
def setup
@screenshot = File.join(File.dirname(__FILE__), 'screenshot_test')
FileUtils.rm_f("#{@... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/test_helper.rb | Ruby | mit | 217 | main | 211 | # frozen_string_literal: true
require 'test/unit'
# Add test libraries you want to use here, e.g. mocha
class Test::Unit::TestCase
ENV['TZ'] = 'UTC'
# Add global extensions to the test case class here
end |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/curlyq_tags_test.rb | Ruby | mit | 217 | main | 1,409 | # frozen_string_literal: true
require 'json'
require 'yaml'
require 'helpers/curlyq-helpers'
require 'test_helper'
# Tests for tags command
class CurlyQTagsTest < Test::Unit::TestCase
include CurlyQHelpers
def setup
end
def test_tags
result = curlyq('tags', '--search', '#main .post h3', 'https://brettt... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/curlyq_headlinks_test.rb | Ruby | mit | 217 | main | 962 | # frozen_string_literal: true
require 'json'
require 'yaml'
require 'helpers/curlyq-helpers'
require 'test_helper'
# Tests for tags command
class CurlyQHeadlinksTest < Test::Unit::TestCase
include CurlyQHelpers
def setup
end
def test_headlinks_query
result = curlyq('headlinks', '-q', '[rel=stylesheet]'... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/curlyq_extract_test.rb | Ruby | mit | 217 | main | 1,890 | # frozen_string_literal: true
require 'json'
require 'yaml'
require 'helpers/curlyq-helpers'
require 'test_helper'
# Tests for tags command
class CurlyQExtractTest < Test::Unit::TestCase
include CurlyQHelpers
def setup
end
def test_extract_inclusive
result = curlyq('extract', '-i', '-b', 'Adding', '-a'... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/curlyq_json_test.rb | Ruby | mit | 217 | main | 1,082 | # frozen_string_literal: true
require 'json'
require 'yaml'
require 'helpers/curlyq-helpers'
require 'test_helper'
# Tests for tags command
class CurlyQJsonTest < Test::Unit::TestCase
include CurlyQHelpers
def setup
end
def test_json
result = curlyq('json', 'https://brettterpstra.com/scripts/giveaways_... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/curlyq_links_test.rb | Ruby | mit | 217 | main | 579 | # frozen_string_literal: true
require 'json'
require 'yaml'
require 'helpers/curlyq-helpers'
require 'test_helper'
# Tests for tags command
class CurlyQLinksTest < Test::Unit::TestCase
include CurlyQHelpers
def test_links
result = curlyq('links', '-q', '[content*=twitter]', 'https://stackoverflow.com/questi... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/curlyq_html_test.rb | Ruby | mit | 217 | main | 832 | # frozen_string_literal: true
require 'json'
require 'yaml'
require 'helpers/curlyq-helpers'
require 'test_helper'
# Tests for tags command
class CurlyQHtmlTest < Test::Unit::TestCase
include CurlyQHelpers
def test_html_search_query
result = curlyq('html', '-s', '#main article .aligncenter', '-q', 'images[0... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/helpers/threaded_tests.rb | Ruby | mit | 217 | main | 5,068 | #!/usr/bin/env ruby
require 'tty-spinner'
require 'tty-progressbar'
require 'open3'
require 'shellwords'
require 'fileutils'
require 'pastel'
class ThreadedTests
def run(pattern: '*', max_threads: 8, max_tests: 0)
pastel = Pastel.new
start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
@results... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | test/helpers/curlyq-helpers.rb | Ruby | mit | 217 | main | 819 | require 'open3'
require 'time'
require 'fileutils'
$LOAD_PATH.unshift File.join(__dir__, '..', '..', 'lib')
require 'curly'
module CurlyQHelpers
CURLYQ_EXEC = File.join(File.dirname(__FILE__), '..', '..', 'bin', 'curlyq')
BUNDLE = '/Users/ttscoff/.asdf/shims/bundle'
def curlyq_with_env(env, *args, stdin: nil)
... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | lib/curly.rb | Ruby | mit | 217 | main | 257 | # frozen_string_literal: true
require 'curly/version'
require 'curly/hash'
require 'curly/string'
require 'curly/array'
require 'curly/numeric'
require 'json'
require 'yaml'
require 'uri'
require 'tty-which'
require 'nokogiri'
require 'selenium-webdriver' |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | lib/curly/string.rb | Ruby | mit | 217 | main | 2,458 | # frozen_string_literal: true
##
## Remove extra spaces and newlines from a string
##
## @return [String] cleaned string
##
class ::String
##
## Discard invalid characters and output a UTF-8 String
##
## @return [String] UTF-8 encoded string
##
def utf8
encode('utf-16', invalid: :replace).enco... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | lib/curly/array.rb | Ruby | mit | 217 | main | 4,247 | # frozen_string_literal: true
# Array helpers
class ::Array
##
## Remove extra spaces from each element of an array of
## strings
##
## @return [Array] cleaned array
##
def clean
map(&:clean)
end
##
## @see #clean
##
def clean!
replace clean
end
##
## Strip HTML tags from ea... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | lib/curly/hash.rb | Ruby | mit | 217 | main | 10,492 | # frozen_string_literal: true
# Hash helpers
class ::Hash
## Convert a Curly object to data hash
##
## @return [Hash] return a hash with keys renamed and
## cleaned up
##
## @param url [String] A url to fall back to
## @param clean [Boolean] Clean extra spaces and newlines i... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | lib/curly/curl/html.rb | Ruby | mit | 217 | main | 27,582 | # frozen_string_literal: true
module Curl
# String helpers
class ::String
def remove_entities
gsub(/ /, ' ')
end
end
# Class for CURLing an HTML page
class Html
attr_accessor :settings, :browser, :source, :headers, :headers_only, :compressed, :clean, :fallback,
:igno... |
github | ttscoff/curlyq | https://github.com/ttscoff/curlyq | lib/curly/curl/json.rb | Ruby | mit | 217 | main | 3,515 | # frozen_string_literal: true
module Curl
# Class for CURLing a JSON response
class Json
attr_accessor :url
attr_writer :compressed, :request_headers, :symbolize_names
attr_reader :code, :json, :headers
def to_data
{
url: @url,
code: @code,
json: @json,
head... |
github | NZKoz/rails_xss | https://github.com/NZKoz/rails_xss | init.rb | Ruby | mit | 217 | master | 427 | # Include hook code here
begin
require 'erubis/helpers/rails_helper'
require 'rails_xss'
Erubis::Helpers::RailsHelper.engine_class = RailsXss::Erubis
Module.class_eval do
include RailsXss::SafeHelpers
end
require 'rails_xss_escaping'
require 'av_patch'
rescue LoadError
puts "Could not load all mo... |
github | NZKoz/rails_xss | https://github.com/NZKoz/rails_xss | Rakefile | Ruby | mit | 217 | master | 565 | require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the rails_xss plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the r... |
github | NZKoz/rails_xss | https://github.com/NZKoz/rails_xss | lib/rails_xss_escaping.rb | Ruby | mit | 217 | master | 483 | ERB::Util.module_eval do # :nodoc:
def html_escape_with_output_safety(value)
# Values which don't respond to html_safe, should be checked
if value.respond_to?(:html_safe?) && value.html_safe?
value
else
html_escape_without_output_safety(value).html_safe!
end
end
alias_method_chain... |
github | NZKoz/rails_xss | https://github.com/NZKoz/rails_xss | lib/av_patch.rb | Ruby | mit | 217 | master | 301 | module AvPatch
# Rails version of with_output_buffer uses '' as the default buf
def with_output_buffer(buf = ActionView::SafeBuffer.new) #:nodoc:
super(buf)
end
end
ActionView::Base.send :include, AvPatch
module ActionView
class Base
def self.xss_safe?
true
end
end
end |
github | NZKoz/rails_xss | https://github.com/NZKoz/rails_xss | lib/rails_xss.rb | Ruby | mit | 217 | master | 1,047 | # RailsXss
module RailsXss
class Erubis < ::Erubis::Eruby
def add_preamble(src)
src << "@output_buffer = ActionView::SafeBuffer.new;\n"
end
def add_text(src, text)
src << "@output_buffer << ('" << escape_text(text) << "'.html_safe!);"
end
def add_expr_literal(src, code)
src... |
github | NZKoz/rails_xss | https://github.com/NZKoz/rails_xss | test/rails_xss_test.rb | Ruby | mit | 217 | master | 709 | require 'test_helper'
require 'rails_xss_escaping'
class RailsXssTest < ActiveSupport::TestCase
test "ERB::Util.h should mark its return value as safe and escape it" do
escaped = ERB::Util.h("<p>")
assert_equal "<p>", escaped
assert escaped.html_safe?
end
test "ERB::Util.h should leave previou... |
github | pazdera/tco | https://github.com/pazdera/tco | tco.gemspec | Ruby | mit | 217 | master | 1,056 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "tco/version"
Gem::Specification.new do |s|
s.name = "tco"
s.version = Tco::VERSION
s.authors = ["Radek Pazdera"]
s.email = ["radek@pazdera.co.uk"]
s.summary = %... |
github | pazdera/tco | https://github.com/pazdera/tco | spec/tco_spec.rb | Ruby | mit | 217 | master | 329 | require "tco"
describe Tco do
describe Tco::Colour do
before :each do
@colour = Tco::Colour.new [12, 34, 56]
end
it "converts to HSL" do
hsl = @colour.hsl
hsl[0].should be_within(0.1).of 210
hsl[1].should be_within(0.1).of 64.7
hsl[2].should be_within(0.1).of 13.3
end
... |
github | pazdera/tco | https://github.com/pazdera/tco | spec/lib_spec.rb | Ruby | mit | 217 | master | 4,298 | # tco - terminal colouring application and library
# Copyright (c) 2013, 2014 Radek Pazdera
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | spec/parser_spec.rb | Ruby | mit | 217 | master | 4,967 | # tco - terminal colouring application and library
# Copyright (c) 2013, 2014 Radek Pazdera
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | spec/utils.rb | Ruby | mit | 217 | master | 254 | require "tco/style"
module Utils
def get_params(base_style=nil, fg=nil, bg=nil, bright=nil, underline=nil)
{
:base_style => base_style,
:fg => fg,
:bg => bg,
:bright => bright,
:underline => underline
}
end
end |
github | pazdera/tco | https://github.com/pazdera/tco | spec/string_ext_spec.rb | Ruby | mit | 217 | master | 3,217 | # tco - terminal colouring application and library
# Copyright (c) 2013, 2014 Radek Pazdera
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | lib/tco.rb | Ruby | mit | 217 | master | 4,932 | # tco - terminal colouring application and library
# Copyright (c) 2013, 2014 Radek Pazdera
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | lib/tco/version.rb | Ruby | mit | 217 | master | 1,197 | # tco - terminal colouring application and library
# Copyright (c) 2013, 2014 Radek Pazdera
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | lib/tco/parser.rb | Ruby | mit | 217 | master | 5,001 | # tco - terminal colouring application and library
# Copyright (c) 2013, 2014 Radek Pazdera
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | lib/tco/colouring.rb | Ruby | mit | 217 | master | 7,181 | # tco - terminal colouring application and library
# Copyright (c) 2013, 2014 Radek Pazdera
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | lib/tco/config.rb | Ruby | mit | 217 | master | 4,163 | # tco - terminal colouring application and library
# Copyright (c) 2013, 2014 Radek Pazdera
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | lib/tco/palette.rb | Ruby | mit | 217 | master | 18,360 | # tco - terminal colouring application and library
# Copyright (c) 2013, 2014 Radek Pazdera
# MIT License
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | lib/tco/style.rb | Ruby | mit | 217 | master | 1,704 | # tco - terminal colouring application and library
# copyright (c) 2013, 2014 radek pazdera
# mit license
# permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "software"), to deal
# in the software without restriction, including with... |
github | pazdera/tco | https://github.com/pazdera/tco | examples/tux.rb | Ruby | mit | 217 | master | 232 | #!/usr/bin/env ruby
require "tco"
require "rmagick"
Magick::Image.read("tux.png")[0].each_pixel do |pixel, col, row|
c = [pixel.red, pixel.green, pixel.blue].map { |v| 255*(v/65535.0) }
print " ".bg c
puts if col >= 53
end |
github | pazdera/tco | https://github.com/pazdera/tco | examples/rainbow.rb | Ruby | mit | 217 | master | 456 | #!/usr/bin/env ruby
require "tco"
conf = Tco.config
conf.names["purple"] = "#622e90"
conf.names["dark-blue"] = "#2d3091"
conf.names["blue"] = "#00aaea"
conf.names["green"] = "#02a552"
conf.names["yellow"] = "#fdea22"
conf.names["orange"] = "#f37f5a"
conf.names["red"] = "#eb443b"
Tco.reconfigure conf
rainbow = ["purp... |
github | pazdera/tco | https://github.com/pazdera/tco | examples/union_jack.rb | Ruby | mit | 217 | master | 779 | #!/usr/bin/env ruby
require "tco"
flag = <<-EOS
RRR BBBBBBBBBB RR BBBBBBBBBB RRR
RR BBBBBBBB RR BBBBBBBB RR
B RR BBBBBB RR BBBBBB RR B
BBB RR BBBB RR BBBB RR BBB
BBBBB RR BBB RR BBB RR BBBBB
RR
RRRRRRRRRRRRRRRRRRRRRRRR... |
github | drnic/appscrolls | https://github.com/drnic/appscrolls | Guardfile | Ruby | mit | 217 | master | 587 | guard 'cucumber' do
watch(%r{^features/.+\.feature$})
watch(%r{^features/support/.+$}) { 'features' }
watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
end
guard 'rspec', :version => 2 do
watch(%r{^spec/.+_spec\.rb$})
watch(%r{^scroll... |
github | drnic/appscrolls | https://github.com/drnic/appscrolls | Rakefile | Ruby | mit | 217 | master | 1,432 | require "bundler/gem_tasks"
require 'rspec/core/rake_task'
desc "run specs"
RSpec::Core::RakeTask.new
task :default => :spec
desc "Remove the test_run Rails app (if it's there)"
task :clean do
system 'rm -rf test_run'
end
desc "Execute a test run with the specified scrolls."
task :run => :clean do
scrolls = E... |
github | drnic/appscrolls | https://github.com/drnic/appscrolls | appscrolls.gemspec | Ruby | mit | 217 | master | 1,256 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require File.dirname(__FILE__) + "/version"
Gem::Specification.new do |s|
s.name = "appscrolls"
s.version = AppScrollsScrolls::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Michael Bleigh", "Dr Nic Williams"]
s.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.