repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
joliss/markdown-rails
https://github.com/joliss/markdown-rails/blob/bc43c1c110b66f92481ad3733e0fb6495c846d7b/testapp/config/initializers/mime_types.rb
testapp/config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
ruby
MIT
bc43c1c110b66f92481ad3733e0fb6495c846d7b
2026-01-04T17:45:12.101166Z
false
joliss/markdown-rails
https://github.com/joliss/markdown-rails/blob/bc43c1c110b66f92481ad3733e0fb6495c846d7b/testapp/config/initializers/secret_token.rb
testapp/config/initializers/secret_token.rb
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. Testapp::Application.config.secret_token = '37d351cbe61f61c436a254a63a641b7eb81732299c1ead653e5e531e65d5eb34c2aa4ae4da0d8d6390c5760e1d9afb9cd4197a7af8df30a77e72656d5373bbf3'
ruby
MIT
bc43c1c110b66f92481ad3733e0fb6495c846d7b
2026-01-04T17:45:12.101166Z
false
joliss/markdown-rails
https://github.com/joliss/markdown-rails/blob/bc43c1c110b66f92481ad3733e0fb6495c846d7b/testapp/config/environments/test.rb
testapp/config/environments/test.rb
Testapp::Application.configure do # Settings specified here will take precedence over those in config/application.rb # 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! config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" # Log error messages when you accidentally call methods on nil config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Raise exception on mass assignment protection for Active Record models config.active_record.mass_assignment_sanitizer = :strict # Print deprecation notices to the stderr config.active_support.deprecation = :stderr end
ruby
MIT
bc43c1c110b66f92481ad3733e0fb6495c846d7b
2026-01-04T17:45:12.101166Z
false
joliss/markdown-rails
https://github.com/joliss/markdown-rails/blob/bc43c1c110b66f92481ad3733e0fb6495c846d7b/testapp/config/environments/development.rb
testapp/config/environments/development.rb
Testapp::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger config.active_support.deprecation = :log # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin # Raise exception on mass assignment protection for Active Record models config.active_record.mass_assignment_sanitizer = :strict # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) config.active_record.auto_explain_threshold_in_seconds = 0.5 # Do not compress assets config.assets.compress = false # Expands the lines which load the assets config.assets.debug = true end
ruby
MIT
bc43c1c110b66f92481ad3733e0fb6495c846d7b
2026-01-04T17:45:12.101166Z
false
joliss/markdown-rails
https://github.com/joliss/markdown-rails/blob/bc43c1c110b66f92481ad3733e0fb6495c846d7b/testapp/config/environments/production.rb
testapp/config/environments/production.rb
Testapp::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) config.serve_static_assets = false # Compress JavaScripts and CSS config.assets.compress = true # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = false # Generate digests for assets URLs config.assets.digest = true # Defaults to Rails.root.join("public/assets") # config.assets.manifest = YOUR_PATH # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # See everything in the log (default is :info) # config.log_level = :debug # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] # Use a different logger for distributed setups # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) # config.assets.precompile += %w( search.js ) # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false # Enable threaded mode # config.threadsafe! # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true # Send deprecation notices to registered listeners config.active_support.deprecation = :notify # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) # config.active_record.auto_explain_threshold_in_seconds = 0.5 end
ruby
MIT
bc43c1c110b66f92481ad3733e0fb6495c846d7b
2026-01-04T17:45:12.101166Z
false
joliss/markdown-rails
https://github.com/joliss/markdown-rails/blob/bc43c1c110b66f92481ad3733e0fb6495c846d7b/lib/markdown-rails.rb
lib/markdown-rails.rb
require 'markdown-rails/version' require 'markdown-rails/engine'
ruby
MIT
bc43c1c110b66f92481ad3733e0fb6495c846d7b
2026-01-04T17:45:12.101166Z
false
joliss/markdown-rails
https://github.com/joliss/markdown-rails/blob/bc43c1c110b66f92481ad3733e0fb6495c846d7b/lib/markdown-rails/version.rb
lib/markdown-rails/version.rb
module MarkdownRails VERSION = "0.2.1" end
ruby
MIT
bc43c1c110b66f92481ad3733e0fb6495c846d7b
2026-01-04T17:45:12.101166Z
false
joliss/markdown-rails
https://github.com/joliss/markdown-rails/blob/bc43c1c110b66f92481ad3733e0fb6495c846d7b/lib/markdown-rails/engine.rb
lib/markdown-rails/engine.rb
require 'rdiscount' require 'action_view' # We cannot use Markdown::Rails because it conflicts with RDiscount's Markdown class module MarkdownRails class Handler def initialize end def call(template) # Return Ruby code that returns the compiled template MarkdownRails.renderer.call(template.source).inspect + '.html_safe' end end class <<self def configure yield self end attr_accessor :renderer def render(&block) self.renderer = block end end end MarkdownRails.configure do |config| config.render do |markdown_source| RDiscount.new(markdown_source).to_html end end handler = MarkdownRails::Handler.new [:md, :markdown].each do |extension| # >= v3.0.5 if defined? ActionView::Template::Handlers and ActionView::Template::Handlers.respond_to? :register_template_handler ActionView::Template::Handlers # >= v2.1.0 <= v2.1.0 elsif defined? ActionView::Template and ActionView::Template.respond_to? :register_template_handler ActionView::Template # >= v2.2.1 <= v2.3.8 elsif defined? ActionView::TemplateHandlers and ActionView::TemplateHandlers.respond_to? :register_template_handler ActionView::TemplateHandlers # <= v2.0.3 elsif defined? ActionView::Base and ActionView::Base.respond_to? :register_template_handler ActionView::Base # I give up... else raise "Couldn't find `register_template_handler' method in ActionView module." end.register_template_handler extension, handler end
ruby
MIT
bc43c1c110b66f92481ad3733e0fb6495c846d7b
2026-01-04T17:45:12.101166Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/app/helpers/application_helper.rb
app/helpers/application_helper.rb
module ApplicationHelper include Twitter::Autolink end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/app/controllers/welcome_controller.rb
app/controllers/welcome_controller.rb
class WelcomeController < ApplicationController end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
class SessionsController < ApplicationController def create credentials = request.env['omniauth.auth']['credentials'] session[:access_token] = credentials['token'] session[:access_token_secret] = credentials['secret'] redirect_to show_path, notice: 'Signed in' end def show if session['access_token'] && session['access_token_secret'] @user = client.user(include_entities: true) else redirect_to failure_path end end def error flash[:error] = 'Sign in with Twitter failed' redirect_to root_path end def destroy reset_session redirect_to root_path, notice: 'Signed out' end end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/app/controllers/application_controller.rb
app/controllers/application_controller.rb
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception private def client @client ||= Twitter::REST::Client.new do |config| config.consumer_key = ENV['CONSUMER_KEY'] config.consumer_secret = ENV['CONSUMER_SECRET'] config.access_token = session['access_token'] config.access_token_secret = session['access_token_secret'] end end end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/test/test_helper.rb
test/test_helper.rb
ENV['RAILS_ENV'] ||= 'test' require 'simplecov' require 'coveralls' SimpleCov.formatters = [SimpleCov::Formatter::HTMLFormatter, Coveralls::SimpleCov::Formatter] SimpleCov.start('rails') do minimum_coverage(100) end require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' require 'mocha/setup' require 'webmock/minitest'
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/test/functional/sessions_controller_test.rb
test/functional/sessions_controller_test.rb
require 'test_helper' class SessionsControllerTest < ActionController::TestCase test 'should save access token and secret in session on OAuth callback' do result = {} result['omniauth.auth'] = {} result['omniauth.auth']['credentials'] = {} result['omniauth.auth']['credentials']['token'] = 'abc' result['omniauth.auth']['credentials']['secret'] = '123' request.stubs env: result get :create assert_equal 'abc', session[:access_token] assert_equal '123', session[:access_token_secret] assert_equal 'Signed in', flash[:notice] assert_redirected_to show_path end test 'should display profile when authenticated' do session[:access_token] = 'abc' session[:access_token_secret] = '123' stub_request(:get, 'https://api.twitter.com/1.1/account/verify_credentials.json'). with(query: {include_entities: 'true'}). to_return(body: File.read(File.expand_path('../../fixtures/user.json', __FILE__))) stub_request(:get, 'https://api.twitter.com/1.1/users/show.json'). with(query: {screen_name: 'sferik'}). to_return(body: File.read(File.expand_path('../../fixtures/user.json', __FILE__))) get :show assert_not_nil assigns :user assert_response :success assert_select 'title', 'Sign in with Twitter' assert_select 'form' do assert_select '[action=?]', '/signout' assert_select '[method=?]', 'post' end assert_select 'input[name="_method"]' do assert_select '[type=?]', 'hidden' assert_select '[value=?]', 'delete' end assert_select 'button', 'Sign out' end test 'should redirect to failure path when unauthenticated' do get :show assert_redirected_to failure_path end test 'should display error on failure' do get :error assert_equal 'Sign in with Twitter failed', flash[:error] assert_redirected_to root_path end test 'should empty session on sign out' do get :destroy assert_equal ['flash'], session.keys assert_equal 'Signed out', flash[:notice] assert_redirected_to root_path end end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/test/functional/welcome_controller_test.rb
test/functional/welcome_controller_test.rb
require 'test_helper' class WelcomeControllerTest < ActionController::TestCase test 'should get index' do get :index assert_response :success assert_select 'title', 'Sign in with Twitter' assert_select 'form' do assert_select '[action=?]', '/auth/twitter' assert_select '[method=?]', 'get' end assert_select 'button', 'Sign in with Twitter' end end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/application.rb
config/application.rb
require File.expand_path('../boot', __FILE__) require 'action_controller/railtie' require 'rails/test_unit/railtie' require 'sprockets/railtie' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module SignInWithTwitter class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de # Do not swallow errors in after_commit/after_rollback callbacks. # config.active_record.raise_in_transactional_callbacks = true end end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/environment.rb
config/environment.rb
# Load the Rails application. require File.expand_path('../application', __FILE__) # Initialize the Rails application. Rails.application.initialize!
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/routes.rb
config/routes.rb
Rails.application.routes.draw do root to: 'welcome#index' get '/auth/twitter/callback', to: 'sessions#create', as: 'callback' get '/auth/failure', to: 'sessions#error', as: 'failure' get '/profile', to: 'sessions#show', as: 'show' delete '/signout', to: 'sessions#destroy', as: 'signout' end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/unicorn.rb
config/unicorn.rb
worker_processes 3 timeout 30 preload_app true before_fork do |_server, _worker| Signal.trap 'TERM' do Process.kill 'QUIT', Process.pid end end after_fork do |_server, _worker| Signal.trap 'TERM' do end end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/boot.rb
config/boot.rb
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' # Set up gems listed in the Gemfile.
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/initializers/filter_parameter_logging.rb
config/initializers/filter_parameter_logging.rb
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password]
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/initializers/session_store.rb
config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_sign-in-with-twitter_session'
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/initializers/wrap_parameters.rb
config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] if respond_to?(:wrap_parameters) end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do # self.include_root_in_json = true # end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/initializers/omniauth.rb
config/initializers/omniauth.rb
Rails.application.config.middleware.use OmniAuth::Builder do if ENV['CONSUMER_KEY'].blank? || ENV['CONSUMER_SECRET'].blank? warn '*' * 80 warn 'WARNING: Missing consumer key or secret. First, register an app with Twitter at' warn 'https://dev.twitter.com/apps to obtain OAuth credentials. Then, start the server' warn 'with the command: CONSUMER_KEY=abc CONSUMER_SECRET=123 rails server' warn '*' * 80 else provider :twitter, ENV['CONSUMER_KEY'], ENV['CONSUMER_SECRET'] end end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/initializers/inflections.rb
config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/initializers/cookies_serializer.rb
config/initializers/cookies_serializer.rb
# Be sure to restart your server when you modify this file. Rails.application.config.action_dispatch.cookies_serializer = :json
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/initializers/assets.rb
config/initializers/assets.rb
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( search.js )
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/initializers/backtrace_silencers.rb
config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/initializers/mime_types.rb
config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/environments/test.rb
config/environments/test.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # 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! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure static file server for tests with Cache-Control for performance. config.serve_static_files = true config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. # config.action_mailer.delivery_method = :test # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :warn # Randomize the order test cases are executed. config.active_support.test_order = :random # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/environments/development.rb
config/environments/development.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send. # config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. # config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. config.assets.digest = true # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. # Raises helpful error messages. config.assets.raise_runtime_errors = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
sferik/sign-in-with-twitter
https://github.com/sferik/sign-in-with-twitter/blob/6af428a4a2e7b9832d7b60f84886a5889df66eec/config/environments/production.rb
config/environments/production.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Enable Rack::Cache to put a simple HTTP cache in front of your application # Add `rack-cache` to your Gemfile before enabling this. # For large-scale production use, consider using a caching reverse proxy like # NGINX, varnish or squid. # config.action_dispatch.rack_cache = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. config.assets.digest = true # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :debug # Prepend all log lines with the following tags. # config.log_tags = [ :subdomain, :uuid ] # Use a different logger for distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production. # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Do not dump schema after migrations. # config.active_record.dump_schema_after_migration = false end
ruby
MIT
6af428a4a2e7b9832d7b60f84886a5889df66eec
2026-01-04T17:45:04.780094Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/app/controllers/saml_idp/idp_controller.rb
app/controllers/saml_idp/idp_controller.rb
module SamlIdp class IdpController < ActionController::Base include SamlIdp::Controller unloadable protect_from_forgery if Rails.version.to_i < 4 before_filter :validate_saml_request else before_action :validate_saml_request end def new render :template => "saml_idp/idp/new" end def create unless params[:email].blank? && params[:password].blank? person = idp_authenticate(params[:email], params[:password]) if person.nil? @saml_idp_fail_msg = "Incorrect email or password." else @saml_response = idp_make_saml_response(person) render :template => "saml_idp/idp/saml_post", :layout => false return end end render :template => "saml_idp/idp/new" end protected def idp_authenticate(email, password) raise "Not implemented" end def idp_make_saml_response(person) raise "Not implemented" end end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/spec_helper.rb
spec/spec_helper.rb
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib' $LOAD_PATH.unshift File.dirname(__FILE__) STDERR.puts("Running Specs under Ruby Version #{RUBY_VERSION}") require "rails_app/config/environment" require 'rspec' require 'capybara/rspec' require 'capybara/rails' require 'ruby-saml' require 'ruby-saml-idp' Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f} RSpec.configure do |config| config.mock_with :rspec config.include SamlRequestMacros end Capybara.default_host = "https://app.example.com"
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/support/saml_request_macros.rb
spec/support/saml_request_macros.rb
module SamlRequestMacros def make_saml_request(requested_saml_acs_url = "https://foo.example.com/saml/consume") auth_request = OneLogin::RubySaml::Authrequest.new auth_url = auth_request.create(saml_settings(saml_acs_url: requested_saml_acs_url)) CGI.unescape(auth_url.split("=").last) end def saml_settings(options = {}) settings = OneLogin::RubySaml::Settings.new settings.assertion_consumer_service_url = options[:saml_acs_url] || "https://foo.example.com/saml/consume" settings.issuer = options[:issuer] || "https://foo.example.com/" settings.idp_sso_target_url = options[:idp_sso_target_url] || "http://idp.com/saml/idp" settings.idp_cert_fingerprint = SamlIdp::Default::FINGERPRINT settings.name_identifier_format = SamlIdp::Default::NAME_ID_FORMAT settings end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/saml_idp/controller_spec.rb
spec/saml_idp/controller_spec.rb
require 'spec_helper' require 'timecop' describe SamlIdp::Controller do include SamlIdp::Controller def params @params ||= {} end it "should find the SAML ACS URL" do requested_saml_acs_url = "https://example.com/saml/consume" params[:SAMLRequest] = make_saml_request(requested_saml_acs_url) validate_saml_request expect(saml_acs_url).to eq(requested_saml_acs_url) end context "SAML Responses" do before(:each) do params[:SAMLRequest] = make_saml_request validate_saml_request end it "should create a SAML Response" do saml_response = encode_SAMLResponse("foo@example.com") response = OneLogin::RubySaml::Response.new(saml_response) expect(response.name_id).to eq("foo@example.com") expect(response.issuers).to eq(["http://example.com"]) response.settings = saml_settings expect(response.is_valid?).to be_truthy end it "should handle custom attribute objects" do provider = double(to_s: %[<saml:AttributeStatement><saml:Attribute Name="organization"><saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">Organization name</saml:AttributeValue></saml:Attribute></saml:AttributeStatement>]) default_attributes = %[<saml:AttributeStatement><saml:Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"><saml:AttributeValue>foo@example.com</saml:AttributeValue></saml:Attribute></saml:AttributeStatement>] saml_response = encode_SAMLResponse("foo@example.com", { attributes_provider: provider }) response = OneLogin::RubySaml::Response.new(saml_response) expect(response.response).to include provider.to_s expect(response.response).to_not include default_attributes end [:sha1, :sha256, :sha384, :sha512].each do |algorithm_name| it "should create a SAML Response using the #{algorithm_name} algorithm" do self.algorithm = algorithm_name saml_response = encode_SAMLResponse("foo@example.com") response = OneLogin::RubySaml::Response.new(saml_response) expect(response.name_id).to eq("foo@example.com") expect(response.issuers).to eq(["http://example.com"]) response.settings = saml_settings expect(response.is_valid?).to be true end end it "should not set SessionNotOnOrAfter when expires_in is nil" do Timecop.freeze self.expires_in = nil saml_response = encode_SAMLResponse("foo@example.com") response = OneLogin::RubySaml::Response.new(saml_response) expect(response.session_expires_at).to be_nil end it "should set SessionNotOnOrAfter when expires_in is specified" do self.expires_in = 86400 # 1 day now = Time.now.utc saml_response = Timecop.freeze(now) { encode_SAMLResponse("foo@example.com") } response = OneLogin::RubySaml::Response.new(saml_response) expect(response.session_expires_at).to eq(Time.at(now.to_i + 86400)) end end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/acceptance/acceptance_helper.rb
spec/acceptance/acceptance_helper.rb
require File.expand_path(File.dirname(__FILE__) + "/../spec_helper") require 'capybara/rspec' # Put your acceptance spec helpers inside /spec/acceptance/support Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} RSpec.configure do |config| config.include Rails.application.routes.url_helpers, :type => :request end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/acceptance/idp_controller_spec.rb
spec/acceptance/idp_controller_spec.rb
require File.expand_path(File.dirname(__FILE__) + '/acceptance_helper') feature 'IdpController' do scenario 'Login via default signup page' do saml_request = make_saml_request("http://foo.example.com/saml/consume") visit "/saml/auth?SAMLRequest=#{CGI.escape(saml_request)}" fill_in 'Email', :with => "brad.copa@example.com" fill_in 'Password', :with => "okidoki" click_button 'Sign in' click_button 'Submit' # simulating onload expect(current_url).to eq('http://foo.example.com/saml/consume') expect(page).to have_content("brad.copa@example.com") end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/app/helpers/application_helper.rb
spec/rails_app/app/helpers/application_helper.rb
module ApplicationHelper end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/app/controllers/saml_controller.rb
spec/rails_app/app/controllers/saml_controller.rb
class SamlController < ApplicationController def consume response = OneLogin::RubySaml::Response.new(params[:SAMLResponse]) render :text => response.name_id end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/app/controllers/saml_idp_controller.rb
spec/rails_app/app/controllers/saml_idp_controller.rb
class SamlIdpController < SamlIdp::IdpController def idp_authenticate(email, password) { :email => email } end def idp_make_saml_response(user) encode_SAMLResponse(user[:email]) end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/app/controllers/application_controller.rb
spec/rails_app/app/controllers/application_controller.rb
class ApplicationController < ActionController::Base protect_from_forgery end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/db/seeds.rb
spec/rails_app/db/seeds.rb
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) # Mayor.create(:name => 'Emanuel', :city => cities.first)
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/test/test_helper.rb
spec/rails_app/test/test_helper.rb
ENV["RAILS_ENV"] = "test" require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integration tests # -- they do not yet inherit this setting fixtures :all # Add more helper methods to be used by all tests here... end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/test/performance/browsing_test.rb
spec/rails_app/test/performance/browsing_test.rb
require 'test_helper' require 'rails/performance_test_help' class BrowsingTest < ActionDispatch::PerformanceTest # Refer to the documentation for all available options # self.profile_options = { :runs => 5, :metrics => [:wall_time, :memory] # :output => 'tmp/performance', :formats => [:flat] } def test_homepage get '/' end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/application.rb
spec/rails_app/config/application.rb
require File.expand_path('../boot', __FILE__) require "action_controller/railtie" require "active_resource/railtie" if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.require(:default, :assets, Rails.env) end module RailsApp class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Custom directories with classes and modules you want to be autoloadable. # config.autoload_paths += %W(#{config.root}/extras) # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. # config.plugins = [ :exception_notification, :ssl_requirement, :all ] # Activate observers that should always be running. # config.active_record.observers = :cacher, :garbage_collector, :forum_observer # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de # Configure the default encoding used in templates for Ruby 1.9. config.encoding = "utf-8" # Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password] # Use SQL instead of Active Record's schema dumper when creating the database. # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql # Enforce whitelist mode for mass assignment. # This will create an empty whitelist of attributes available for mass-assignment for all models # in your app. As such, your models will need to explicitly whitelist or blacklist accessible # parameters by using an attr_accessible or attr_protected declaration. # config.active_record.whitelist_attributes = true # Enable the asset pipeline config.assets.enabled = true # Version of your assets, change this if you want to expire all your assets config.assets.version = '1.0' end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/environment.rb
spec/rails_app/config/environment.rb
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application RailsApp::Application.initialize!
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/routes.rb
spec/rails_app/config/routes.rb
RailsApp::Application.routes.draw do get '/saml/auth' => 'saml_idp#new' post '/saml/auth' => 'saml_idp#create' post '/saml/consume' => 'saml#consume' end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/boot.rb
spec/rails_app/config/boot.rb
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/initializers/session_store.rb
spec/rails_app/config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. RailsApp::Application.config.session_store :cookie_store, :key => '_rails_app_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rails generate session_migration") # RailsApp::Application.config.session_store :active_record_store
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/initializers/wrap_parameters.rb
spec/rails_app/config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters :format => [:json] end # Disable root element in JSON by default. ActiveSupport.on_load(:active_record) do self.include_root_in_json = false end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/initializers/inflections.rb
spec/rails_app/config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections do |inflect| # inflect.acronym 'RESTful' # end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/initializers/backtrace_silencers.rb
spec/rails_app/config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/initializers/mime_types.rb
spec/rails_app/config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/initializers/secret_token.rb
spec/rails_app/config/initializers/secret_token.rb
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. RailsApp::Application.config.secret_token = '8514a9643396093754c300364a89682d50a6f9ec8cbdb9741f24600fbff044546596a48f8d333502107b143a07e0d6cb25e33e148f480073c9cb15ead7d35846'
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/environments/test.rb
spec/rails_app/config/environments/test.rb
RailsApp::Application.configure do # Settings specified here will take precedence over those in config/application.rb # 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! config.cache_classes = true # Configure static asset server for tests with Cache-Control for performance config.serve_static_assets = true config.static_cache_control = "public, max-age=3600" # Log error messages when you accidentally call methods on nil config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. #config.action_mailer.delivery_method = :test # Raise exception on mass assignment protection for Active Record models #config.active_record.mass_assignment_sanitizer = :strict # Print deprecation notices to the stderr config.active_support.deprecation = :stderr end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/environments/development.rb
spec/rails_app/config/environments/development.rb
RailsApp::Application.configure do # Settings specified here will take precedence over those in config/application.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send #config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger config.active_support.deprecation = :log # Only use best-standards-support built into browsers config.action_dispatch.best_standards_support = :builtin # Raise exception on mass assignment protection for Active Record models #config.active_record.mass_assignment_sanitizer = :strict # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) #config.active_record.auto_explain_threshold_in_seconds = 0.5 # Do not compress assets config.assets.compress = false # Expands the lines which load the assets config.assets.debug = true end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/spec/rails_app/config/environments/production.rb
spec/rails_app/config/environments/production.rb
RailsApp::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false config.action_controller.perform_caching = true # Disable Rails's static asset server (Apache or nginx will already do this) config.serve_static_assets = false # Compress JavaScripts and CSS config.assets.compress = true # Don't fallback to assets pipeline if a precompiled asset is missed config.assets.compile = false # Generate digests for assets URLs config.assets.digest = true # Defaults to Rails.root.join("public/assets") # config.assets.manifest = YOUR_PATH # Specifies the header that your server uses for sending files # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # See everything in the log (default is :info) # config.log_level = :debug # Prepend all log lines with the following tags # config.log_tags = [ :subdomain, :uuid ] # Use a different logger for distributed setups # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added) # config.assets.precompile += %w( search.js ) # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false # Enable threaded mode # config.threadsafe! # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation can not be found) config.i18n.fallbacks = true # Send deprecation notices to registered listeners config.active_support.deprecation = :notify # Log the query plan for queries taking more than this (works # with SQLite, MySQL, and PostgreSQL) # config.active_record.auto_explain_threshold_in_seconds = 0.5 end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/lib/ruby-saml-idp.rb
lib/ruby-saml-idp.rb
module SamlIdp require 'saml_idp/configurator' require 'saml_idp/controller' require 'saml_idp/default' require 'saml_idp/version' require 'saml_idp/engine' if defined?(::Rails) && Rails::VERSION::MAJOR > 2 def self.config=(config) @config = config end def self.config @config ||= SamlIdp::Configurator.new end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/lib/saml_idp/version.rb
lib/saml_idp/version.rb
module SamlIdp VERSION = '0.3.5' end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/lib/saml_idp/default.rb
lib/saml_idp/default.rb
module SamlIdp module Default NAME_ID_FORMAT = "urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress" X509_CERTIFICATE = "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURxekNDQXhTZ0F3SUJBZ0lCQVRBTkJna3Foa2lHOXcwQkFRc0ZBRENCaGpFTE1Ba0dBMVVFQmhNQ1FWVXgKRERBS0JnTlZCQWdUQTA1VFZ6RVBNQTBHQTFVRUJ4TUdVM2xrYm1WNU1Rd3dDZ1lEVlFRS0RBTlFTVlF4Q1RBSApCZ05WQkFzTUFERVlNQllHQTFVRUF3d1BiR0YzY21WdVkyVndhWFF1WTI5dE1TVXdJd1lKS29aSWh2Y05BUWtCCkRCWnNZWGR5Wlc1alpTNXdhWFJBWjIxaGFXd3VZMjl0TUI0WERURXlNRFF5T0RBeU1qSXlPRm9YRFRNeU1EUXkKTXpBeU1qSXlPRm93Z1lZeEN6QUpCZ05WQkFZVEFrRlZNUXd3Q2dZRFZRUUlFd05PVTFjeER6QU5CZ05WQkFjVApCbE41Wkc1bGVURU1NQW9HQTFVRUNnd0RVRWxVTVFrd0J3WURWUVFMREFBeEdEQVdCZ05WQkFNTUQyeGhkM0psCmJtTmxjR2wwTG1OdmJURWxNQ01HQ1NxR1NJYjNEUUVKQVF3V2JHRjNjbVZ1WTJVdWNHbDBRR2R0WVdsc0xtTnYKYlRDQm56QU5CZ2txaGtpRzl3MEJBUUVGQUFPQmpRQXdnWWtDZ1lFQXVCeXdQTmxDMUZvcEdMWWZGOTZTb3RpSwo4Tmo2L25XMDg0TzRvbVJNaWZ6eTd4OTU1UkxFeTY3M3EyYWlKTkIzTHZFNlh2a3Q5Y0d0eHROb09YdzFnMlV2CkhLcGxkUWJyNmJPRWpMTmVETlc3ajBvYitKclJ2QVVPSzlDUmdkeXc1TUM2bHdxVlFRNUMxRG5hVC8yZlNCRmoKYXNCRlRSMjRkRXBmVHk4SGZLRUNBd0VBQWFPQ0FTVXdnZ0VoTUFrR0ExVWRFd1FDTUFBd0N3WURWUjBQQkFRRApBZ1VnTUIwR0ExVWREZ1FXQkJRTkJHbW10M3l0S3BjSmFCYVlOYm55VTJ4a2F6QVRCZ05WSFNVRUREQUtCZ2dyCkJnRUZCUWNEQVRBZEJnbGdoa2dCaHZoQ0FRMEVFQllPVkdWemRDQllOVEE1SUdObGNuUXdnYk1HQTFVZEl3U0IKcXpDQnFJQVVEUVJwcHJkOHJTcVhDV2dXbURXNThsTnNaR3VoZ1l5a2dZa3dnWVl4Q3pBSkJnTlZCQVlUQWtGVgpNUXd3Q2dZRFZRUUlFd05PVTFjeER6QU5CZ05WQkFjVEJsTjVaRzVsZVRFTU1Bb0dBMVVFQ2d3RFVFbFVNUWt3CkJ3WURWUVFMREFBeEdEQVdCZ05WQkFNTUQyeGhkM0psYm1ObGNHbDBMbU52YlRFbE1DTUdDU3FHU0liM0RRRUoKQVF3V2JHRjNjbVZ1WTJVdWNHbDBRR2R0WVdsc0xtTnZiWUlCQVRBTkJna3Foa2lHOXcwQkFRc0ZBQU9CZ1FBRQpjVlVQQlg3dVptenFaSmZ5K3RVUE9UNUltTlFqOFZFMmxlcmhuRmpuR1BIbUhJcWhwemdud0hRdWpKZnMvYTMwCjlXbTVxd2NDYUMxZU81Y1dqY0cweDNPamRsbHNnWURhdGw1R0F1bXRCeDhKM05oV1JxTlVnaXRDSWtRbHhISXcKVWZnUWFDdXNoWWdEREw1WWJJUWErK2VnQ2dwSVorVDBEajVvUmV3Ly9BPT0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo=" FINGERPRINT = "9E:65:2E:03:06:8D:80:F2:86:C7:6C:77:A1:D9:14:97:0A:4D:F4:4D" SECRET_KEY = <<EOS -----BEGIN RSA PRIVATE KEY----- MIICXAIBAAKBgQC4HLA82ULUWikYth8X3pKi2Irw2Pr+dbTzg7iiZEyJ/PLvH3nl EsTLrverZqIk0Hcu8Tpe+S31wa3G02g5fDWDZS8cqmV1Buvps4SMs14M1buPShv4 mtG8BQ4r0JGB3LDkwLqXCpVBDkLUOdpP/Z9IEWNqwEVNHbh0Sl9PLwd8oQIDAQAB AoGAQmUGIUtwUEgbXe//kooPc26H3IdDLJSiJtcvtFBbUb/Ik/dT7AoysgltA4DF pGURNfqERE+0BVZNJtCCW4ixew4uEhk1XowYXHCzjkzyYoFuT9v5SP4cu4q3t1kK 51JF237F0eCY3qC3k96CzPGG67bwOu9EeXAu4ka/plLdsAECQQDkg0uhR/vsJffx tiWxcDRNFoZpCpzpdWfQBnHBzj9ZC0xrdVilxBgBpupCljO2Scy4MeiY4S1Mleel CWRqh7RBAkEAzkIjUnllEkr5sjVb7pNy+e/eakuDxvZck0Z8X3USUki/Nm3E/GPP c+CwmXR4QlpMpJr3/Prf1j59l/LAK9AwYQJBAL9eRSQYCJ3HXlGKXR6v/NziFEY7 oRTSQdIw02ueseZ8U89aQpbwFbqsclq5Ny1duJg5E7WUPj94+rl3mCSu6QECQBVh 0duY7htpXl1VHsSq0H6MmVgXn/+eRpaV9grHTjDtjbUMyCEKD9WJc4VVB6qJRezC i/bT4ySIsehwp+9i08ECQEH03lCpHpbwiWH4sD25l/z3g2jCbIZ+RTV6yHIz7Coh gAbBqA04wh64JhhfG69oTBwqwj3imlWF8+jDzV9RNNw= -----END RSA PRIVATE KEY----- EOS end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/lib/saml_idp/configurator.rb
lib/saml_idp/configurator.rb
module SamlIdp class Configurator attr_accessor :x509_certificate, :secret_key, :algorithm, :expires_in def initialize(config_file = nil) self.x509_certificate = Default::X509_CERTIFICATE self.secret_key = Default::SECRET_KEY self.algorithm = :sha1 self.expires_in = nil instance_eval(File.read(config_file), config_file) if config_file end end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/lib/saml_idp/controller.rb
lib/saml_idp/controller.rb
module SamlIdp module Controller require 'openssl' require 'base64' require 'time' require 'securerandom' attr_accessor :x509_certificate, :secret_key, :algorithm, :expires_in attr_accessor :saml_acs_url def x509_certificate return @x509_certificate if defined?(@x509_certificate) @x509_certificate = SamlIdp.config.x509_certificate end def secret_key return @secret_key if defined?(@secret_key) @secret_key = SamlIdp.config.secret_key end def algorithm return @algorithm if defined?(@algorithm) self.algorithm = SamlIdp.config.algorithm @algorithm end def algorithm=(algorithm) @algorithm = algorithm if algorithm.is_a?(Symbol) @algorithm = case algorithm when :sha256 then OpenSSL::Digest::SHA256 when :sha384 then OpenSSL::Digest::SHA384 when :sha512 then OpenSSL::Digest::SHA512 else OpenSSL::Digest::SHA1 end end @algorithm end def algorithm_name algorithm.to_s.split('::').last.downcase end def expires_in return @expires_in if defined?(@expires_in) @expires_in = SamlIdp.config.expires_in end protected def validate_saml_request(saml_request = params[:SAMLRequest]) decode_SAMLRequest(saml_request) rescue false end def decode_SAMLRequest(saml_request) zstream = Zlib::Inflate.new(-Zlib::MAX_WBITS) @saml_request = zstream.inflate(Base64.decode64(saml_request)) zstream.finish zstream.close @saml_request_id = @saml_request[/ID=['"](.+?)['"]/, 1] @saml_acs_url = @saml_request[/AssertionConsumerServiceURL=['"](.+?)['"]/, 1] end def encode_SAMLResponse(nameID, opts = {}) now = Time.now.utc response_id, reference_id = SecureRandom.uuid, SecureRandom.uuid audience_uri = opts[:audience_uri] || saml_acs_url[/^(.*?\/\/.*?\/)/, 1] issuer_uri = opts[:issuer_uri] || (defined?(request) && request.url) || "http://example.com" attributes_statement = attributes(opts[:attributes_provider], nameID) session_expiration = '' if expires_in session_expiration = %{ SessionNotOnOrAfter="#{(now + expires_in).iso8601}"} end assertion = %[<saml:Assertion xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="_#{reference_id}" IssueInstant="#{now.iso8601}" Version="2.0"><saml:Issuer Format="urn:oasis:names:SAML:2.0:nameid-format:entity">#{issuer_uri}</saml:Issuer><saml:Subject><saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress">#{nameID}</saml:NameID><saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer"><saml:SubjectConfirmationData#{@saml_request_id ? %[ InResponseTo="#{@saml_request_id}"] : ""} NotOnOrAfter="#{(now+3*60).iso8601}" Recipient="#{@saml_acs_url}"></saml:SubjectConfirmationData></saml:SubjectConfirmation></saml:Subject><saml:Conditions NotBefore="#{(now-5).iso8601}" NotOnOrAfter="#{(now+60*60).iso8601}"><saml:AudienceRestriction><saml:Audience>#{audience_uri}</saml:Audience></saml:AudienceRestriction></saml:Conditions>#{attributes_statement}<saml:AuthnStatement AuthnInstant="#{now.iso8601}" SessionIndex="_#{reference_id}"#{session_expiration}><saml:AuthnContext><saml:AuthnContextClassRef>urn:federation:authentication:windows</saml:AuthnContextClassRef></saml:AuthnContext></saml:AuthnStatement></saml:Assertion>] digest_value = Base64.encode64(algorithm.digest(assertion)).gsub(/\n/, '') signed_info = %[<ds:SignedInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"><ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:CanonicalizationMethod><ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-#{algorithm_name}"></ds:SignatureMethod><ds:Reference URI="#_#{reference_id}"><ds:Transforms><ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"></ds:Transform><ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:Transform></ds:Transforms><ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig##{algorithm_name}"></ds:DigestMethod><ds:DigestValue>#{digest_value}</ds:DigestValue></ds:Reference></ds:SignedInfo>] signature_value = sign(signed_info).gsub(/\n/, '') signature = %[<ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">#{signed_info}<ds:SignatureValue>#{signature_value}</ds:SignatureValue><KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#"><ds:X509Data><ds:X509Certificate>#{self.x509_certificate}</ds:X509Certificate></ds:X509Data></KeyInfo></ds:Signature>] assertion_and_signature = assertion.sub(/Issuer\>\<saml:Subject/, "Issuer>#{signature}<saml:Subject") xml = %[<samlp:Response ID="_#{response_id}" Version="2.0" IssueInstant="#{now.iso8601}" Destination="#{@saml_acs_url}" Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"#{@saml_request_id ? %[ InResponseTo="#{@saml_request_id}"] : ""} xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"><saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">#{issuer_uri}</saml:Issuer><samlp:Status><samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" /></samlp:Status>#{assertion_and_signature}</samlp:Response>] Base64.encode64(xml) end private def sign(data) key = OpenSSL::PKey::RSA.new(self.secret_key) Base64.encode64(key.sign(algorithm.new, data)) end def attributes(provider, nameID) provider ? provider : %[<saml:AttributeStatement><saml:Attribute Name="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress"><saml:AttributeValue>#{nameID}</saml:AttributeValue></saml:Attribute></saml:AttributeStatement>] end end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
lawrencepit/ruby-saml-idp
https://github.com/lawrencepit/ruby-saml-idp/blob/c16baa42df45d7a69556c15f9939e38edcc5bac2/lib/saml_idp/engine.rb
lib/saml_idp/engine.rb
module SamlIdp class Engine < Rails::Engine end end
ruby
MIT
c16baa42df45d7a69556c15f9939e38edcc5bac2
2026-01-04T17:45:11.326213Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/support/project_path.rb
features/support/project_path.rb
PROJECT_PATH = File.expand_path("../../..", __FILE__)
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/support/disable_bundler.rb
features/support/disable_bundler.rb
Before do unset_bundler_env_vars end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/support/rails.rb
features/support/rails.rb
module RailsAppHelpers def create_rails_app_with_kumade run_simple("rails new rake-tasks -T") cd('rake-tasks') append_to_file('Gemfile', "gem 'kumade', :path => '#{PROJECT_PATH}'") run_bundler set_up_git_repo end def create_rails_app_with_kumade_and_jammit create_rails_app_with_kumade add_jammit_to_gemfile run_bundler commit_everything_in_repo end end World(RailsAppHelpers)
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/support/env.rb
features/support/env.rb
begin require 'simplecov' rescue LoadError # Probably on 1.8.7, ignore. end require 'aruba/cucumber' require 'kumade' Before do @aruba_timeout_seconds = 60 end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/support/jammit.rb
features/support/jammit.rb
module JammitHelpers def set_up_jammit assets_yaml = <<-YAML.strip javascripts: default: - public/javascripts/application.js YAML write_file('public/javascripts/application.js', 'var foo = 3;') write_file('config/assets.yml', assets_yaml) commit_everything_in_repo('add Jammit files') end end World(JammitHelpers)
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/support/git.rb
features/support/git.rb
module GitHelpers def set_up_git_repo ["git init --template=/dev/null", "touch .gitkeep", "git add .", "git commit -am First"].each do |git_command| run_simple(git_command) end end def commit_everything_in_repo(message = "MY_MESSAGE") ['git add .', "git commit -am '#{message}'"].each do |git_command| run_simple(git_command) end end def modify_tracked_file write_file('tracked-file', 'clean') commit_everything_in_repo('modify tracked file') append_to_file('tracked-file', 'dirty it up') end end World(GitHelpers)
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/support/bundler.rb
features/support/bundler.rb
module BundlerHelpers def run_bundler bundle = 'bundle install' run_simple("#{bundle} --local || #{bundle}") end def add_jammit_to_gemfile append_to_file('Gemfile', "\ngem 'jammit'") end def add_kumade_to_gemfile append_to_file('Gemfile', "\ngem 'kumade', :path => '../../..'") end end World(BundlerHelpers)
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/support/git_remotes.rb
features/support/git_remotes.rb
module GitRemoteHelpers @@created_remotes = [] def remove_all_created_remotes in_current_dir do @@created_remotes.each do |remote| run_simple("git remote rm #{remote}") end end @@created_remotes = [] end def add_heroku_remote_named(remote_name) run_simple("git remote add #{remote_name} git@heroku.com:#{remote_name}_app.git") @@created_remotes << remote_name end def add_non_heroku_remote_named(remote_name) run_simple("git remote add #{remote_name} git@github.com:gabebw/kumade.git") @@created_remotes << remote_name end def add_origin_remote original_dir = current_dir create_dir("../origin") cd("../origin") run_simple("git init --bare") cd("../#{File.basename(original_dir)}") run_simple("git remote add origin ../origin") @@created_remotes << 'origin' end end World(GitRemoteHelpers) After do remove_all_created_remotes end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/step_definitions/git_steps.rb
features/step_definitions/git_steps.rb
When /^I create a Heroku remote named "([^"]*)"$/ do |remote_name| add_heroku_remote_named(remote_name) end When /^I create a non-Heroku remote named "([^"]*)"$/ do |remote_name| add_non_heroku_remote_named(remote_name) end When /^I set up a git repo$/ do set_up_git_repo end When /^I commit everything in the current repo$/ do commit_everything_in_repo end When /^I create an untracked file$/ do write_file("untracked-file", "anything") end Given /^a dirty repo$/ do modify_tracked_file end When /^I modify a tracked file$/ do modify_tracked_file end When /^I add the origin remote$/ do add_origin_remote end When /^I switch to the "([^"]+)" branch$/ do |branch_name| run_simple("git checkout -b #{branch_name}") end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/step_definitions/bundler_steps.rb
features/step_definitions/bundler_steps.rb
When /^I bundle$/ do run_bundler end When /^I set up the Gemfile with kumade$/ do add_kumade_to_gemfile end When /^I add "jammit" to the Gemfile$/ do add_jammit_to_gemfile end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/step_definitions/jammit_steps.rb
features/step_definitions/jammit_steps.rb
When /^I set up Jammit$/ do set_up_jammit end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/step_definitions/kumade_steps.rb
features/step_definitions/kumade_steps.rb
When /^I run kumade$/ do run_simple("bundle exec kumade", must_be_successful = false) end When /^I run kumade with "([^"]+)"$/ do |args| run_simple("bundle exec kumade #{args}", must_be_successful = false) end Given /^a directory set up for kumade$/ do create_dir('the-kumade-directory') cd('the-kumade-directory') add_kumade_to_gemfile run_bundler set_up_git_repo end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/step_definitions/rails_steps.rb
features/step_definitions/rails_steps.rb
Given /^a new Rails application with Kumade$/ do create_rails_app_with_kumade end Given /^a new Rails application with Kumade and Jammit$/ do create_rails_app_with_kumade_and_jammit end When /^I configure my Rails app for Jammit$/ do run_bundler set_up_jammit add_origin_remote end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/features/step_definitions/rake_steps.rb
features/step_definitions/rake_steps.rb
When /^I require the kumade railtie in the Rakefile$/ do rakefile_content = prep_for_fs_check { IO.readlines("Rakefile") } new_rakefile_content = rakefile_content.map do |line| if line.include?('load_tasks') ["require 'kumade/railtie'", line].join("\n") else line end end.join overwrite_file("Rakefile", new_rakefile_content) end Then /^the rake tasks should include "([^"]+)" with a description of "([^"]+)"$/ do |task_name, task_description| steps %{ When I run `bundle exec rake -T` Then the output should match /#{task_name}.+#{task_description}/ } end Then /^the rake tasks should not include "([^"]+)"/ do |task_name| steps %{ When I run `bundle exec rake -T` Then the output from "bundle exec rake -T" should not contain "#{task_name}" } end When /^I add a pre-compilation rake task that prints "Hi!"$/ do append_to_file("Rakefile", <<-CUSTOM_TASK) namespace :kumade do task :before_asset_compilation do puts 'Hi!' end end CUSTOM_TASK commit_everything_in_repo end When /^I add a pre-deploy rake task that prints "Hi!"$/ do append_to_file("Rakefile", <<-CUSTOM_TASK) namespace :kumade do task :pre_deploy do puts 'Hi!' end end CUSTOM_TASK commit_everything_in_repo end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade_spec.rb
spec/kumade_spec.rb
require 'spec_helper' describe Kumade, ".configuration" do it "returns a Kumade::Configuration instance" do Kumade.configuration.should be_a Kumade::Configuration end it "caches the configuration" do Kumade.configuration.should eq Kumade.configuration end end describe Kumade, ".configuration=" do it "sets Kumade.configuration" do Kumade.configuration = "new-value" Kumade.configuration.should == "new-value" end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/spec_helper.rb
spec/spec_helper.rb
begin require 'simplecov' rescue LoadError # Probably on 1.8.7, ignore. end require 'rspec' require 'aruba/api' require 'bourne' require 'kumade' # Since we autoload, these aren't require'd when we require kumade. require 'rake' require 'cocaine' module GitRemoteHelpers def force_add_heroku_remote(remote_name) remove_remote(remote_name) `git remote add #{remote_name} git@heroku.com:#{remote_name}.git` end def remove_remote(remote_name) `git remote rm #{remote_name} 2>/dev/null` end end spec_dir = Pathname.new(File.expand_path(File.dirname(__FILE__))) Dir[spec_dir.join('support', '**', "*.rb")].each {|f| require File.expand_path(f) } RSpec.configure do |config| config.mock_with :mocha config.color_enabled = true config.include Rake::DSL if defined?(Rake::DSL) config.include GitRemoteHelpers config.include GitHelpers config.include EnvironmentHelpers config.include Aruba::Api config.around do |example| FileUtils.rm_rf(current_dir) FileUtils.mkdir_p(current_dir) in_current_dir do `git init .` `touch .gitkeep` `git add .` `git commit -m First` example.run end end config.treat_symbols_as_metadata_keys_with_true_values = true config.before(:each, :with_mock_outputter) do Kumade.configuration.outputter = stub("Null Outputter", :success => true, :error => true, :info => true, :say_command => true) end config.after(:each, :with_mock_outputter) do Kumade.configuration.outputter = Kumade::Outputter.new end config.after do Kumade.configuration = Kumade::Configuration.new end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/support/heroku.rb
spec/support/heroku.rb
shared_context "when on Cedar" do let(:command_line) { mock("Kumade::CommandLine") } let(:stack_command) { "bundle exec heroku stack --remote staging" } let(:heroku_output) { ["aspen-mri-1.8.6", "bamboo-mri-1.9.2", "bamboo-ree-1.8.7", "* cedar (beta)"].join("\n") } before do Kumade::CommandLine.expects(:new).with(stack_command).returns(command_line) command_line.expects(:run_or_error).returns(heroku_output) end end shared_context "when not on Cedar" do let(:command_line) { mock("Kumade::CommandLine") } let(:stack_command) { "bundle exec heroku stack --remote staging" } let(:heroku_output) { ["aspen-mri-1.8.6", "* bamboo-mri-1.9.2", "bamboo-ree-1.8.7", "cedar (beta)"].join("\n") } before do Kumade::CommandLine.expects(:new).with(stack_command).returns(command_line) command_line.expects(:run_or_error).returns(heroku_output) end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/support/environments.rb
spec/support/environments.rb
module EnvironmentHelpers shared_context "with Heroku environment" do let(:environment) { 'staging' } before do force_add_heroku_remote(environment) Kumade.configuration.environment = environment end after { remove_remote(environment) } end shared_context "with Heroku-accounts environment" do let(:environment) { 'heroku-accounts' } let(:heroku_url) { 'git@heroku.work:my-app.git' } before do `git remote add #{environment} #{heroku_url}` Kumade.configuration.environment = environment end after { remove_remote(environment) } end shared_context "with non-Heroku environment" do let(:environment) { 'not-heroku' } let(:not_a_heroku_url) { 'git@github.com:gabebw/kumade.git' } before do `git remote add #{environment} #{not_a_heroku_url}` Kumade.configuration.environment = environment end after { remove_remote(environment) } end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/support/git.rb
spec/support/git.rb
module GitHelpers def dirty_the_repo `echo dirty_it_up > .gitkeep` end def create_untracked_file_in(directory) FileUtils.mkdir_p(directory) FileUtils.touch(File.join(directory, 'i-am-untracked')) end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/support/define_constant.rb
spec/support/define_constant.rb
module DefineConstant def define_constant(path, base = Object, &block) namespace, class_name = *constant_path(path) klass = Class.new(base) namespace.const_set(class_name, klass) klass.class_eval(&block) if block_given? @defined_constants << path klass end def clear_generated_constants @defined_constants.reverse.each do |path| namespace, class_name = *constant_path(path) if namespace.const_defined?(class_name) namespace.send(:remove_const, class_name) end end @defined_constants.clear end private def constant_path(constant_name) names = constant_name.split('::') class_name = names.pop namespace = names.inject(Object) { |result, name| result.const_get(name) } [namespace, class_name] end end RSpec.configure do |config| config.include DefineConstant config.before do @defined_constants = [] end config.after do clear_generated_constants end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/support/shared_examples/packager.rb
spec/support/shared_examples/packager.rb
share_examples_for "packager" do its(:assets_path) { should_not be_nil } it { should respond_to(:installed?) } it { should respond_to(:package) } end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/deployer_spec.rb
spec/kumade/deployer_spec.rb
require 'spec_helper' describe Kumade::Deployer, "#pre_deploy", :with_mock_outputter do let(:git) { subject.git } let(:rake_task_runner) { stub("RakeTaskRunner", :invoke => true) } let(:packager) { stub("packager", :run => true) } before do Kumade::Packager.stubs(:new => packager) Kumade::RakeTaskRunner.stubs(:new).with("kumade:pre_deploy").returns(rake_task_runner) end it "calls the correct methods" do git.expects(:ensure_clean_git) subject.expects(:run_pre_deploy_task) subject.expects(:package_assets) git.expects(:push).with(subject.git.current_branch) subject.pre_deploy end it "invokes the kumade:pre_deploy task" do subject.pre_deploy Kumade::RakeTaskRunner.should have_received(:new).with("kumade:pre_deploy") rake_task_runner.should have_received(:invoke) end end describe Kumade::Deployer, "#post_deploy_success", :with_mock_outputter do let(:rake_task_runner) { stub("RakeTaskRunner", :invoke => true) } before do Kumade::RakeTaskRunner.stubs(:new).with("kumade:post_deploy").returns(rake_task_runner) end it "calls the correct methods" do subject.expects(:run_post_deploy_task) subject.post_deploy_success end it "invokes the kumade:post_deploy task" do subject.post_deploy_success Kumade::RakeTaskRunner.should have_received(:new).with("kumade:post_deploy") rake_task_runner.should have_received(:invoke) end end describe Kumade::Deployer, "#deploy", :with_mock_outputter do let(:remote_name) { 'staging' } before do force_add_heroku_remote(remote_name) end it "calls the correct methods" do subject.expects(:pre_deploy) subject.heroku.expects(:sync) subject.heroku.expects(:migrate_database) subject.heroku.expects(:restart_app) subject.expects(:post_deploy) subject.expects(:post_deploy_success) subject.deploy end context "if deploy fails" do before { subject.git.stubs(:heroku_remote?).raises(RuntimeError.new("fun times")) } it "calls post_deploy" do subject.expects(:post_deploy) subject.deploy end it "prints the error" do subject.deploy Kumade.configuration.outputter.should have_received(:error).with("RuntimeError: fun times") end end end describe Kumade::Deployer, "#sync_origin", :with_mock_outputter do let(:new_branch) { 'new-branch' } before do `git checkout -b #{new_branch} 2>/dev/null` end it "pushes the current branch to origin" do subject.git.expects(:push).with(new_branch) subject.sync_origin end end describe Kumade::Deployer, "#ensure_clean_git", :with_mock_outputter do it "calls git.ensure_clean_git" do subject.git.expects(:ensure_clean_git) subject.ensure_clean_git end end describe Kumade::Deployer, "#ensure_heroku_remote_exists", :with_mock_outputter do let(:environment) { 'staging' } before do force_add_heroku_remote(environment) Kumade.configuration.environment = environment end context "when the remote points to Heroku" do it "does not print an error" do subject.ensure_heroku_remote_exists Kumade.configuration.outputter.should have_received(:error).never end it "prints a success message" do subject.ensure_heroku_remote_exists Kumade.configuration.outputter.should have_received(:success).with(regexp_matches(/#{environment} is a Heroku remote/)) end end context "when the remote does not exist" do before do remove_remote(environment) end it "prints an error" do subject.ensure_heroku_remote_exists Kumade.configuration.outputter.should have_received(:error).with(regexp_matches(/Cannot deploy: "#{environment}" remote does not exist/)) end end context "when the remote does not point to Heroku" do let(:bad_environment) { 'bad' } before do `git remote add #{bad_environment} blerg@example.com` Kumade.configuration.environment = bad_environment end it "prints an error" do subject.ensure_heroku_remote_exists Kumade.configuration.outputter.should have_received(:error).with(regexp_matches(/Cannot deploy: "#{bad_environment}" remote does not point to Heroku/)) end end end describe Kumade::Deployer, "packaging", :with_mock_outputter do let(:git) { stub("git", :current_branch => "awesome", :delete => true) } let(:packager) { stub("packager", :run => true) } before do Kumade::Git.stubs(:new => git) Kumade::Packager.stubs(:new => packager) end it "builds the correct packager" do subject.deploy Kumade::Packager.should have_received(:new).with(git) end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/packager_list_spec.rb
spec/kumade/packager_list_spec.rb
require 'spec_helper' describe Kumade::PackagerList, "detecting packages", :with_mock_outputter do it "returns an array containing the Jammit packager if Jammit is installed" do Kumade::JammitPackager.stubs(:installed? => true) Kumade::PackagerList.new.to_a.should == [Kumade::JammitPackager] end it "returns an array containing the no-op packager if no other packagers are found" do Kumade::JammitPackager.stubs(:installed? => false) Kumade::PackagerList.new.to_a.should == [Kumade::NoopPackager] end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/heroku_spec.rb
spec/kumade/heroku_spec.rb
require 'spec_helper' describe Kumade::Heroku, "DEPLOY_BRANCH", :with_mock_outputter do subject { Kumade::Heroku::DEPLOY_BRANCH } it { should == "deploy" } end describe Kumade::Heroku, "#sync", :with_mock_outputter do let(:environment) { 'staging' } before do force_add_heroku_remote(environment) subject.git.stubs(:create) subject.git.stubs(:push) end it "creates and pushes the deploy branch" do subject.sync subject.git.should have_received(:create).with("deploy") subject.git.should have_received(:push).with("deploy:master", environment, true) end end describe Kumade::Heroku, "#migrate_database", :with_mock_outputter do let(:environment) { 'staging' } before do subject.stubs(:heroku) force_add_heroku_remote(environment) end it "runs db:migrate with the correct app" do subject.migrate_database subject.should have_received(:heroku).with("rake db:migrate") end context "when pretending" do before do Kumade.configuration.pretending = true end it "does not run the command" do subject.migrate_database subject.should have_received(:heroku).never end it "prints a message" do subject.migrate_database Kumade.configuration.outputter.should have_received(:success).with(regexp_matches(/Migrated #{environment}/)) end end end describe Kumade::Heroku, "#restart_app", :with_mock_outputter do let(:environment) { 'staging' } before do subject.stubs(:heroku) force_add_heroku_remote(environment) end it "runs the heroku restart command" do subject.restart_app subject.should have_received(:heroku).with("restart") end it "prints a message" do subject.restart_app Kumade.configuration.outputter.should have_received(:success).with(regexp_matches(/Restarted #{environment}/)) end context "when pretending" do before do Kumade.configuration.pretending = true end it "does not run the command" do subject.restart_app subject.should have_received(:heroku).never end end end describe Kumade::Heroku, "#heroku", :with_mock_outputter do let(:command_instance) { stub("Kumade::CommandLine instance", :run_or_error => true) } before do Kumade::CommandLine.stubs(:new => command_instance) end context "when on Cedar" do include_context "when on Cedar" it "runs commands with `run`" do subject.heroku("rake") Kumade::CommandLine.should have_received(:new).with(regexp_matches(/bundle exec heroku run rake/)).once command_instance.should have_received(:run_or_error).once end it "runs restart command without `run`" do subject.heroku("restart") Kumade::CommandLine.should have_received(:new).with(regexp_matches(/bundle exec heroku restart/)).once command_instance.should have_received(:run_or_error).once end end context "when not on Cedar" do include_context "when not on Cedar" it "runs commands without `run`" do subject.heroku("rake") Kumade::CommandLine.should have_received(:new).with(regexp_matches(/bundle exec heroku rake/)).once command_instance.should have_received(:run_or_error).once end end end describe Kumade::Heroku, "#cedar?", :with_mock_outputter do context "when on Cedar" do include_context "when on Cedar" it "returns true" do subject.cedar?.should == true end end context "when not on Cedar" do include_context "when not on Cedar" it "returns false" do subject.cedar?.should == false end end end describe Kumade::Heroku, "#delete_deploy_branch", :with_mock_outputter do before { subject.git.stubs(:delete) } it "deletes the deploy branch" do subject.delete_deploy_branch subject.git.should have_received(:delete).with(Kumade::Heroku::DEPLOY_BRANCH, 'master').once end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/git_spec.rb
spec/kumade/git_spec.rb
require 'spec_helper' describe Kumade::Git, "#heroku_remote?", :with_mock_outputter do context "when the environment is a Heroku repository" do include_context "with Heroku environment" it { should be_heroku_remote } end context "when the environment is a Heroku repository managed with heroku-accounts" do include_context "with Heroku-accounts environment" it { should be_heroku_remote } end context "when the environment is not a Heroku repository" do include_context "with non-Heroku environment" it { should_not be_heroku_remote } end end describe Kumade::Git, ".environments", :with_mock_outputter do let(:environment) { 'staging' } let(:not_a_heroku_env) { 'fake_heroku' } let(:not_a_heroku_url) { 'git@github.com:gabebw/kumade.git' } before do force_add_heroku_remote(environment) `git remote add #{not_a_heroku_env} #{not_a_heroku_url}` end after do remove_remote(environment) remove_remote(not_a_heroku_env) end it "returns all Heroku environments" do Kumade::Git.environments.should == ["staging"] end end describe Kumade::Git, "#push", :with_mock_outputter do let(:branch) { 'branch' } let(:remote) { 'my-remote' } context "when the remote exists" do let(:command_line) { stub("Kumade::CommandLine instance", :run_or_error => true) } before do Kumade::CommandLine.stubs(:new => command_line) subject.stubs(:remote_exists? => true) end it "pushes to the correct remote" do subject.push(branch, remote) Kumade::CommandLine.should have_received(:new).with("git push #{remote} #{branch}") command_line.should have_received(:run_or_error).once end it "can force push" do subject.push(branch, remote, true) Kumade::CommandLine.should have_received(:new).with("git push -f #{remote} #{branch}") command_line.should have_received(:run_or_error).once end it "prints a success message" do subject.push(branch, remote) Kumade.configuration.outputter.should have_received(:success).with("Pushed #{branch} -> #{remote}") end end context "when the remote does not exist" do before do subject.stubs(:remote_exists? => false) end it "returns silently" do subject.push(branch) Kumade::CommandLine.should have_received(:new).never end end end describe Kumade::Git, "#create", :with_mock_outputter do let(:branch) { "my-new-branch" } it "creates a branch" do subject.create(branch) system("git show-ref #{branch} > /dev/null").should be_true end context "when the branch already exists" do before do subject.create(branch) end it "does not error" do subject.create(branch) Kumade.configuration.outputter.should have_received(:error).never end end end describe Kumade::Git, "#delete", :with_mock_outputter do let(:branch_to_delete) { 'branch_to_delete' } let(:branch_to_checkout) { 'branch_to_checkout' } before do subject.create(branch_to_delete) subject.create(branch_to_checkout) end it "switches to a branch" do subject.delete(branch_to_delete, branch_to_checkout) subject.current_branch.should == branch_to_checkout end it "deletes a branch" do subject.delete(branch_to_delete, branch_to_checkout) `git show-ref #{branch_to_delete}`.strip.should be_empty end end describe Kumade::Git, "#add_and_commit_all_assets_in", :with_mock_outputter do let(:directory) { 'assets' } before do Dir.mkdir(directory) Dir.chdir(directory) do File.open('new-file', 'w') do |f| f.write('some content') end end end it "switches to the deploy branch" do subject.add_and_commit_all_assets_in(directory) subject.current_branch.should == Kumade::Heroku::DEPLOY_BRANCH end it "uses a bland commit message" do subject.add_and_commit_all_assets_in(directory) `git log -n1 --pretty=format:%s`.should == 'Compiled assets.' end it "commits everything in the dir" do subject.add_and_commit_all_assets_in(directory) subject.should_not be_dirty end it "prints a success message" do subject.add_and_commit_all_assets_in(directory) Kumade.configuration.outputter.should have_received(:success).with('Added and committed all assets') end context "if the command fails" do let(:command_line) { mock('CommandLine', :run_or_error => nil) } before do Kumade::CommandLine.stubs(:new => command_line) end it "prints an error message if something goes wrong" do subject.add_and_commit_all_assets_in(directory) command_line.should have_received(:run_or_error).once end end end describe Kumade::Git, "#current_branch", :with_mock_outputter do it "returns the current branch" do subject.current_branch.should == 'master' `git checkout -b new-branch 2>/dev/null` subject.current_branch.should == 'new-branch' end end describe Kumade::Git, "#remote_exists?", :with_mock_outputter do context "when pretending" do before { Kumade.configuration.pretending = true } it "returns true no matter what" do subject.remote_exists?('not-a-remote').should be_true end end context "when not pretending" do let(:good_remote) { 'good-remote' } let(:bad_remote) { 'bad-remote' } before do Kumade.configuration.pretending = false force_add_heroku_remote(good_remote) end it "returns true if the remote exists" do subject.remote_exists?(good_remote).should be_true end it "returns false if the remote does not exist" do subject.remote_exists?(bad_remote).should be_false end end end describe Kumade::Git, "#dirty?", :with_mock_outputter do context "when dirty" do before { dirty_the_repo } it { should be_dirty } end context "when clean" do it { should_not be_dirty } end end describe Kumade::Git, "#ensure_clean_git", :with_mock_outputter do context "when pretending" do before do Kumade.configuration.pretending = true dirty_the_repo end it "prints a success message" do subject.ensure_clean_git Kumade.configuration.outputter.should have_received(:success).with("Git repo is clean") end end context "when repo is clean" do it "prints a success message" do subject.ensure_clean_git Kumade.configuration.outputter.should have_received(:success).with("Git repo is clean") end end context "when repo is dirty" do before { dirty_the_repo } it "prints an error message" do subject.ensure_clean_git Kumade.configuration.outputter.should have_received(:error).with("Cannot deploy: repo is not clean.") end end end describe Kumade::Git, "#has_untracked_files_in?", :with_mock_outputter do let(:untracked_dir) { 'untracked' } context "in normal mode" do before do Kumade.configuration.pretending = false create_untracked_file_in(untracked_dir) end it "detects untracked files" do subject.should have_untracked_files_in(untracked_dir) end it "detects untracked files when given an absolute path" do subject.should have_untracked_files_in(File.expand_path("./" + untracked_dir)) end it "does not get confused by tracked files" do `git add . && git commit -am Message` subject.should_not have_untracked_files_in(untracked_dir) end end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/configuration_spec.rb
spec/kumade/configuration_spec.rb
require 'spec_helper' describe Kumade::Configuration, "by default" do its(:environment) { should == 'staging' } it { should_not be_pretending } end describe Kumade::Configuration, "#outputter" do it "defaults to a Kumade::Outputter instance" do subject.outputter.should be_a Kumade::Outputter end end describe Kumade::Configuration, "#outputter=" do it "sets outputter" do subject.outputter = "new-value" subject.outputter.should == "new-value" end end describe Kumade::Configuration, "#pretending" do it "has read/write access for the pretending attribute" do subject.pretending = true subject.should be_pretending end end describe Kumade::Configuration, "#pretending?" do it "returns false when not pretending" do subject.pretending = false subject.should_not be_pretending end it "returns true when pretending" do subject.pretending = true subject.should be_pretending end it "defaults to false" do subject.should_not be_pretending end end describe Kumade::Configuration, "#environment" do it "has read/write access for the environment attribute" do subject.environment = 'new-environment' subject.environment.should == 'new-environment' end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/cli_spec.rb
spec/kumade/cli_spec.rb
require 'spec_helper' describe Kumade::CLI, :with_mock_outputter do let(:out) { StringIO.new } let(:environment) { 'my-environment' } let(:deployer) { stub("Deployer", :new => deployer_instance) } let(:deployer_instance) { stub("DeployerInstance", :deploy => nil) } before { Kumade::CLI.deployer = deployer } after { Kumade::CLI.deployer = nil } context "when pretending" do %w(-p --pretend).each do |pretend_flag| subject { Kumade::CLI.new([pretend_flag, environment], out) } context pretend_flag do it "sets pretending to true" do subject Kumade.configuration.should be_pretending end it "deploys" do subject deployer_instance.should have_received(:deploy) end end end end context "with no command-line arguments" do subject { Kumade::CLI.new([], out) } it "sets the environment to staging" do Kumade.configuration.environment.should == 'staging' end it "sets pretending to false" do Kumade.configuration.should_not be_pretending end end context "running normally" do subject { Kumade::CLI.new([environment], out) } it "sets pretending to false" do subject Kumade.configuration.should_not be_pretending end it "deploys" do subject deployer_instance.should have_received(:deploy) end end end describe Kumade::CLI, ".deployer" do after { Kumade::CLI.deployer = nil } it "sets the deployer to the Deployer class by default" do Kumade::CLI.deployer.should == Kumade::Deployer end it "can override deployer" do Kumade::CLI.deployer = "deployer!" Kumade::CLI.deployer.should == "deployer!" end end describe Kumade::CLI, ".swapping_stdout_for" do let!(:stdout) { $stdout } let(:output) { StringIO.new } before do stdout.stubs(:print => nil, :puts => nil) end it 'does not let anything get printed' do Kumade::CLI.swapping_stdout_for(output) do $stdout.puts "Hello, you can't see me." end stdout.should have_received(:print).never stdout.should have_received(:puts).never output.rewind output.read.should == "Hello, you can't see me.\n" end context 'when print_output is false' do subject do Kumade::CLI.swapping_stdout_for(output) do $stdout.puts "Hello, you can see me!" raise Kumade::DeploymentError.new("error") end end it 'dumps the output stash to real stdout when an error happens, exits with non-zero status' do expect { subject }.should raise_error SystemExit stdout.should have_received(:print).with("Hello, you can see me!\n") end end context "in print output mode" do it 'prints everything' do Kumade::CLI.swapping_stdout_for(output, true) do $stdout.puts "Hello, you can see me!" end stdout.should have_received(:puts).with("Hello, you can see me!") end end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/packager_spec.rb
spec/kumade/packager_spec.rb
require 'spec_helper' describe Kumade::Packager, ".available_packager", :with_mock_outputter do let(:packager_1) { "1st packager" } let(:packager_2) { "2nd packager" } it "returns the first available packager" do Kumade::PackagerList.stubs(:new => [packager_1, packager_2]) Kumade::Packager.available_packager.should == packager_1 end it "returns nil if no packagers are available" do Kumade::PackagerList.stubs(:new => []) Kumade::Packager.available_packager.should be_nil end end describe Kumade::Packager, "#run", :with_mock_outputter do let(:git) { stub("git", :dirty? => true, :add_and_commit_all_assets_in => true) } let(:packager) { stub("packager", :name => "MyPackager", :package => true, :assets_path => 'fake_assets_path', :installed? => true) } let(:rake_task_runner) { stub("RakeTaskRunner", :invoke => true) } before do Kumade::RakeTaskRunner.stubs(:new => rake_task_runner) end subject { Kumade::Packager.new(git, packager) } it "precompiles assets" do subject.run Kumade::RakeTaskRunner.should have_received(:new).with("kumade:before_asset_compilation") rake_task_runner.should have_received(:invoke) end context "when packaging with a packager" do context "when pretending" do before do Kumade.configuration.pretending = true end it "prints a success message" do subject.run Kumade.configuration.outputter.should have_received(:success).with("Packaged with MyPackager") end it "does not package" do subject.run packager.should have_received(:package).never end end context "when not pretending" do before do Kumade.configuration.pretending = false end it "prints a success message" do subject.run Kumade.configuration.outputter.should have_received(:success).with("Packaged with MyPackager") end it "packages" do subject.run packager.should have_received(:package).once end it "prints an error if an exception is raised" do packager.stubs(:package).raises(RuntimeError.new("my specific error")) subject.run Kumade.configuration.outputter.should have_received(:error).with("Error: RuntimeError: my specific error") end end end context "when packaging and the repository becomes dirty" do before do Kumade.configuration.pretending = false git.stubs(:dirty? => true) end it "performs a commit" do subject.run git.should have_received(:add_and_commit_all_assets_in).with(packager.assets_path) end it "prints the success message after committing" do git.stubs(:add_and_commit_all_assets_in).raises(RuntimeError.new("something broke")) subject.run Kumade.configuration.outputter.should have_received(:success).never end end context "when packaging and the repository is not dirty" do before do Kumade.configuration.pretending = false git.stubs(:dirty? => false) end it "does not print a success message" do subject.run Kumade.configuration.outputter.should have_received(:success).never end it "doesn't perform a commit" do subject.run git.should have_received(:add_and_commit_all_assets_in).never end end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/rake_task_runner_spec.rb
spec/kumade/rake_task_runner_spec.rb
require "spec_helper" describe Kumade::RakeTaskRunner, :with_mock_outputter do context "when the task doesn't exist" do subject { Kumade::RakeTaskRunner.new("bogus:task") } it "does not notify the user that the task was run successfully" do subject.invoke Kumade.configuration.outputter.should have_received(:success).never end end context "when Rakefile exists" do subject { Kumade::RakeTaskRunner.new("bogus:task") } before do File.stubs(:exist?).with("Rakefile").returns(true) end it "loads the Rakefile" do subject.stubs(:load).with("Rakefile") subject.invoke subject.should have_received(:load).with("Rakefile") end end context "when the task exists" do let(:task_name) { "kumade:test:custom_task_name" } let(:invoked_task) { stub("invoked", :invoke! => false) } before do Rake::Task.define_task task_name do invoked_task.invoke! end end after do Rake::Task[task_name].reenable end subject { Kumade::RakeTaskRunner.new(task_name) } context "when pretending" do before do Kumade.configuration.pretending = true end it "notifies the user that the task was run successfully" do subject.invoke Kumade.configuration.outputter.should have_received(:success).with("Running rake task: #{task_name}") end it "does not invoke the task" do subject.invoke invoked_task.should have_received(:invoke!).never end end context "when not pretending" do before do Kumade.configuration.pretending = false end it "notifies the user that the task was run successfully" do subject.invoke Kumade.configuration.outputter.should have_received(:success).with("Running rake task: #{task_name}") end it "invokes the task" do subject.invoke invoked_task.should have_received(:invoke!).once end end end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/outputter_spec.rb
spec/kumade/outputter_spec.rb
require 'spec_helper' describe Kumade::Outputter, "#success" do before { STDOUT.stubs(:puts) } it "prints a message to STDOUT" do subject.success("woo hoo") STDOUT.should have_received(:puts).with(regexp_matches(/==> woo hoo/)) end end describe Kumade::Outputter, "#error" do before { STDOUT.stubs(:puts) } it "raises a DeploymentError with the given message" do lambda { subject.error("uh oh") }.should raise_error(Kumade::DeploymentError, "uh oh") end it "prints a message to STDOUT" do subject.error("uh oh") rescue nil STDOUT.should have_received(:puts).with(regexp_matches(/==> ! uh oh/)) end end describe Kumade::Outputter, "#info" do before { STDOUT.stubs(:puts) } it "prints a message to STDOUT" do subject.info("the more you know") STDOUT.should have_received(:puts).with(regexp_matches(/==> the more you know/)) end end describe Kumade::Outputter, "#say_command" do before { STDOUT.stubs(:puts) } it "prints a formatted message to STDOUT" do subject.say_command("git checkout master") STDOUT.should have_received(:puts).with(" " * 8 + "git checkout master") end end describe Kumade::Outputter, "#info" do before { STDOUT.stubs(:puts) } it "prints a message to STDOUT" do subject.info("the more you know") STDOUT.should have_received(:puts).with(regexp_matches(/==> the more you know/)) end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/command_line_spec.rb
spec/kumade/command_line_spec.rb
require 'spec_helper' describe Kumade::CommandLine, "#run_or_error", :with_mock_outputter do subject { Kumade::CommandLine.new("echo") } context "when pretending" do let(:command_line) { stub("Cocaine::CommandLine instance", :run => "does-not-matter", :command => 'command') } before do Cocaine::CommandLine.stubs(:new).returns(command_line) Kumade.configuration.pretending = true end it "does not run the command" do subject.run_or_error command_line.should have_received(:run).never end it "prints the command" do subject.run_or_error Kumade.configuration.outputter.should have_received(:say_command).with(command_line.command).once end end context "when successful" do let(:command_line) { stub("Cocaine::CommandLine instance", :run => command_line_result, :command => 'command') } let(:command_line_result) { "result" } before do Cocaine::CommandLine.stubs(:new).returns(command_line) Kumade.configuration.pretending = false end it "returns the result of running the command" do subject.run_or_error.should == command_line_result end end context "when unsuccessful" do subject { Kumade::CommandLine.new("BAD COMMAND") } before do Kumade.configuration.pretending = false end it "prints an error message" do subject.run_or_error("something bad") Kumade.configuration.outputter.should have_received(:error).with("something bad") end end end describe Kumade::CommandLine, "#run_with_status", :with_mock_outputter do let(:command) { "echo blah" } let(:command_line_result) { "blah\n" } let(:command_line) { stub("Cocaine::CommandLine instance", :run => command_line_result, :command => command) } subject { Kumade::CommandLine.new(command) } before do Cocaine::CommandLine.stubs(:new).returns(command_line) end it "prints the command" do subject.run_with_status Kumade.configuration.outputter.should have_received(:say_command).with(command).once end context "when pretending" do before { Kumade.configuration.pretending = true } it "does not run the command" do subject.run_with_status command_line.should have_received(:run).never end it "returns true" do subject.run_with_status.should == true end end context "when not pretending" do before { Kumade.configuration.pretending = false } it "runs the command" do subject.run_with_status command_line.should have_received(:run).once end it "returns the result of running the command" do subject.run_with_status.should == command_line_result end end end describe Kumade::CommandLine, "#run", :with_mock_outputter do context "when successful" do subject { Kumade::CommandLine.new("echo -n blah") } it "returns the result of running the command" do subject.run.should == "blah" end end context "when unsuccessful" do let(:bad_command) { "grep FAKE NOT_A_FILE" } subject { Kumade::CommandLine.new("#{bad_command} 2>/dev/null") } it "returns false" do subject.run.should be_false end end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/packagers/noop_packager_spec.rb
spec/kumade/packagers/noop_packager_spec.rb
require "spec_helper" describe Kumade::NoopPackager do subject { Kumade::NoopPackager } it_should_behave_like "packager" its(:assets_path) { should == "" } it { should_not be_installed } end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/spec/kumade/packagers/jammit_packager_spec.rb
spec/kumade/packagers/jammit_packager_spec.rb
require "spec_helper" require "jammit" describe Kumade::JammitPackager, :with_mock_outputter do subject { Kumade::JammitPackager } it_should_behave_like "packager" it "has the correct asset path" do subject.assets_path.should == File.join(jammit_public_root, Jammit.package_path) end it "knows how to package itself" do ::Jammit.stubs(:package!) subject.package ::Jammit.should have_received(:package!).once end context "when Jammit is defined" do before { Jammit } it { should be_installed } end context "when Jammit is not defined" do before { Object.send(:remove_const, :Jammit) } it { should_not be_installed } end def jammit_public_root defined?(Jammit.public_root) ? Jammit.public_root : Jammit::PUBLIC_ROOT end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/lib/kumade.rb
lib/kumade.rb
require 'kumade/railtie' module Kumade autoload :Git, "kumade/git" autoload :Deployer, "kumade/deployer" autoload :CLI, "kumade/cli" autoload :DeploymentError, "kumade/deployment_error" autoload :Configuration, "kumade/configuration" autoload :Heroku, "kumade/heroku" autoload :Packager, "kumade/packager" autoload :JammitPackager, "kumade/packagers/jammit_packager" autoload :NoopPackager, "kumade/packagers/noop_packager" autoload :PackagerList, "kumade/packager_list" autoload :RakeTaskRunner, "kumade/rake_task_runner" autoload :CommandLine, "kumade/command_line" autoload :Outputter, "kumade/outputter" def self.configuration @@configuration ||= Configuration.new end def self.configuration=(new_configuration) @@configuration = new_configuration end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/lib/kumade/packager.rb
lib/kumade/packager.rb
module Kumade class Packager def initialize(git, packager = Packager.available_packager) @packager = packager @git = git end def run if @packager.installed? precompile_assets package end end def self.available_packager Kumade::PackagerList.new.first end private def precompile_assets RakeTaskRunner.new("kumade:before_asset_compilation").invoke end def package return Kumade.configuration.outputter.success(success_message) if Kumade.configuration.pretending? begin @packager.package if @git.dirty? || @git.has_untracked_files_in?(@packager.assets_path) @git.add_and_commit_all_assets_in(@packager.assets_path) Kumade.configuration.outputter.success(success_message) end rescue => packager_exception Kumade.configuration.outputter.error("Error: #{packager_exception.class}: #{packager_exception.message}") end end def success_message "Packaged with #{@packager.name}" end end end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false
thoughtbot/kumade
https://github.com/thoughtbot/kumade/blob/271510307b7037695988aa4881c7c17445cc9d1d/lib/kumade/version.rb
lib/kumade/version.rb
module Kumade VERSION = "0.8.2" end
ruby
MIT
271510307b7037695988aa4881c7c17445cc9d1d
2026-01-04T17:45:11.500917Z
false