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 |
|---|---|---|---|---|---|---|---|---|
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/lib/generators/rspec/request/templates/request_spec.rb | lib/generators/rspec/request/templates/request_spec.rb | require 'rails_helper'
RSpec.describe "<%= class_name.pluralize %>", <%= type_metatag(:request) %> do
describe "GET /<%= name.underscore.pluralize %>" do
it "works! (now write some real specs)" do
get <%= index_helper %>_path
expect(response).to have_http_status(200)
end
end
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/lib/generators/rspec/job/job_generator.rb | lib/generators/rspec/job/job_generator.rb | require 'generators/rspec'
module Rspec
module Generators
# @private
class JobGenerator < Base
def create_job_spec
file_suffix = file_name.end_with?('job') ? 'spec.rb' : 'job_spec.rb'
template 'job_spec.rb.erb', target_path('jobs', class_path, [file_name, file_suffix].join('_'))
e... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/lib/generators/rspec/install/install_generator.rb | lib/generators/rspec/install/install_generator.rb | require "rspec/support"
require "rspec/core"
RSpec::Support.require_rspec_core "project_initializer"
require "rspec/rails/feature_check"
module Rspec
module Generators
# @private
class InstallGenerator < ::Rails::Generators::Base
desc <<DESC
Description:
Copy rspec files to your application.
DESC
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/lib/generators/rspec/install/templates/spec/rails_helper.rb | lib/generators/rspec/install/templates/spec/rails_helper.rb | # This file is copied to spec/ when you run 'rails generate rspec:install'
require 'spec_helper'
ENV['RAILS_ENV'] ||= 'test'
require_relative '../config/environment'
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
<% i... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/test_helper.rb | test/test_helper.rb | # Configure Rails Environment
ENV["RAILS_ENV"] = "test"
require 'bundler/setup'
require 'rails'
require 'rails/test_help'
require 'rails-api'
def rails3?
Rails::API.rails3?
end
class ActiveSupport::TestCase
def self.app
@@app ||= Class.new(Rails::Application) do
def self.name
'TestApp'
en... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/api_application/api_application_test.rb | test/api_application/api_application_test.rb | require 'test_helper'
require 'action_controller/railtie'
require 'rack/test'
class OmgController < ActionController::API
def index
render :text => "OMG"
end
def unauthorized
render :text => "get out", :status => :unauthorized
end
end
class ApiApplicationTest < ActiveSupport::TestCase
include ::Rac... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/generators/app_generator_test.rb | test/generators/app_generator_test.rb | require 'generators/generators_test_helper'
require 'rails-api/generators/rails/app/app_generator'
class AppGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
arguments [destination_root]
def test_skeleton_is_created
run_generator
default_files.each { |path| assert_file path }
... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/generators/generators_test_helper.rb | test/generators/generators_test_helper.rb | require 'test_helper'
require 'rails/generators'
module GeneratorsTestHelper
def self.included(base)
base.class_eval do
destination File.expand_path("../../tmp", __FILE__)
setup :prepare_destination
teardown :remove_destination
begin
base.tests Rails::Generators.const_get(base... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/generators/resource_generator_test.rb | test/generators/resource_generator_test.rb | require 'generators/generators_test_helper'
require 'rails/generators/rails/resource/resource_generator'
class ResourceGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
arguments %w(account)
setup :copy_routes
def test_resource_routes_are_added
run_generator
assert_file "confi... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/generators/scaffold_generator_test.rb | test/generators/scaffold_generator_test.rb | require 'generators/generators_test_helper'
require 'rails/generators/rails/scaffold/scaffold_generator'
class ScaffoldGeneratorTest < Rails::Generators::TestCase
include GeneratorsTestHelper
arguments %w(product_line title:string product:belongs_to user:references)
setup :copy_routes
def test_scaffold_on_in... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/generators/fixtures/routes.rb | test/generators/fixtures/routes.rb | Rails.application.routes.draw do
end
| ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/api_controller/url_for_test.rb | test/api_controller/url_for_test.rb | require 'test_helper'
class UrlForApiController < ActionController::API
def one; end
def two; end
end
class UrlForApiTest < ActionController::TestCase
tests UrlForApiController
def setup
super
@request.host = 'www.example.com'
end
def test_url_for
get :one
assert_equal "http://www.exampl... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/api_controller/renderers_test.rb | test/api_controller/renderers_test.rb | require 'test_helper'
require 'active_support/core_ext/hash/conversions'
class Model
def to_json(options = {})
{ :a => 'b' }.to_json(options)
end
def to_xml(options = {})
{ :a => 'b' }.to_xml(options)
end
end
class RenderersApiController < ActionController::API
use ActionDispatch::ShowExceptions, R... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/api_controller/force_ssl_test.rb | test/api_controller/force_ssl_test.rb | require 'test_helper'
class ForceSSLApiController < ActionController::API
force_ssl
def one; end
def two
head :ok
end
end
class ForceSSLApiTest < ActionController::TestCase
tests ForceSSLApiController
def test_redirects_to_https
get :two
assert_response 301
assert_equal "https://test.hos... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/api_controller/redirect_to_test.rb | test/api_controller/redirect_to_test.rb | require 'test_helper'
class RedirectToApiController < ActionController::API
def one
redirect_to :action => "two"
end
def two; end
end
class RedirectToApiTest < ActionController::TestCase
tests RedirectToApiController
def test_redirect_to
get :one
assert_response :redirect
assert_equal "htt... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/api_controller/data_streaming_test.rb | test/api_controller/data_streaming_test.rb | require 'test_helper'
module TestApiFileUtils
def file_name() File.basename(__FILE__) end
def file_path() File.expand_path(__FILE__) end
def file_data() @data ||= File.open(file_path, 'rb') { |f| f.read } end
end
class DataStreamingApiController < ActionController::API
include TestApiFileUtils
def one; end... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/api_controller/action_methods_test.rb | test/api_controller/action_methods_test.rb | require 'test_helper'
class ActionMethodsApiController < ActionController::API
def one; end
def two; end
# Rails 5 does not have method hide_action
if Rails::VERSION::MAJOR < 5
hide_action :two
end
end
class ActionMethodsApiTest < ActionController::TestCase
tests ActionMethodsApiController
def test... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/test/api_controller/conditional_get_test.rb | test/api_controller/conditional_get_test.rb | require 'test_helper'
require 'active_support/core_ext/integer/time'
require 'active_support/core_ext/numeric/time'
class ConditionalGetApiController < ActionController::API
before_filter :handle_last_modified_and_etags, :only => :two
def one
if stale?(:last_modified => Time.now.utc.beginning_of_day, :etag =>... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/rails-api.rb | lib/rails-api.rb | require 'rails/version'
require 'rails-api/version'
require 'rails-api/action_controller/api'
require 'rails-api/application'
module Rails
module API
def self.rails3?
Rails::VERSION::MAJOR == 3
end
end
end
| ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/rails-api/public_exceptions.rb | lib/rails-api/public_exceptions.rb | module Rails
module API
class PublicExceptions
attr_accessor :public_path
def initialize(public_path)
@public_path = public_path
end
def call(env)
exception = env["action_dispatch.exception"]
status = env["PATH_INFO"][1..-1]
request = ActionD... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/rails-api/version.rb | lib/rails-api/version.rb | module Rails
module API
VERSION = '0.4.1'
end
end
| ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/rails-api/application.rb | lib/rails-api/application.rb | require 'rails/application'
require 'rails-api/public_exceptions'
require 'rails-api/application/default_rails_four_middleware_stack'
module Rails
class Application < Engine
alias_method :rails_default_middleware_stack, :default_middleware_stack
def default_middleware_stack
if Rails::API.rails3?
... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/rails-api/application/default_rails_four_middleware_stack.rb | lib/rails-api/application/default_rails_four_middleware_stack.rb | module Rails
class Application
class DefaultRailsFourMiddlewareStack
attr_reader :config, :paths, :app
def initialize(app, config, paths)
@app = app
@config = config
@paths = paths
end
def build_stack
ActionDispatch::MiddlewareStack.new.tap do |middleware|... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/rails-api/generators/rails/app/app_generator.rb | lib/rails-api/generators/rails/app/app_generator.rb | require 'rails/generators'
require 'rails/generators/rails/app/app_generator'
Rails::Generators::AppGenerator.source_paths.unshift(
File.expand_path('../../../../templates/rails/app', __FILE__)
)
class Rails::AppBuilder
undef tmp
undef vendor
end
| ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/rails-api/templates/rails/scaffold_controller/controller.rb | lib/rails-api/templates/rails/scaffold_controller/controller.rb | <% module_namespacing do -%>
class <%= controller_class_name %>Controller < ApplicationController
before_action <%= ":set_#{singular_table_name}" %>, only: [:show, :update, :destroy]
# GET <%= route_url %>
# GET <%= route_url %>.json
def index
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/rails-api/templates/test_unit/scaffold/functional_test.rb | lib/rails-api/templates/test_unit/scaffold/functional_test.rb | require 'test_helper'
<% module_namespacing do -%>
class <%= controller_class_name %>ControllerTest < ActionController::TestCase
setup do
@<%= singular_table_name %> = <%= table_name %>(:one)
end
test "should get index" do
get :index
assert_response :success
assert_not_nil assigns(:<%= table_nam... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/rails-api/action_controller/api.rb | lib/rails-api/action_controller/api.rb | require 'action_view'
require 'action_controller'
require 'action_controller/log_subscriber'
module ActionController
# API Controller is a lightweight version of <tt>ActionController::Base</tt>,
# created for applications that don't require all functionality that a complete
# \Rails controller provides, allowing... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
rails-api/rails-api | https://github.com/rails-api/rails-api/blob/91c6c35a3babfcec535e7e2469eca8aa49289b4a/lib/generators/rails/api_resource_route/api_resource_route_generator.rb | lib/generators/rails/api_resource_route/api_resource_route_generator.rb | require 'rails/generators/rails/resource_route/resource_route_generator'
module Rails
module Generators
class ApiResourceRouteGenerator < ResourceRouteGenerator
def add_resource_route
return if options[:actions].present?
route_config = regular_class_path.collect{ |namespace| "namespace :#{... | ruby | MIT | 91c6c35a3babfcec535e7e2469eca8aa49289b4a | 2026-01-04T15:44:04.272150Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/action_class_finder_spec.rb | spec/action_class_finder_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
require 'formtastic/action_class_finder'
RSpec.describe Formtastic::ActionClassFinder do
include FormtasticSpecHelper
it_behaves_like 'Specialized Class Finder' do
let(:default) { Formtastic::Actions }
let(:namespaces_setting) { :action... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/namespaced_class_finder_spec.rb | spec/namespaced_class_finder_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
require 'formtastic/namespaced_class_finder'
RSpec.describe Formtastic::NamespacedClassFinder do
include FormtasticSpecHelper
before do
stub_const('SearchPath', Module.new)
end
let(:search_path) { [ SearchPath ] }
subject(:finder) { ... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/localizer_spec.rb | spec/localizer_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Formtastic::Localizer' do
describe "Cache" do
before do
@cache = Formtastic::Localizer::Cache.new
@key = ['model', 'name']
@undefined_key = ['model', 'undefined']
@cache.set(@key, 'value')
end
... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/input_class_finder_spec.rb | spec/input_class_finder_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
require 'formtastic/input_class_finder'
RSpec.describe Formtastic::InputClassFinder do
it_behaves_like 'Specialized Class Finder' do
let(:default) { Formtastic::Inputs }
let(:namespaces_setting) { :input_namespaces }
end
end
| ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/i18n_spec.rb | spec/i18n_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Formtastic::I18n' do
FORMTASTIC_KEYS = [:required, :yes, :no, :create, :update].freeze
it "should be defined" do
expect { Formtastic::I18n }.not_to raise_error
end
describe "default translations" do
it "should be d... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/fast_spec_helper.rb | spec/fast_spec_helper.rb | # encoding: utf-8
# frozen_string_literal: true
$LOAD_PATH << 'lib/formtastic'
require 'active_support/all'
require 'localized_string'
require 'inputs'
require 'helpers'
class MyInput
include Formtastic::Inputs::Base
end
I18n.enforce_available_locales = false if I18n.respond_to?(:enforce_available_locales)
| ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/schema.rb | spec/schema.rb | # frozen_string_literal: true
ActiveRecord::Schema.define(version: 20170208011723) do
create_table "posts", force: :cascade do |t|
t.integer "author_id", limit: 4, null: false
end
create_table "authors", force: :cascade do |t|
t.integer "age", limit: 4, null: false
t.string "name", limi... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/spec_helper.rb | spec/spec_helper.rb | # encoding: utf-8
# frozen_string_literal: true
require 'rubygems'
require 'bundler/setup'
require 'active_support'
require 'action_pack'
require 'action_view'
require 'action_controller'
require 'action_dispatch'
require 'active_record'
ActiveRecord::Base.establish_connection('url' => 'sqlite3::memory:', 'pool' => 1)... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/support/custom_macros.rb | spec/support/custom_macros.rb | # encoding: utf-8
# frozen_string_literal: true
module CustomMacros
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def it_should_have_input_wrapper_with_class(class_name)
it "should have input wrapper with class '#{class_name}'" do
expect(output_buffer.to_str).... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/support/deprecation.rb | spec/support/deprecation.rb | # frozen_string_literal: true
def with_deprecation_silenced(&block)
::Formtastic::Deprecation.silence do
yield
end
end
| ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/support/test_environment.rb | spec/support/test_environment.rb | # encoding: utf-8
# frozen_string_literal: true
require 'rspec/core'
require 'rspec-dom-testing'
RSpec.configure do |config|
config.include CustomMacros
config.include RSpec::Dom::Testing::Matchers
config.mock_with :rspec
# rspec-rails 3 will no longer automatically infer an example group's spec type
# fro... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/support/shared_examples.rb | spec/support/shared_examples.rb | # frozen_string_literal: true
RSpec.shared_context 'form builder' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
after do
::I18n.backend.reload!
end
end
| ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/support/specialized_class_finder_shared_example.rb | spec/support/specialized_class_finder_shared_example.rb | # encoding: utf-8
# frozen_string_literal: true
#
RSpec.shared_examples 'Specialized Class Finder' do
let(:builder) { Formtastic::FormBuilder.allocate }
subject(:finder) { described_class.new(builder) }
context 'by default' do
it 'includes Object and the default namespaces' do
expect(finder.namespaces)... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/builder/custom_builder_spec.rb | spec/builder/custom_builder_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Formtastic::Helpers::FormHelper.builder' do
include FormtasticSpecHelper
class MyCustomFormBuilder < Formtastic::FormBuilder
end
# TODO should be a separate spec for custom inputs
class Formtastic::Inputs::AwesomeInput
... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/builder/semantic_fields_for_spec.rb | spec/builder/semantic_fields_for_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Formtastic::FormBuilder#fields_for' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
allow(@new_post).to receive(:author).and_return(::Author.new)
end
c... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/builder/error_proc_spec.rb | spec/builder/error_proc_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Rails field_error_proc' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
it "should not be overridden globally for all form builders" do
current_fie... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/helpers/input_helper_spec.rb | spec/helpers/input_helper_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'with input class finder' do
include_context 'form builder'
before do
@errors = double('errors')
allow(@errors).to receive(:[]).and_return([])
allow(@new_post).to receive(:errors).and_return(@errors)
end
describe... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | true |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/helpers/actions_helper_spec.rb | spec/helpers/actions_helper_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Formtastic::FormBuilder#actions' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe 'with a block' do
describe 'when no options are provided'... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/helpers/semantic_errors_helper_spec.rb | spec/helpers/semantic_errors_helper_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Formtastic::FormBuilder#semantic_errors' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
@title_errors = ['must not be blank', 'must be awesome']
@base_... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/helpers/reflection_helper_spec.rb | spec/helpers/reflection_helper_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Formtastic::Helpers::Reflection' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
class ReflectionTester
include Formtastic::Helpers::Reflection
... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/helpers/inputs_helper_spec.rb | spec/helpers/inputs_helper_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Formtastic::FormBuilder#inputs' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe 'with a block (block forms syntax)' do
describe 'when no ... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/helpers/action_helper_spec.rb | spec/helpers/action_helper_spec.rb | # frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'with action class finder' do
include_context 'form builder'
describe 'arguments and options' do
it 'should require the first argument (the action method)' do
expect {
concat(semantic_form_for(@new_post) do |builder|
c... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/helpers/form_helper_spec.rb | spec/helpers/form_helper_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'FormHelper' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe '#semantic_form_for' do
it 'yields an instance of Formtastic::FormBuilder' do... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/actions/button_action_spec.rb | spec/actions/button_action_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'ButtonAction', 'when submitting' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
concat(semantic_form_for(@new_post) do |builder|
concat(builder.acti... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/actions/input_action_spec.rb | spec/actions/input_action_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'InputAction', 'when submitting' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
concat(semantic_form_for(@new_post) do |builder|
concat(builder.actio... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/actions/generic_action_spec.rb | spec/actions/generic_action_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'InputAction::Base' do
# Most basic Action class to test Base
class ::GenericAction
include ::Formtastic::Actions::Base
def supported_methods
[:submit, :reset, :cancel]
end
def to_html
wrapper do
... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/actions/link_action_spec.rb | spec/actions/link_action_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'LinkAction', 'when cancelling' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
context 'without a :url' do
before do
concat(semantic_form_for... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/generators/formtastic/stylesheets/stylesheets_generator_spec.rb | spec/generators/formtastic/stylesheets/stylesheets_generator_spec.rb | # frozen_string_literal: true
require 'spec_helper'
# Generators are not automatically loaded by Rails
require 'generators/formtastic/stylesheets/stylesheets_generator'
RSpec.describe Formtastic::StylesheetsGenerator do
# Tell the generator where to put its output (what it thinks of as Rails.root)
destination Fil... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/generators/formtastic/input/input_generator_spec.rb | spec/generators/formtastic/input/input_generator_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'generators/formtastic/input/input_generator'
RSpec.describe Formtastic::InputGenerator do
include FormtasticSpecHelper
destination File.expand_path("../../../../../tmp", __FILE__)
before do
prepare_destination
end
after do
FileUtils.rm_... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/generators/formtastic/form/form_generator_spec.rb | spec/generators/formtastic/form/form_generator_spec.rb | # frozen_string_literal: true
require 'spec_helper'
# Generators are not automatically loaded by Rails
require 'generators/formtastic/form/form_generator'
RSpec.describe Formtastic::FormGenerator do
include FormtasticSpecHelper
# Tell the generator where to put its output (what it thinks of as Rails.root)
des... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/generators/formtastic/install/install_generator_spec.rb | spec/generators/formtastic/install/install_generator_spec.rb | # frozen_string_literal: true
require 'spec_helper'
# Generators are not automatically loaded by Rails
require 'generators/formtastic/install/install_generator'
RSpec.describe Formtastic::InstallGenerator do
# Tell the generator where to put its output (what it thinks of as Rails.root)
destination File.expand_pat... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/custom_input_spec.rb | spec/inputs/custom_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
# TODO extract out
module TestInputs
def input_args
@template = self
@object = ::Post.new
@object_name = 'post'
@method = :title
@options = {}
@proc = Proc.new {}
@builder = Formtastic::FormBuilder.new(@object_name, @o... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/url_input_spec.rb | spec/inputs/url_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'url input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "when object is provided" do
before do
concat(semantic_form_for(@new_post... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/placeholder_spec.rb | spec/inputs/placeholder_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'string input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
after do
::I18n.backend.reload!
end
describe "placeholder text" do
[:email,... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/hidden_input_spec.rb | spec/inputs/hidden_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'hidden input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:secret, :as => :... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/string_input_spec.rb | spec/inputs/string_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'string input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "when object is provided" do
before do
concat(semantic_form_for(@new_p... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/radio_input_spec.rb | spec/inputs/radio_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'radio input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe 'for belongs_to association' do
before do
concat(semantic_form_for(@new... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/time_zone_input_spec.rb | spec/inputs/time_zone_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'time_zone input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:time_zone))
... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/password_input_spec.rb | spec/inputs/password_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'password input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:title, :as => ... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/readonly_spec.rb | spec/inputs/readonly_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'readonly option' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "placeholder text" do
[:email, :number, :password, :phone, :search, :stri... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/text_input_spec.rb | spec/inputs/text_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'text input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:body, :as => :text... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/number_input_spec.rb | spec/inputs/number_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'number input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
allow(@new_post.class).to receive(:validators_on).with(:title).and_return([
active_mode... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/email_input_spec.rb | spec/inputs/email_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'email input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "when object is provided" do
before do
concat(semantic_form_for(@new_po... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/date_picker_input_spec.rb | spec/inputs/date_picker_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'date_picker input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
context "with an object" do
before do
concat(semantic_form_for(@new_post) ... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/country_input_spec.rb | spec/inputs/country_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'country input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "when country_select is not available as a helper from a plugin" do
it "sh... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/phone_input_spec.rb | spec/inputs/phone_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'phone input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "when object is provided" do
before do
concat(semantic_form_for(@new_po... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/include_blank_spec.rb | spec/inputs/include_blank_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "*select: options[:include_blank]" do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
allow(@new_post).to receive(:author_id).and_return(nil)
allow(@new_po... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/check_boxes_input_spec.rb | spec/inputs/check_boxes_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'check_boxes input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe 'for a has_many association' do
before do
@output_buffer = Action... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/select_input_spec.rb | spec/inputs/select_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'select input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe 'explicit values' do
describe 'using an array of values' do
before do
... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/boolean_input_spec.rb | spec/inputs/boolean_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'boolean input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe 'generic' do
before do
concat(semantic_form_for(@new_post) do |builde... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/color_input_spec.rb | spec/inputs/color_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'color input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "when object is provided" do
before do
concat(semantic_form_for(@new_po... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/time_picker_input_spec.rb | spec/inputs/time_picker_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'time_picker input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
context "with an object" do
before do
concat(semantic_form_for(@new_post) ... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/datetime_select_input_spec.rb | spec/inputs/datetime_select_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'datetime select input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "general" do
before do
::I18n.backend.store_translations :en... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/with_options_spec.rb | spec/inputs/with_options_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'string input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "with_options and :wrapper_html" do
before do
concat(semantic_form_for... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/search_input_spec.rb | spec/inputs/search_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'search input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "when object is provided" do
before do
concat(semantic_form_for(@new_p... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/range_input_spec.rb | spec/inputs/range_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'range input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "when object is provided" do
before do
concat(semantic_form_for(@bob) d... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/label_spec.rb | spec/inputs/label_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Formtastic::FormBuilder#label' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
it 'should add "required string" only once with caching enabled' do
... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/file_input_spec.rb | spec/inputs/file_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'file input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
concat(semantic_form_for(@new_post) do |builder|
concat(builder.input(:body, :as => :file... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/datetime_picker_input_spec.rb | spec/inputs/datetime_picker_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'datetime_picker input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
after do
::I18n.backend.reload!
end
context "with an object" do
bef... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/time_select_input_spec.rb | spec/inputs/time_select_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'time select input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "general" do
before do
::I18n.backend.reload!
@output_buffe... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/datalist_input_spec.rb | spec/inputs/datalist_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe "datalist inputs" do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "renders correctly" do
lists_without_values =[
%w(a b c),
["a"... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/date_select_input_spec.rb | spec/inputs/date_select_input_spec.rb | # encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'date select input' do
include FormtasticSpecHelper
before do
@output_buffer = ActionView::OutputBuffer.new ''
mock_everything
end
describe "general" do
before do
@output_buffer = ActionView::OutputBuffer... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/base/collections_spec.rb | spec/inputs/base/collections_spec.rb | # frozen_string_literal: true
require 'fast_spec_helper'
require 'inputs/base/collections'
class MyInput
include Formtastic::Inputs::Base::Collections
end
RSpec.describe MyInput do
let(:builder) { double }
let(:template) { double }
let(:model_class) { double }
let(:model) { double(:class => model_class) }
... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/spec/inputs/base/validations_spec.rb | spec/inputs/base/validations_spec.rb | # frozen_string_literal: true
require 'fast_spec_helper'
require 'active_model'
require 'inputs/base/validations'
class MyInput
attr_accessor :validations
include Formtastic::Inputs::Base::Validations
def validations?
true
end
end
RSpec.describe MyInput do
let(:builder) { double }
let(:template) { do... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/script/integration-template.rb | script/integration-template.rb | # frozen_string_literal: true
gem 'formtastic', path: '..'
gem 'bcrypt', '~> 3.1.7'
gem 'rails-dom-testing', group: :test
gem 'rexml', '~> 3.2' # to compensate for missing dependency in selenium-webdriver
# to speed up bundle install, reuse the bundle path
def bundle_path
File.expand_path ENV.fetch('BUNDLE_PATH', 'v... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/lib/formtastic.rb | lib/formtastic.rb | # encoding: utf-8
# frozen_string_literal: true
module Formtastic
extend ActiveSupport::Autoload
autoload :Helpers
autoload :HtmlAttributes
autoload :LocalizedString
autoload :Localizer
autoload :NamespacedClassFinder
autoload :InputClassFinder
autoload :ActionClassFinder
autoload :Deprecation
ea... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/lib/generators/formtastic/stylesheets/stylesheets_generator.rb | lib/generators/formtastic/stylesheets/stylesheets_generator.rb | module Formtastic
# Copies a stylesheet into to app/assets/stylesheets/formtastic.css
#
# @example
# !!!shell
# $ rails generate formtastic:stylesheets
class StylesheetsGenerator < Rails::Generators::Base
source_root File.expand_path("../../../templates", __FILE__)
desc "Copies Formtastic example... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/lib/generators/formtastic/input/input_generator.rb | lib/generators/formtastic/input/input_generator.rb | # frozen_string_literal: true
module Formtastic
# Modify existing inputs, subclass them, or create your own from scratch.
# @example
# !!!shell
# $ rails generate formtastic:input HatSize
# @example Define input name using underscore convention
# !!!shell
# $ rails generate formtastic:input hat_size... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/lib/generators/formtastic/form/form_generator.rb | lib/generators/formtastic/form/form_generator.rb | # encoding: utf-8
# frozen_string_literal: true
module Formtastic
# Generates a Formtastic form partial based on an existing model. It will not overwrite existing
# files without confirmation.
#
# @example
# !!!shell
# $ rails generate formtastic:form Post
# @example Copy the partial code to the pastebo... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/lib/generators/formtastic/install/install_generator.rb | lib/generators/formtastic/install/install_generator.rb | # encoding: utf-8
# frozen_string_literal: true
module Formtastic
# Copies a config initializer to config/initializers/formtastic.rb
#
# @example
# !!!shell
# $ rails generate formtastic:install
class InstallGenerator < Rails::Generators::Base
source_root File.expand_path('../../../templates', __FILE... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/lib/generators/templates/input.rb | lib/generators/templates/input.rb | class <%= name.camelize %>Input <%= @extension_sentence %>
<%- if !options[:extend] -%>
include Formtastic::Inputs::Base
<%- end -%>
<%- if !options[:extend] || (options[:extend] == "extend") -%>
def to_html
# Add your custom input definition here.
<%- if options[:extend] == "extend" -%>
super
... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
formtastic/formtastic | https://github.com/formtastic/formtastic/blob/3ed00c52ab2472a02fe1f63a4327fde401c7472e/lib/generators/templates/formtastic.rb | lib/generators/templates/formtastic.rb | # encoding: utf-8
# frozen_string_literal: true
# Set the default text field size when input is a string. Default is nil.
# Formtastic::FormBuilder.default_text_field_size = 50
# Set the default text area height when input is a text. Default is 20.
# Formtastic::FormBuilder.default_text_area_height = 5
# Set the def... | ruby | MIT | 3ed00c52ab2472a02fe1f63a4327fde401c7472e | 2026-01-04T15:43:36.501686Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.