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
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
Gemfile
Ruby
mit
240
main
281
source "https://rubygems.org" gemspec gem "appraisal" gem "bundler", "~> 1.0" gem "byebug" gem "m" gem "minitest" gem "mocha" gem "pry", "~> 0.12.0" gem "pry-byebug", "~> 3.6.0" gem "rake" gem "rubocop", "0.71.0" gem "snowglobe", ">= 0.3.0" gem "test-unit" gem "warnings_logger"
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
Rakefile
Ruby
mit
240
main
621
require "bundler/setup" require "bundler/gem_tasks" require "rake/testtask" require "pry-byebug" require_relative "test/support/current_bundle" load "tasks/shoulda.rake" Rake::TestTask.new do |t| t.libs << "test" t.ruby_opts += ["-w"] t.pattern = "test/**/*_test.rb" t.verbose = true end task :default do i...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
shoulda-context.gemspec
Ruby
mit
240
main
925
# -*- encoding: utf-8 -*- $LOAD_PATH << File.join(File.dirname(__FILE__), "lib") require "shoulda/context/version" Gem::Specification.new do |s| s.name = "shoulda-context" s.version = Shoulda::Context::VERSION.dup s.platform = Gem::Platform::RUBY s.authors = ["thoughtbot, inc.", "Tammer Sale...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
Appraisals
Ruby
mit
240
main
1,795
# Note: All of the dependencies here were obtained by running `rails new` with # various versions of Rails and copying lines from the generated Gemfile. It's # best to keep the gems here in the same order as they're listed there so you # can compare them more easily. shared_rails_dependencies = proc do gem "sqlite3"...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/test_helper.rb
Ruby
mit
240
main
1,026
require_relative "support/current_bundle" Tests::CurrentBundle.instance.assert_appraisal! #--- require "pry-byebug" require "warnings_logger" TEST_FRAMEWORK = ENV.fetch("TEST_FRAMEWORK", "minitest") if TEST_FRAMEWORK == "test_unit" require "test-unit" require "mocha/test_unit" else require "minitest/autorun"...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/support/rails_application_with_shoulda_context.rb
Ruby
mit
240
main
1,007
require_relative "snowglobe" class RailsApplicationWithShouldaContext < Snowglobe::RailsApplication ROOT_DIRECTORY = Pathname.new("../../..").expand_path(__FILE__) def create super bundle.updating do bundle.add_gem(test_framework_gem_name, group: :test) bundle.add_gem("shoulda-context", path:...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/support/current_bundle.rb
Ruby
mit
240
main
1,084
require "bundler" require "appraisal" module Tests class CurrentBundle AppraisalNotSpecified = Class.new(ArgumentError) include Singleton def assert_appraisal! unless appraisal_in_use? message = <<MSG Please run tests starting with `appraisal <appraisal_name>`. Possible appraisals are: ...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/shoulda/context_test.rb
Ruby
mit
240
main
9,190
require 'test_helper' class ContextTest < PARENT_TEST_CASE def self.context_macro(&blk) context "with a subcontext made by a macro" do setup { @context_macro = :foo } merge_block(&blk) end end context "context with setup block" do setup do @blah = "blah" end should "run t...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/shoulda/railtie_test.rb
Ruby
mit
240
main
1,173
require "test_helper" class RailtieTest < PARENT_TEST_CASE context "A Rails application with shoulda-context added to it" do setup do app.create end should "load files in vendor/gems and vendor/plugins when booted" do app.create_gem_with_macro( module_name: "MacrosFromVendor", ...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/shoulda/test_framework_detection_test.rb
Ruby
mit
240
main
3,253
require "test_helper" require "tempfile" class TestFrameworkDetectionTest < PARENT_TEST_CASE if TEST_FRAMEWORK == "minitest" should "detect Minitest 5.x when it is loaded standalone" do assert_integration_with "Minitest::Test", setup: <<-RUBY require "minitest/autorun" RUBY end end i...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/shoulda/helpers_test.rb
Ruby
mit
240
main
4,287
require 'test_helper' class HelpersTest < PARENT_TEST_CASE context "an array of values" do setup do @a = ['abc', 'def', 3] end [/b/, 'abc', 3].each do |x| should "contain #{x.inspect}" do assert_raises(ASSERTION_CLASS) do assert_does_not_contain @a, x end as...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/shoulda/rerun_snippet_test.rb
Ruby
mit
240
main
1,913
require "test_helper" class RerunSnippetTest < PARENT_TEST_CASE context "A Rails application with shoulda-context added to it" do should "display the correct rerun snippet when a test fails" do if app.rails_version >= 5 && TEST_FRAMEWORK == "minitest" app.create app.write_file("test/models...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/shoulda/should_test.rb
Ruby
mit
240
main
10,993
require 'test_helper' class ShouldTest < PARENT_TEST_CASE should "be able to define a should statement outside of a context" do assert true end should "see the name of my class as ShouldTest" do assert_equal "ShouldTest", self.class.name end def self.should_see_class_methods should "be able to ...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/shoulda/convert_to_should_syntax_test.rb
Ruby
mit
240
main
1,289
require 'test_helper' class ConvertToShouldSyntaxTest < PARENT_TEST_CASE BEFORE_FIXTURE = <<-EOS class DummyTest < #{PARENT_TEST_CASE} should "Not change this_word_with_underscores" do end def test_should_be_working assert true end def test_some_cool_stuff assert ...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
test/shoulda/autoload_macro_test.rb
Ruby
mit
240
main
445
require 'test_helper' class AutoloadMacroTest < PARENT_TEST_CASE context "The macro auto-loader" do should "load macros from the plugins" do assert self.class.respond_to?('plugin_macro') end should "load macros from the gems" do assert self.class.respond_to?('gem_macro') end should ...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context.rb
Ruby
mit
240
main
449
require "shoulda/context/autoload_macros" require "shoulda/context/configuration" require "shoulda/context/context" require "shoulda/context/dsl" require "shoulda/context/proc_extensions" require "shoulda/context/test_framework_detection" require "shoulda/context/version" require "shoulda/context/world" if defined?(Ra...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/dsl.rb
Ruby
mit
240
main
9,765
require "shoulda/context/assertions" module Shoulda module Context module DSL def self.included(base) base.class_eval do include Assertions include InstanceMethods end base.extend(ClassMethods) end module ClassMethods # == Should statements ...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/proc_extensions.rb
Ruby
mit
240
main
373
# Stolen straight from ActiveSupport class Proc #:nodoc: def bind(object) block, time = self, Time.now (class << object; self end).class_eval do method_name = "__bind_#{time.to_i}_#{time.usec}" define_method(method_name, &block) method = instance_method(method_name) remove_method(meth...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/context.rb
Ruby
mit
240
main
7,031
module Shoulda module Context class Context # :nodoc: attr_accessor :name # my name attr_accessor :parent # may be another context, or the original test::unit class. attr_accessor :subcontexts # array of contexts nested under myself attr_accessor :setup_blo...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/autoload_macros.rb
Ruby
mit
240
main
1,928
module Shoulda # :nodoc: # Call autoload_macros when you want to load test macros automatically in a non-Rails # project (it's done automatically for Rails projects). # You don't need to specify ROOT/test/shoulda_macros explicitly. Your custom macros # are loaded automatically when you call autoload_macros. #...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/assertions.rb
Ruby
mit
240
main
3,590
module Shoulda # :nodoc: module Context module Assertions # Asserts that two arrays contain the same elements, the same number of times. Essentially ==, but unordered. # # assert_same_elements([:a, :b, :c], [:c, :a, :b]) => passes) def assert_same_elements(a1, a2, msg = nil) [:s...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/configuration.rb
Ruby
mit
240
main
358
module Shoulda module Context def self.configure yield self end def self.include(mod) test_framework_test_cases.each do |test_case| test_case.class_eval { include mod } end end def self.extend(mod) test_framework_test_cases.each do |test_case| test_case.ex...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/test_framework_detection.rb
Ruby
mit
240
main
811
module Shoulda module Context module TestFrameworkDetection def self.possible_test_frameworks [ -> { ActiveSupport::TestCase }, -> { Minitest::Test }, -> { Test::Unit::TestCase } ] end def self.resolve_framework(future_framework) future_fram...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/railtie.rb
Ruby
mit
240
main
315
module Shoulda module Context class Railtie < Rails::Railtie initializer "shoulda_context.autoload_macros" do if Rails.env.test? Shoulda.autoload_macros( Rails.root, File.join("vendor", "{plugins,gems}", "*") ) end end end end end
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/world.rb
Ruby
mit
240
main
394
module Shoulda module Context class << self def contexts # :nodoc: @contexts ||= [] end attr_writer :contexts def current_context # :nodoc: self.contexts.last end def add_context(context) # :nodoc: self.contexts.push(context) end def remov...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/tasks/list_tests.rake
Ruby
mit
240
main
836
namespace :shoulda do desc "List the names of the test methods in a specification like format" task :list do $LOAD_PATH.unshift("test") require 'test/unit' require 'rubygems' require 'active_support' # bug in test unit. Set to true to stop from running. Test::Unit.run = true test_fil...
github
thoughtbot/shoulda-context
https://github.com/thoughtbot/shoulda-context
lib/shoulda/context/tasks/yaml_to_shoulda.rake
Ruby
mit
240
main
907
namespace :shoulda do # From http://blog.internautdesign.com/2007/11/2/a-yaml_to_shoulda-rake-task # David.Lowenfels@gmail.com desc "Converts a YAML file (FILE=./path/to/yaml) into a Shoulda skeleton" task :from_yaml do require 'yaml' def yaml_to_context(hash, indent = 0) indent1 = ' ' * indent ...
github
makandra/query_diet
https://github.com/makandra/query_diet
query_diet.gemspec
Ruby
mit
239
master
928
$:.push File.expand_path("../lib", __FILE__) require "query_diet/version" Gem::Specification.new do |gem| gem.name = 'query_diet' gem.version = QueryDiet::VERSION gem.authors = ["Henning Koch", "Tobias Kraze"] gem.email = "github@makandra.de" gem.homepage = "https://github.c...
github
makandra/query_diet
https://github.com/makandra/query_diet
Gemfile.7.0.sqlite
Ruby
mit
239
master
261
source 'https://rubygems.org' # Runtime dependencies gem 'rails', '=7.0.1' # Development dependencies gem 'rspec' gem 'rspec-rails' gem 'sqlite3' gem 'database_cleaner' gem 'capybara' gem 'byebug' gem 'gemika' # Gem under test gem 'query_diet', :path => '.'
github
makandra/query_diet
https://github.com/makandra/query_diet
lib/query_diet/logger.rb
Ruby
mit
239
master
949
module QueryDiet class Logger DEFAULT_OPTIONS = { :bad_count => 8, :bad_time => 5000 } class << self attr_accessor :queries, :paused def reset self.queries = [] end def log(query) if paused? yield else result = nil time = QueryDi...
github
makandra/query_diet
https://github.com/makandra/query_diet
lib/query_diet/benchmark.rb
Ruby
mit
239
master
237
module QueryDiet module Benchmark class << self def realtime r0 = Process.clock_gettime(Process::CLOCK_MONOTONIC) yield Process.clock_gettime(Process::CLOCK_MONOTONIC) - r0 end end end end
github
makandra/query_diet
https://github.com/makandra/query_diet
lib/query_diet/widget.rb
Ruby
mit
239
master
1,407
module QueryDiet module Widget class << self def css(nonce_attribute) <<-EOF <style type="text/css"#{nonce_attribute}><!-- div#query_diet { position: absolute; top: 0; right: 0; background-color: black; color: white; ...
github
makandra/query_diet
https://github.com/makandra/query_diet
lib/query_diet/active_record_ext.rb
Ruby
mit
239
master
439
module QueryDiet module ActiveRecordExt if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('3') def log(query, *, **) QueryDiet::Logger.log(query) { super } end else def log(query, *) QueryDiet::Logger.log(query) { super } end end end end ActiveSupport.on_load...
github
makandra/query_diet
https://github.com/makandra/query_diet
lib/query_diet/widget/helper.rb
Ruby
mit
239
master
552
module QueryDiet module Widget module Helper def query_diet_widget(options = {}) default_html_options = {:nonce => false} options = options.reverse_merge(default_html_options) nonce_attribute = options.fetch(:nonce) ? " nonce=\"#{content_security_policy_nonce}\"" : '' html...
github
makandra/query_diet
https://github.com/makandra/query_diet
lib/query_diet/rack/reset_logger.rb
Ruby
mit
239
master
503
module QueryDiet module Rack class ResetLogger def initialize(app) @app = app end def call(env) QueryDiet::Logger.reset @app.call(env) end end end end if defined?(Rails::Railtie) class QueryDiet::Railtie < Rails::Railtie initializer 'query_diet.inser...
github
makandra/query_diet
https://github.com/makandra/query_diet
spec/spec_helper.rb
Ruby
mit
239
master
585
# Set the default environment to sqlite3's in_memory database ENV['RAILS_ENV'] ||= 'test' # Runtime dependencies require 'rails/all' require_relative './support/app' require 'rspec/rails' require 'gemika' require 'byebug' require 'query_diet' # Require all files in spec/support Dir["#{File.dirname(__FILE__)}/support...
github
makandra/query_diet
https://github.com/makandra/query_diet
spec/query_diet/logger_spec.rb
Ruby
mit
239
master
2,351
describe QueryDiet::Logger do before do QueryDiet::Logger.reset end def mock_realtime(seconds) expect(QueryDiet::Benchmark).to receive(:realtime).at_least(:once).and_wrap_original do |original_method, *args, &block| original_method.call(*args, &block) seconds end end describe "#rese...
github
makandra/query_diet
https://github.com/makandra/query_diet
spec/query_diet/widget/helper_spec.rb
Ruby
mit
239
master
2,132
require 'spec_helper' describe QueryDiet::Widget::Helper, type: :helper do it "should be highlighted if the request was too intimate with the database" do QueryDiet::Logger.stub :bad? => true helper.query_diet_widget.should have_selector('div#query_diet.bad') end it "should not be highlighted if the re...
github
makandra/query_diet
https://github.com/makandra/query_diet
spec/support/app.rb
Ruby
mit
239
master
319
class SpecApp < Rails::Application end Rails.application = SpecApp.instance if defined?(Rails.application.secrets) Rails.application.secrets.secret_key_base = 'the_secret' Rails.application.secrets.secret_token = 'the_secret' end class ActionController::Base def _routes Rails.application.routes end end
github
huydx/facy
https://github.com/huydx/facy
facy.gemspec
Ruby
mit
239
master
1,102
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'facy/version' Gem::Specification.new do |spec| spec.name = "facy" spec.version = Facy::VERSION spec.authors = ["dxhuy1988"] spec.email = ["doxuanhuy@gmail.com...
github
huydx/facy
https://github.com/huydx/facy
lib/facy.rb
Ruby
mit
239
master
480
%w( koala readline yaml thread launchy eventmachine active_support active_support/core_ext active_support/dependencies ).each { |lib| require lib } Thread.abort_on_exception = true Encoding.default_external = Encoding.find('UTF-8') %w( core_ext core logger get_token output command help faceb...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/image_viewer.rb
Ruby
mit
239
master
1,924
module Facy module ImageViewer def view_img(path, options={}) Image.new(path, options).draw end module AnsiRGB def self.wrap_with_code(string, rgb) red, green, blue = rgb[0], rgb[1], rgb[2] "\e[#{code(red, green, blue)}m" + string + "\e[0m" end def self.code(red, ...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/facebook.rb
Ruby
mit
239
master
3,383
module Facy module Facebook attr_reader :authen_hash, :rest module ConnectionStatus NORMAL = 0 ERROR = 1 SUSPENDED = 2 end def facebook_me @graph.api("/me?fields=id,name") rescue Koala::Facebook::ServerError retry_wait rescue Koala::Facebook::APIError ...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/core.rb
Ruby
mit
239
master
2,632
module Facy module Core def me @me end def config @config ||= {} end def inits @inits ||= [] end def init(&block) inits << block end def config_file config_file_folder = "/tmp" config_file_name = ".facy_config.yml" File.expand_path(conf...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/converter.rb
Ruby
mit
239
master
2,443
# coding: utf-8 module Facy module Converter #convert facebook graph return to Item#class def graph2item(graph_item) id = graph_item["id"] if id =~ /^notif_(.+)$/ item = Item.new({ id: id, info: :notification, data: { user: graph_item["from"]["nam...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/option_parser.rb
Ruby
mit
239
master
486
module Facy module OptParser def parse(argv) OptionParser.new do |opt| # -h, --h, --help is show usage. # -v, --v, --version is show version. # short option with require argument opt.on('--debug_log VALUE') do |v| config[:debug_log] = v end ...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/output.rb
Ruby
mit
239
master
5,462
# coding: utf-8 module Facy module Output def periodic_output return if (items = not_yet_print_items).empty? new_line items.each {|item| instant_output(item)} clear_line end def not_yet_print_items items = [] while !stream_print_queue.empty? post = stream_prin...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/help.rb
Ruby
mit
239
master
727
module Facy module Help def helps @helps ||= [] end def help(target, usage, example=nil) helps << {target: target, usage: usage, example: example} end end extend Help init do command :help do |target| target = target.tap{|t|t.strip!}.gsub(':','').to_sym @helps.each...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/get_token.rb
Ruby
mit
239
master
3,417
# coding: utf-8 module Facy module GetToken def session_file File.expand_path(config[:session_file_name], config[:session_file_folder]) end def setup_app_id developer_page = "https://developers.facebook.com" puts "★ go to #{developer_page} and enter our app_id: " browse(dev...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/command.rb
Ruby
mit
239
master
6,964
module Facy module Command def aliasing(origin, with) alias_commands[with] = origin end def alias_commands @alias_commands ||= {} end def commands @commands ||= [] end def command(pattern, options={}, &block) commands << {pattern: pattern, block: block} end ...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/logger.rb
Ruby
mit
239
master
524
module Facy module Logger def log_file File.expand_path(config[:log_file_name], config[:log_folder]) end def log_queue @log_queue ||= [] end def log(info, message) return unless config[:debug_log] log_queue << {info: info.to_s, message: message} end def d...
github
huydx/facy
https://github.com/huydx/facy
lib/facy/input_queue.rb
Ruby
mit
239
master
634
module Facy module InputQueue def printed_item @printed_item ||= Set.new end def stream_print_queue @stream_print_queue ||= [] end def notification_print_queue @notification_print_queue ||= [] end def item_print_queue @item_print_queue ||= [] end def ins...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
display_case.gemspec
Ruby
mit
239
master
888
Gem::Specification.new do |s| s.name = 'display_case' s.version = '0.3.1' s.date = '2022-08-10' s.summary = "An implementation of the Exhibit pattern, as described in Objects on Rails" s.description = "An implementation of the Exhibit pattern, as described in Objects on Rails" s.author...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
Rakefile
Ruby
mit
239
master
703
require 'rake/testtask' require_relative 'tasks/gemspec' namespace 'test' do test_files = FileList['spec/**/*_spec.rb'] integration_test_files = FileList['spec/**/*_integration_spec.rb'] unit_test_files = test_files - integration_test_files desc "Run unit tests" Rake::TestTask.new('unit'...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
Gemfile
Ruby
mit
239
master
264
source 'http://rubygems.org' group :development, :test do gem 'minitest' gem 'rr' gem 'activerecord-nulldb-adapter', :github => "nulldb/nulldb" gem 'rake' gem 'json-jruby', :platform => :jruby gem "activesupport" gem "activerecord", ">= 6.1.6.1" end
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/spec_helper_full.rb
Ruby
mit
239
master
303
require_relative 'spec_helper_lite' #require_relative '../config/environment.rb' module SpecHelpers def setup_database DatabaseCleaner.strategy = :transaction DatabaseCleaner.clean_with(:truncation) DatabaseCleaner.start end def teardown_database DatabaseCleaner.clean end end
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/spec_helper_nulldb.rb
Ruby
mit
239
master
425
require "bundler/setup" require_relative 'spec_helper_lite' require 'active_support/all' require 'active_record' module SpecHelpers def setup_nulldb require 'nulldb' schema_path = File.expand_path('fixtures/db/schema.rb', File.dirname(__FILE__)) ActiveRecord::Base.establish_connection(:adapter => :nulldb...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/spec_helper_lite.rb
Ruby
mit
239
master
1,207
ENV['RAILS_ENV'] ||= 'test' gem 'minitest' # demand gem version require 'minitest/autorun' require 'rr' require 'ostruct' $: << File.expand_path('../lib', File.dirname(__FILE__)) class MiniTest::Unit::TestCase include RR::Adapters::MiniTest end def stub_module(full_name, &block) stub_class_or_module(full_name, M...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/integration/several_exhibits_spec.rb
Ruby
mit
239
master
999
require_relative '../spec_helper_lite' require_relative '../../lib/display_case' require 'ostruct' describe "several exhibits" do let(:model) { stub } let(:first_exhibit) { new_exhibit } let(:second_exhibit) { new_exhibit } before do @exhibits = [first_exhibit, second_exhibit] stub(DisplayCase::Exhibi...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/integration/ordering_exhibits_spec.rb
Ruby
mit
239
master
1,545
require_relative '../spec_helper_lite' require_relative '../../lib/display_case' require 'ostruct' describe "ordering" do let(:model) { stub } let(:first_exhibit) { new_exhibit } let(:second_exhibit) { new_exhibit } before do @exhibits = [first_exhibit, second_exhibit] end it "should favor Exhibits...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/basic_exhibit_spec.rb
Ruby
mit
239
master
969
require_relative '../spec_helper_lite' require_relative '../../lib/display_case' describe DisplayCase::BasicExhibit do subject { DisplayCase::BasicExhibit.new(model, context) } let(:model) { ["e1", "e2", "e3"] } let(:context) { Object.new } describe '#to_partial_path' do it 'delegates to the model if it h...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/reloaded_namespaced_exhibit_spec.rb
Ruby
mit
239
master
1,719
require_relative '../spec_helper_lite' require_relative '../../lib/display_case' require 'ostruct' describe "reloading namespaced exhibits" do let(:model) { stub } let(:exhibit_file) { File.expand_path('spec/fixtures/exhibits/changing_exhibits/namespaced_exhibit_three.rb') } before do DisplayCase.conf...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/text_post_exhibit_spec.rb
Ruby
mit
239
master
716
require_relative '../spec_helper_lite' require_relative '../fixtures/exhibits/text_post_exhibit' describe TextPostExhibit do before do @post = OpenStruct.new( title: "TITLE", body: "BODY", pubdate: "PUBDATE") @context = stub! @it = TextPostExhibit.new(@post, @context) end it "...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/link_exhibit_spec.rb
Ruby
mit
239
master
1,628
require_relative '../spec_helper_lite' require_relative '../fixtures/exhibits/link_exhibit' require 'json' describe LinkExhibit do before do @next = Object.new @prev = Object.new @up = Object.new @model = Object.new stub(@model).next{ @next } stub(@model).prev{ @prev } stub(@model).up{ ...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/tag_list_exhibit_spec.rb
Ruby
mit
239
master
243
require_relative '../spec_helper_lite' require_relative '../fixtures/exhibits/tag_list_exhibit' describe TagListExhibit do subject { TagListExhibit.new(tag_list, context) } let(:tag_list) { Object.new } let(:context) { Object.new } end
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/configuration_spec.rb
Ruby
mit
239
master
1,402
require_relative '../spec_helper_lite' require_relative '../../lib/display_case' require_relative '../fixtures/exhibits/blog_exhibit' module DisplayCase describe Exhibit do describe '#exhibits' do it 'should not include BlogExhibit when explicit and no exhibits given' do DisplayCase.configure do |c...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/blog_exhibit_spec.rb
Ruby
mit
239
master
787
require_relative '../spec_helper_lite' require_relative '../fixtures/exhibits/blog_exhibit' describe BlogExhibit do subject { BlogExhibit.new(blog, context) } let(:blog) { OpenStruct.new(:tags => tags) } let(:tags) { Object.new } let(:context) { Object.new } it 'exhibits its tags' do exh...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/reloaded_exhibit_spec.rb
Ruby
mit
239
master
1,530
require_relative '../spec_helper_lite' require_relative '../../lib/display_case' require 'ostruct' describe "reloading exhibits" do let(:model) { stub } let(:exhibit_file) { File.expand_path('spec/fixtures/exhibits/changing_exhibits/exhibit_one.rb') } before do DisplayCase.configure do |config| ...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/exhibit_spec.rb
Ruby
mit
239
master
3,539
require_relative '../spec_helper_lite' require_relative '../../lib/display_case' describe DisplayCase::Exhibit do subject { exhibit_class.new(model, context) } let(:exhibit_class) { Class.new(DisplayCase::Exhibit) } let(:model) { Object.new } let(:context) { Object.new } DisplayCas...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/enumerable_exhibit_spec.rb
Ruby
mit
239
master
5,641
require_relative '../spec_helper_lite' require_relative '../../lib/display_case' describe DisplayCase::EnumerableExhibit do describe "class" do subject { DisplayCase::EnumerableExhibit } it "is applicable to Enumerables" do assert subject.applicable_to?([]) assert subject.applicable_to?({}) ...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/picture_post_exhibit_spec.rb
Ruby
mit
239
master
728
require_relative '../spec_helper_lite' require_relative '../fixtures/exhibits/picture_post_exhibit' describe PicturePostExhibit do before do @post = OpenStruct.new( title: "TITLE", body: "BODY", pubdate: "PUBDATE") @context = stub! @it = PicturePostExhibit.new(@post, @context) en...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/exhibits/nil_exhibit_spec.rb
Ruby
mit
239
master
710
require_relative '../spec_helper_lite' require_relative '../fixtures/exhibits/nil_exhibit' describe NilExhibit do subject { NilExhibit.new(nil, context) } let(:context) { Object.new } it 'says when it is nil' do subject.name.must_equal "I am nil!" end it 'says when it is not nil' do not_...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/models/taggable_record_spec.rb
Ruby
mit
239
master
1,415
require_relative '../spec_helper_lite' require_relative '../fixtures/models/taggable_record' describe TaggableRecord do include Conversions class Item attr_writer :save_result def initialize(tags) @attributes = {:tags => tags} end def save; @save_result end def [](key) @attribute...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/models/tag_list_spec.rb
Ruby
mit
239
master
2,677
require 'ostruct' require_relative '../spec_helper_lite' require_relative '../fixtures/models/tag_list' describe TagList do include Conversions describe "given a blank string" do before do @it = TagList.new("") end it "is empty" do @it.must_be_empty end it "stringifies to the emp...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/models/post_spec.rb
Ruby
mit
239
master
1,935
require_relative '../spec_helper_nulldb' require_relative '../fixtures/models/post' describe Post do include SpecHelpers before do setup_nulldb @it = Post.new(:title => "TITLE") @ar = @it @ar_class = Post end after do teardown_nulldb end it "supports reading and writing a blog referen...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/models/blog_spec.rb
Ruby
mit
239
master
1,512
require_relative '../spec_helper_lite' require_relative '../fixtures/models/blog' require 'ostruct' describe Blog do subject { Blog.new(->{entries}) } let(:entries) { [] } it "has no entries" do subject.entries.must_be_empty end describe "#new_entry" do let(:new_post) { OpenStruct.new } ...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/helpers/exhibits_helper_spec.rb
Ruby
mit
239
master
436
require_relative '../spec_helper_lite' stub_class 'DisplayCase::Exhibit' require_relative '../../lib/display_case' describe DisplayCase::ExhibitsHelper do before do @it = Object.new @it.extend DisplayCase::ExhibitsHelper @context = stub! end it "delegates exhibition decisions to Exhibit" do mode...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/helpers/shared_specs_helper.rb
Ruby
mit
239
master
520
# from https://gist.github.com/3113618 gem 'minitest' require 'minitest/spec' require 'minitest/autorun' MiniTest::Spec.class_eval do def self.shared_examples @shared_examples ||= {} end end module MiniTest::Spec::SharedExamples def shared_examples_for(desc, &block) MiniTest::Spec.shared_examples[desc]...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/display_case/is_a_class_comparator_spec.rb
Ruby
mit
239
master
268
require_relative '../../lib/display_case/is_a_class_comparator' require_relative 'class_comparator_shared_examples' module DisplayCase describe IsAClassComparator do let(:comparator) { IsAClassComparator.new } it_behaves_like 'a class comparator' end end
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/display_case/name_class_comparator_spec.rb
Ruby
mit
239
master
270
require_relative '../../lib/display_case/name_class_comparator' require_relative 'class_comparator_shared_examples' module DisplayCase describe NameClassComparator do let(:comparator) { NameClassComparator.new } it_behaves_like 'a class comparator' end end
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/display_case/class_comparator_shared_examples.rb
Ruby
mit
239
master
1,661
require_relative "../spec_helper_lite.rb" require_relative "../helpers/shared_specs_helper" module DisplayCase shared_examples_for 'a class comparator' do describe "DisplayCase Class Comparators" do it 'identifies when an object is of a given class' do object = TestClass.new comparator.call...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/display_case/cache/store_spec.rb
Ruby
mit
239
master
2,110
require_relative '../../spec_helper_lite' require_relative '../../../lib/display_case' require_relative '../../fixtures/exhibits/blog_exhibit' require_relative 'store' module DisplayCase describe Exhibit do let(:exhibit) { BasicExhibit.new(mock, mock) } it "can use a block to access the cache" do resul...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
spec/display_case/cache/store.rb
Ruby
mit
239
master
524
module DisplayCase module Cache class Store def initialize @store = {} end def read(key) @store[key] end def fetch(key, options={}, &block) return read(key) if exist?(key) write(key, yield) read(key) end def wri...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
tasks/gemspec.rb
Ruby
mit
239
master
251
require 'erb' task 'gemspec' do gemspec_template = IO.read('display_case.gemspec.erb') File.open('display_case.gemspec', 'w') do |gemspec_file| gemspec = ERB.new(gemspec_template).result(binding) gemspec_file.puts gemspec end end
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
lib/display_case.rb
Ruby
mit
239
master
280
require_relative 'display_case/configuration' require_relative 'display_case/exhibit' require_relative 'display_case/enumerable_exhibit' require_relative 'display_case/basic_exhibit' require_relative 'display_case/exhibits_helper' require_relative 'display_case/find_definitions'
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
lib/display_case/name_class_comparator.rb
Ruby
mit
239
master
866
module DisplayCase # What with Rails development mode reloading making class matching # unreliable, plus wanting to avoid adding dependencies to external # class definitions if we can avoid it, this class just matches # against class/module name strings rather than the actual class # objects. class NameClas...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
lib/display_case/find_definitions.rb
Ruby
mit
239
master
1,755
module DisplayCase def self.find_definitions absolute_definition_file_paths = configuration.definition_file_paths.map {|path| File.expand_path(path) } absolute_definition_file_paths.uniq.each do |path| file = "#{path}.rb" display_case_load file if File.directory? path Dir[File.join...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
lib/display_case/is_a_class_comparator.rb
Ruby
mit
239
master
877
module DisplayCase class IsAClassComparator def call(object, *classes) classes.any?{|klass| object.is_a?(class_object(klass))} end private # A simple memoizing class name tracker class ClassTracker def initialize @context = Object @data = Hash.new {|h, k| h[k] = c...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
lib/display_case/exhibit.rb
Ruby
mit
239
master
5,188
require 'delegate' require 'active_support' require 'active_support/core_ext' require 'display_case/railtie' if defined?(::Rails) require_relative 'configuration' require_relative 'is_a_class_comparator' require_relative 'name_class_comparator' module DisplayCase class Exhibit < SimpleDelegator def self.initiali...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
lib/display_case/enumerable_exhibit.rb
Ruby
mit
239
master
1,741
require_relative 'exhibit' module DisplayCase class EnumerableExhibit < Exhibit include Enumerable def self.applicable_to?(object, context=nil) # ActiveRecord::Relation, surprisingly, is not Enumerable. But it # behaves sufficiently similarly for our purposes. object.respond_to?(:each) ...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
lib/display_case/railtie.rb
Ruby
mit
239
master
368
module DisplayCase class Railtie < Rails::Railtie # http://guides.rubyonrails.org/configuring.html#initialization-events # "to_prepare will run upon every request in development, but only once (during boot-up) in production and test." config.to_prepare do DisplayCase.find_definitions if Rails.env.de...
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
lib/display_case/basic_exhibit.rb
Ruby
mit
239
master
278
require_relative 'exhibit' module DisplayCase class BasicExhibit < Exhibit def to_partial_path if __getobj__.respond_to?(:to_partial_path) __getobj__.to_partial_path.dup else partialize_name(__getobj__.class.name) end end end end
github
objects-on-rails/display-case
https://github.com/objects-on-rails/display-case
lib/display_case/configuration.rb
Ruby
mit
239
master
2,126
module DisplayCase class << self attr_accessor :configuration end def self.configure self.configuration ||= Configuration.new yield(configuration) end class Configuration # A boolean indicating whether the Exhibits will be explicitly listed in order or # dynamically collected with the in...
github
mattbrictson/bundle_update_interactive
https://github.com/mattbrictson/bundle_update_interactive
Rakefile
Ruby
mit
239
main
2,889
# frozen_string_literal: true require "bundler/gem_tasks" require "rake/testtask" Rake::TestTask.new(:test) do |t| t.libs << "test" t.libs << "lib" t.test_files = FileList["test/**/*_test.rb"] end if Gem.loaded_specs.key?("rubocop") require "rubocop/rake_task" RuboCop::RakeTask.new task default: %i[test ...
github
mattbrictson/bundle_update_interactive
https://github.com/mattbrictson/bundle_update_interactive
Gemfile
Ruby
mit
239
main
652
# frozen_string_literal: true source "https://rubygems.org" gemspec gem "activesupport", "~> 7.1.3" # Needed for factory_bot 6.3 gem "cgi" # Needed for vcr on Ruby 3.5+ gem "factory_bot", "~> 6.3.0" gem "irb" gem "minitest", "~> 5.11" gem "minitest-snapshots", "~> 1.1" gem "mocha", "~> 3.0" gem "observer" gem "openss...
github
mattbrictson/bundle_update_interactive
https://github.com/mattbrictson/bundle_update_interactive
bundle_update_interactive.gemspec
Ruby
mit
239
main
1,578
# frozen_string_literal: true require_relative "lib/bundle_update_interactive/version" Gem::Specification.new do |spec| spec.name = "bundle_update_interactive" spec.version = BundleUpdateInteractive::VERSION spec.authors = ["Matt Brictson"] spec.email = ["opensource@mattbrictson.com"] spec.summary = "Adds ...
github
mattbrictson/bundle_update_interactive
https://github.com/mattbrictson/bundle_update_interactive
test/bundle_update_interactive_test.rb
Ruby
mit
239
main
205
# frozen_string_literal: true require "test_helper" class BundleUpdateInteractiveTest < Minitest::Test def test_that_it_has_a_version_number refute_nil ::BundleUpdateInteractive::VERSION end end
github
mattbrictson/bundle_update_interactive
https://github.com/mattbrictson/bundle_update_interactive
test/test_helper.rb
Ruby
mit
239
main
291
# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("../lib", __dir__) require "bundle_update_interactive" require "minitest/autorun" BundleUpdateInteractive.pastel = Pastel.new(enabled: true) Dir[File.expand_path("support/**/*.rb", __dir__)].sort.each { |rb| require(rb) }
github
mattbrictson/bundle_update_interactive
https://github.com/mattbrictson/bundle_update_interactive
test/integration/cli_integration_test.rb
Ruby
mit
239
main
4,918
# frozen_string_literal: true require "test_helper" require "json" require "open3" require "tmpdir" module BundleUpdateInteractive class CLIIntegrationIest < Minitest::Test def test_updates_lock_file_based_on_selected_gem_while_honoring_gemfile_requirement out, _gemfile, lockfile = within_fixture_copy("in...
github
mattbrictson/bundle_update_interactive
https://github.com/mattbrictson/bundle_update_interactive
test/support/vcr.rb
Ruby
mit
239
main
375
# frozen_string_literal: true require "vcr" VCR.configure do |config| config.allow_http_connections_when_no_cassette = false config.cassette_library_dir = File.expand_path("../cassettes", __dir__) config.hook_into :webmock config.default_cassette_options = { match_requests_on: %i[method uri body_as_json],...