source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/set.rb | Ruby | mit | 48 | main | 7,530 | # frozen_string_literal: true
require_relative "doc"
require_relative "dsl"
require_relative "run"
require_relative "error/missing_subject_block"
module Fix
# A Set represents a collection of test specifications that can be executed as a test suite.
# It manages the lifecycle of specifications, including:
# - B... |
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/doc.rb | Ruby | mit | 48 | main | 4,510 | # frozen_string_literal: true
require_relative "error/invalid_specification_name"
module Fix
# The Doc module serves as a central registry for storing and managing test specifications.
# It provides functionality for:
# - Storing specification classes in a structured way
# - Managing the lifecycle of specific... |
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/requirement.rb | Ruby | mit | 48 | main | 4,043 | # frozen_string_literal: true
require "spectus/requirement/optional"
require "spectus/requirement/recommended"
require "spectus/requirement/required"
module Fix
# Implements requirement levels as defined in RFC 2119.
# Provides methods for specifying different levels of requirements
# in test specifications: MU... |
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/run.rb | Ruby | mit | 48 | main | 2,946 | # frozen_string_literal: true
require "expresenter/fail"
module Fix
# Executes a test specification by running a subject against a set of challenges
# and requirements.
#
# The Run class orchestrates test execution by:
# 1. Evaluating the test subject in the proper environment
# 2. Applying a series of me... |
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/dsl.rb | Ruby | mit | 48 | main | 3,876 | # frozen_string_literal: true
require "defi/method"
require_relative "matcher"
require_relative "requirement"
module Fix
# Abstract class for handling the domain-specific language.
#
# @api private
class Dsl
extend Matcher
extend Requirement
# Sets a user-defined property.
#
# @example
... |
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/matcher.rb | Ruby | mit | 48 | main | 3,052 | # frozen_string_literal: true
require "matchi"
module Fix
# Collection of expectation matchers.
# Provides a comprehensive set of matchers for testing different aspects of objects.
#
# The following matchers are available:
#
# Basic Comparison:
# - eq(expected) # Checks equality using eql?
# ... |
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/error/invalid_specification_name.rb | Ruby | mit | 48 | main | 351 | # frozen_string_literal: true
module Fix
module Error
# Error raised when an invalid specification name is provided during declaration
class InvalidSpecificationName < ::NameError
def initialize(name)
super("Invalid specification name '#{name}'. Specification names must be valid Ruby constants.... |
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/error/missing_specification_block.rb | Ruby | mit | 48 | main | 349 | # frozen_string_literal: true
module Fix
module Error
# Error raised when attempting to build a specification without a block
class MissingSpecificationBlock < ::ArgumentError
MISSING_BLOCK_ERROR = "Block is required for building a specification"
def initialize
super(MISSING_BLOCK_ERROR)... |
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/error/specification_not_found.rb | Ruby | mit | 48 | main | 325 | # frozen_string_literal: true
module Fix
module Error
# Error raised when a specification cannot be found at runtime
class SpecificationNotFound < ::NameError
def initialize(name)
super("Specification '#{name}' not found. Make sure it's defined before running the test.")
end
end
end... |
github | fixrb/fix | https://github.com/fixrb/fix | lib/fix/error/missing_subject_block.rb | Ruby | mit | 48 | main | 445 | # frozen_string_literal: true
module Fix
module Error
# Error raised when attempting to test a specification without providing a subject block
class MissingSubjectBlock < ::ArgumentError
MISSING_BLOCK_ERROR = "Subject block is required for testing a specification. " \
"Use: ... |
github | fixrb/fix | https://github.com/fixrb/fix | fix/true.rb | Ruby | mit | 48 | main | 330 | # frozen_string_literal: true
require_relative File.join("..", "lib", "fix")
Fix :True do
let(:boolean) { true }
it MUST_NOT be false
it MUST be true
on :! do
it MUST be false
it MUST_NOT be true
end
with boolean: true do
it MUST be true
end
with boolean: false do
it MUST be false
... |
github | fixrb/fix | https://github.com/fixrb/fix | fix/it_with_a_block.rb | Ruby | mit | 48 | main | 244 | # frozen_string_literal: true
require_relative File.join("..", "lib", "fix")
Fix :ItWithABlock do
it MUST_NOT be 4
it { MUST_NOT be 4 }
it MUST be 42
it { MUST be 42 }
on :-, 42 do
it MUST be 0
it { MUST be 0 }
end
end |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/identity/equal_spec.rb | Ruby | mit | 48 | main | 204 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST equal(:foo) }.test { :foo }
# test/matcher/identity/equal_spec.rb:5 Success: expected to be :foo. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/predicate/be_xxx_spec.rb | Ruby | mit | 48 | main | 205 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST be_empty }.test { [] }
# test/matcher/predicate/be_xxx_spec.rb:5 Success: expected [] to be empty. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/predicate/have_xxx_spec.rb | Ruby | mit | 48 | main | 235 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST have_key(:foo) }.test { { foo: 42 } }
# test/matcher/predicate/have_xxx_spec.rb:5 Success: expected {:foo=>42} to have key :foo. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/equivalence/eql_spec.rb | Ruby | mit | 48 | main | 206 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST eql("foo") }.test { "foo" }
# test/matcher/equivalence/eql_spec.rb:5 Success: expected to eq "foo". |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/equivalence/eq_spec.rb | Ruby | mit | 48 | main | 204 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST eq("foo") }.test { "foo" }
# test/matcher/equivalence/eq_spec.rb:5 Success: expected to eq "foo". |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/satisfy/satisfy_spec.rb | Ruby | mit | 48 | main | 234 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST(satisfy { |value| value == 42 }) }.test { 42 }
# test/matcher/satisfy/satisfy_spec.rb:5 Success: expected 42 to satisfy &block. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/change_observation/to_spec.rb | Ruby | mit | 48 | main | 266 | # frozen_string_literal: false
require_relative File.join("..", "..", "..", "lib", "fix")
object = "foo"
Fix { it MUST change(object, :to_s).to("FOO") }.test { object.upcase! }
# test/matcher/change_observation/to_spec.rb:7 Success: expected to change to "FOO". |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/change_observation/by_at_most_spec.rb | Ruby | mit | 48 | main | 282 | # frozen_string_literal: false
require_relative File.join("..", "..", "..", "lib", "fix")
object = []
Fix { it MUST change(object, :length).by_at_most(1) }.test { object << 1 }
# test/matcher/change_observation/by_at_most_spec.rb:7 Success: expected [1] to change by at most 1. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/change_observation/from_to_spec.rb | Ruby | mit | 48 | main | 294 | # frozen_string_literal: false
require_relative File.join("..", "..", "..", "lib", "fix")
object = "foo"
Fix { it MUST change(object, :to_s).from("foo").to("FOO") }.test { object.upcase! }
# test/matcher/change_observation/from_to_spec.rb:7 Success: expected to change from "foo" to "FOO". |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/change_observation/by_at_least_spec.rb | Ruby | mit | 48 | main | 285 | # frozen_string_literal: false
require_relative File.join("..", "..", "..", "lib", "fix")
object = []
Fix { it MUST change(object, :length).by_at_least(1) }.test { object << 1 }
# test/matcher/change_observation/by_at_least_spec.rb:7 Success: expected [1] to change by at least 1. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/change_observation/by_spec.rb | Ruby | mit | 48 | main | 258 | # frozen_string_literal: false
require_relative File.join("..", "..", "..", "lib", "fix")
object = []
Fix { it MUST change(object, :length).by(1) }.test { object << 1 }
# test/matcher/change_observation/by_spec.rb:7 Success: expected [1] to change by 1. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/regular_expressions/match_spec.rb | Ruby | mit | 48 | main | 275 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST match(/^[^@]+@[^@]+$/) }.test { "bob@example.email" }
# test/matcher/regular_expressions/match_spec.rb:5 Success: expected "bob@example.email" to match /^[^@]+@[^@]+$/. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/classes/be_an_instance_of_spec.rb | Ruby | mit | 48 | main | 248 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST be_an_instance_of Integer }.test { 42 }
# test/matcher/classes/be_an_instance_of_spec.rb:5 Success: expected 42 to be an instance of Integer. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/expecting_errors/raise_exception_spec.rb | Ruby | mit | 48 | main | 263 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST raise_exception(NameError) }.test { Fix::Boom! }
# test/matcher/expecting_errors/raise_exception_spec.rb:5 Success: undefined method `Boom!' for Fix:Module. |
github | fixrb/fix | https://github.com/fixrb/fix | test/matcher/comparisons/be_within_spec.rb | Ruby | mit | 48 | main | 230 | # frozen_string_literal: true
require_relative File.join("..", "..", "..", "lib", "fix")
Fix { it MUST be_within(2).of(42) }.test { 40 }
# test/matcher/comparisons/be_within_spec.rb:5 Success: expected 40 to be within 2 of 42. |
github | logandk/capistrano-ec2group | https://github.com/logandk/capistrano-ec2group | Rakefile | Ruby | mit | 48 | master | 605 | require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the capistrano-ec2group plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation... |
github | logandk/capistrano-ec2group | https://github.com/logandk/capistrano-ec2group | capistrano-ec2group.gemspec | Ruby | mit | 48 | master | 684 | Gem::Specification.new do |s|
s.name = "capistrano-ec2group"
s.version = "1.0.9"
s.author = "Logan Raarup"
s.email = "logan@logan.dk"
s.date = "2009-06-19"
s.homepage = "http://github.com/logandk/capistrano-ec2group"
s.summary = "Capistrano plugin for deploying to Amazon EC2 instances by security grou... |
github | logandk/capistrano-ec2group | https://github.com/logandk/capistrano-ec2group | lib/capistrano/ec2group.rb | Ruby | mit | 48 | master | 1,093 | require 'right_aws'
unless Capistrano::Configuration.respond_to?(:instance)
abort "capistrano/ec2group requires Capistrano 2"
end
module Capistrano
class Configuration
module Groups
# Associate a group of EC2 instances with a role. In order to use this, you
# must use the security groups feature i... |
github | logandk/capistrano-ec2group | https://github.com/logandk/capistrano-ec2group | test/ec2group_test.rb | Ruby | mit | 48 | master | 436 | require 'test/unit'
require 'yaml'
require 'rubygems/specification'
class CapistranoTest < Test::Unit::TestCase
def test_build_gem
data = File.read(File.join(File.dirname(__FILE__), '..', 'capistrano-ec2group.gemspec'))
spec = nil
if data !~ %r{!ruby/object:Gem::Specification}
Thread.new { spec = ... |
github | ivalkeen/capistrano-nginx | https://github.com/ivalkeen/capistrano-nginx | capistrano-nginx.gemspec | Ruby | mit | 48 | master | 942 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
Gem::Specification.new do |spec|
spec.name = 'capistrano-nginx'
spec.version = '1.0.0'
spec.authors = ['Ivan Tkalin', 'Koen Punt']
spec.email = ['itkalin@gmail.com', '... |
github | ivalkeen/capistrano-nginx | https://github.com/ivalkeen/capistrano-nginx | lib/capistrano/tasks/nginx.rake | Ruby | mit | 48 | master | 2,029 | namespace :nginx do
desc <<-DESC
Setup nginx configuration
Configurable options are:
set :nginx_roles, :all
set :nginx_path, "/etc/nginx"
set :nginx_upstream, -> { fetch(:application) }
set :nginx_server_name, -> { fetch(:application) }
set :nginx_te... |
github | ivalkeen/capistrano-nginx | https://github.com/ivalkeen/capistrano-nginx | lib/generators/capistrano/nginx/config_generator.rb | Ruby | mit | 48 | master | 380 | module Capistrano
module Nginx
module Generators
class ConfigGenerator < Rails::Generators::Base
desc "Create local nginx configuration file for customization"
source_root File.expand_path('../templates', __FILE__)
def copy_template
copy_file "_nginx_conf.erb", "config/dep... |
github | dignoe/whenever-elasticbeanstalk | https://github.com/dignoe/whenever-elasticbeanstalk | whenever-elasticbeanstalk.gemspec | Ruby | mit | 48 | master | 1,122 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'whenever-elasticbeanstalk/version'
Gem::Specification.new do |gem|
gem.name = "whenever-elasticbeanstalk"
gem.version = Whenever::Elasticbeanstalk::VERSION
gem.plat... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | form_props.gemspec | Ruby | mit | 48 | main | 735 | $LOAD_PATH << File.expand_path("lib", __dir__)
require "form_props/version"
Gem::Specification.new do |s|
s.name = "form_props"
s.version = FormProps::VERSION
s.author = "Johny Ho"
s.email = "johny@thoughtbot.com"
s.license = "MIT"
s.homepage = "https://github.com/thoughtbot/form_props/"
s.summary = "For... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/test_helper.rb | Ruby | mit | 48 | main | 7,984 | ENV["RAILS_ENV"] ||= "test"
require "uri"
require_relative "../lib/form_props"
require "open3"
require "byebug"
require "props_template"
require "minitest"
require "minitest/autorun"
require "mocha/minitest"
require "rails"
Rails.backtrace_cleaner.remove_silencers!
require "active_model"
Continent = Struct.new(:id, ... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/form_props_test.rb | Ruby | mit | 48 | main | 10,385 | require_relative "./test_helper"
class FormPropsTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def url_for(options)
if options.is_a?(Hash)
"http://www.example.com"
else
super
end
end
def test_form_with_multipart
form_pr... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/text_area_test.rb | Ruby | mit | 48 | main | 9,243 | require_relative "../test_helper"
class TextAreaTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_text_area_placeholder_without_locales
@post = Post.new
@post.body = "Back to the hill and over it again!"
I18n.with_locale :placeholder... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/select_test.rb | Ruby | mit | 48 | main | 44,108 | require_relative "../test_helper"
class CustomEnumerable
include Enumerable
def each
yield "one"
yield "two"
end
end
class SelectTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
class Map < Hash
def category
"<mus>"
end
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/color_field_test.rb | Ruby | mit | 48 | main | 1,371 | require_relative "../test_helper"
class ColorFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_color_field_with_valid_hex_color_string
@post.title = "#000fff"
form_props(model: @post) do |f|
f.color_field(:title)
end
r... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/collection_select_test.rb | Ruby | mit | 48 | main | 9,362 | require_relative "../test_helper"
class CollectionSelectTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_collection_select
@post = Post.new
@post.author_name = "Babe"
form_props(model: @post) do |f|
f.collection_select(:author... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/radio_button_test.rb | Ruby | mit | 48 | main | 2,946 | require_relative "../test_helper"
class RadioButtonTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_radio_button
@post.title = "Hello World"
form_props(model: @post) do |f|
f.radio_button(:title, "Hello World")
end
result =... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/submit_test.rb | Ruby | mit | 48 | main | 2,610 | require_relative "../test_helper"
class SubmitTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_submit_with_object_as_new_record_and_locale_strings
I18n.with_locale :submit do
@post.persisted = false
@post.stub(:to_key, nil) do
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/month_field_test.rb | Ruby | mit | 48 | main | 2,538 | require_relative "../test_helper"
class MonthFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_month_field
form_props(model: @post) do |f|
f.month_field(:written_on)
end
result = json.result!.strip
expected = {
"... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/number_field_test.rb | Ruby | mit | 48 | main | 954 | require_relative "../test_helper"
class NumberFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_number_field
@post.favs = 2
form_props(model: @post) do |f|
f.number_field(:favs, in: 1...10)
end
result = json.result!.st... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/time_zone_select_test.rb | Ruby | mit | 48 | main | 13,364 | require_relative "../test_helper"
class TimeZoneSelectTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
module FakeZones
FakeZone = Struct.new(:name) do
def to_s
name
end
def =~(_re)
end
def match?(_re)
end
end
module ClassMe... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/password_field_test.rb | Ruby | mit | 48 | main | 854 | require_relative "../test_helper"
class PasswordFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_password_field
@post.title = "does not show"
form_props(model: @post) do |f|
f.password_field(:title)
end
result = json.... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/input_options_test.rb | Ruby | mit | 48 | main | 3,952 | require_relative "../test_helper"
class InputOptionsTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_tag_builder_with_conditional_hash_classes
form_props(model: @post) do |f|
f.text_field(:body, class: [{song: true}, {play: false}])
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/hidden_field_test.rb | Ruby | mit | 48 | main | 1,914 | require_relative "../test_helper"
class HiddenFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_hidden_field
form_props(model: @post) do |f|
f.hidden_field(:title)
end
result = json.result!.strip
expected = {
"ty... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/collection_test.rb | Ruby | mit | 48 | main | 20,312 | require_relative "../test_helper"
Category = Struct.new(:id, :name)
class CollectionTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def assert_no_select(selector, value = nil)
assert_select(selector, text: value, count: 0)
end
def with_collect... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/tel_field_test.rb | Ruby | mit | 48 | main | 535 | require_relative "../test_helper"
class TelFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_tel_field
@post.title = "2125559090"
form_props(model: @post) do |f|
f.tel_field(:title)
end
result = json.result!.strip
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/url_field_test.rb | Ruby | mit | 48 | main | 551 | require_relative "../test_helper"
class UrlFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_url_field
@post.title = "http://example.com"
form_props(model: @post) do |f|
f.url_field(:title)
end
result = json.result!.st... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/text_field_test.rb | Ruby | mit | 48 | main | 10,306 | require_relative "../test_helper"
class TextFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_text_field_placeholder_without_locales
@post = Post.new
@post.body = "Back to the hill and over it again!"
I18n.with_locale :placehold... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/week_field_test.rb | Ruby | mit | 48 | main | 2,522 | require_relative "../test_helper"
class WeekFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_week_field
form_props(model: @post) do |f|
f.week_field(:written_on)
end
result = json.result!.strip
expected = {
"typ... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/grouped_collection_select_test.rb | Ruby | mit | 48 | main | 3,420 | require_relative "../test_helper"
class GroupedCollectionSelectTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
Country = Struct.new("Country", :country_id, :country_name)
setup :setup_test_fixture
def test_option_groups_from_collection_for_select
@post = Post.new
@pos... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/weekday_select_test.rb | Ruby | mit | 48 | main | 3,516 | require_relative "../test_helper"
class WeekdaySelectTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_weekday_select
@post = Post.new
@post.weekday = nil
form_props(model: @post) do |f|
f.weekday_select(:weekday)
end
r... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/email_field_test.rb | Ruby | mit | 48 | main | 551 | require_relative "../test_helper"
class EmailFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_url_field
@post.title = "james@smith.com"
form_props(model: @post) do |f|
f.email_field(:title)
end
result = json.result!.s... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/range_field_test.rb | Ruby | mit | 48 | main | 948 | require_relative "../test_helper"
class RangeFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_range_field
@post.favs = 2
form_props(model: @post) do |f|
f.range_field(:favs, in: 1...10)
end
result = json.result!.strip... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/time_field_test.rb | Ruby | mit | 48 | main | 3,720 | require_relative "../test_helper"
class TimeFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_time_field
@post.written_on = nil
form_props(model: @post) do |f|
f.time_field(:written_on)
end
result = json.result!.strip... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/file_field_test.rb | Ruby | mit | 48 | main | 3,838 | require_relative "../test_helper"
module ActionController
class Base
def self.test_routes(&block)
routes = ActionDispatch::Routing::RouteSet.new
routes.draw(&block)
include routes.url_helpers
routes
end
end
end
class WithActiveStorageRoutesControllers < ActionController::Base
tes... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/checkbox_field_test.rb | Ruby | mit | 48 | main | 12,307 | require_relative "../test_helper"
class CheckboxFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_check_box
@post.admin = false
form_props(model: @post) do |f|
f.check_box(:admin)
end
result = json.result!.strip
exp... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/search_field_test.rb | Ruby | mit | 48 | main | 954 | require_relative "../test_helper"
class SearchFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_search_field
form_props(model: @post) do |f|
f.search_field(:title)
end
result = json.result!.strip
expected = {
"typ... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/datetime_field_test.rb | Ruby | mit | 48 | main | 4,899 | require_relative "../test_helper"
class DateTimeFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_datetime_field
@post.written_on = nil
form_props(model: @post) do |f|
f.datetime_field(:written_on)
end
result = json.r... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | test/inputs/date_field_test.rb | Ruby | mit | 48 | main | 4,113 | require_relative "../test_helper"
class DateFieldTest < ActionView::TestCase
include FormProps::ActionViewExtensions::FormHelper
setup :setup_test_fixture
def test_date_field
@post.written_on = nil
form_props(model: @post) do |f|
f.date_field(:written_on)
end
result = json.result!.strip... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props.rb | Ruby | mit | 48 | main | 1,663 | # frozen_string_literal: true
require "action_view"
require "action_pack"
require "form_props/helper"
require "form_props/action_view_extensions/form_helper"
require "form_props/form_options_helper"
require "form_props/select_renderer"
require "form_props/inputs/base"
require "form_props/inputs/text_field"
require "fo... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/helper.rb | Ruby | mit | 48 | main | 15,389 | # frozen_string_literal: true
# Keep up to date with
# https://github.com/facebook/react/blob/main/packages/react-dom-bindings/src/shared/possibleStandardNames.js
module FormProps
POSSIBLE_STANDARD_NAMES = {
## HTML
accept: "accept",
acceptcharset: "acceptCharset",
"accept-charset": "acceptCharset",
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/form_builder.rb | Ruby | mit | 48 | main | 9,073 | # frozen_string_literal: true
module FormProps
class FormBuilder < ActionView::Helpers::FormBuilder
undef_method :button,
:label,
:datetime_select,
:time_select,
:date_select
# :rich_text_area
def initialize(*args)
super
options = args.last || {}
@default_option... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/select_renderer.rb | Ruby | mit | 48 | main | 1,850 | module FormProps
module SelectRenderer
def add_options(option_tags, options, value = nil)
if options[:include_blank]
content = (options[:include_blank] if options[:include_blank].is_a?(String))
label = (" " unless content)
option_tags = [{label: content || label, value: ""}] + option... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/form_options_helper.rb | Ruby | mit | 48 | main | 4,819 | # frozen_string_literal: true
module FormProps
module FormOptionsHelper
def selected_values
@selected_values ||= []
@selected_values
end
def grouped_options_for_select(grouped_options, selected_key = nil, options = {})
prompt = options[:prompt]
divider = options[:divider]
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/time_field.rb | Ruby | mit | 48 | main | 252 | # frozen_string_literal: true
module FormProps
module Inputs
class TimeField < DatetimeField
private
def format_date(value)
value&.strftime("%T.%L")
end
def field_type
"time"
end
end
end
end |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/select.rb | Ruby | mit | 48 | main | 1,368 | # frozen_string_literal: true
module FormProps
module Inputs
class Select < Base
if ActionView::VERSION::STRING >= "7.1"
include ActionView::Helpers::Tags::SelectRenderer
end
include ActionView::Helpers::FormOptionsHelper
include FormOptionsHelper
include SelectRenderer
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/text_area.rb | Ruby | mit | 48 | main | 861 | # frozen_string_literal: true
require "action_view/helpers/tags/placeholderable"
module FormProps
module Inputs
class TextArea < Base
include ActionView::Helpers::Tags::Placeholderable
def render
json.set!(sanitized_key) do
add_default_name_and_field(@options)
@options[:... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/radio_button.rb | Ruby | mit | 48 | main | 1,269 | # frozen_string_literal: true
module FormProps
module Inputs
class RadioButton < Base
def initialize(object_name, method_name, template_object, tag_value, options)
@tag_value = tag_value
super(object_name, method_name, template_object, options)
end
def input_checked?(options)
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/datetime_local_field.rb | Ruby | mit | 48 | main | 277 | # frozen_string_literal: true
module FormProps
module Inputs
class DatetimeLocalField < DatetimeField
private
def format_date(value)
value&.strftime("%Y-%m-%dT%T")
end
def field_type
"datetime-local"
end
end
end
end |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/submit.rb | Ruby | mit | 48 | main | 461 | # frozen_string_literal: true
module FormProps
module Inputs
class Submit < Base
def initialize(template_object, options)
@template_object = template_object
@options = options.with_indifferent_access
end
def render
@options[:type] = field_type
json.set!(:submit... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/password_field.rb | Ruby | mit | 48 | main | 274 | # frozen_string_literal: true
module FormProps
module Inputs
class PasswordField < TextField
def render
@options = {value: nil}.merge!(@options)
super
end
private
def field_type
"password"
end
end
end
end |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/collection_helpers.rb | Ruby | mit | 48 | main | 1,611 | # frozen_string_literal: true
module FormProps
module Inputs
module CollectionHelpers
def render_collection
json.array! @collection do |item|
value = value_for_collection(item, @value_method)
text = value_for_collection(item, @text_method)
default_html_options = defaul... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/collection_radio_buttons.rb | Ruby | mit | 48 | main | 1,007 | # frozen_string_literal: true
require "action_view/helpers/tags/collection_helpers"
module FormProps
module Inputs
class CollectionRadioButtons < Base
include ActionView::Helpers::Tags::CollectionHelpers
include ActionView::Helpers::FormOptionsHelper
include CollectionHelpers
class Radi... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/month_field.rb | Ruby | mit | 48 | main | 254 | # frozen_string_literal: true
module FormProps
module Inputs
class MonthField < DatetimeField
private
def format_date(value)
value&.strftime("%Y-%m")
end
def field_type
"month"
end
end
end
end |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/number_field.rb | Ruby | mit | 48 | main | 372 | # frozen_string_literal: true
module FormProps
module Inputs
class NumberField < TextField
def render
if (range = @options.delete("in") || @options.delete("within"))
@options.update("min" => range.min, "max" => range.max)
end
super
end
private
def fiel... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/collection_check_boxes.rb | Ruby | mit | 48 | main | 1,043 | # frozen_string_literal: true
require "action_view/helpers/tags/collection_helpers"
module FormProps
module Inputs
class CollectionCheckBoxes < Base
include ActionView::Helpers::Tags::CollectionHelpers
include ActionView::Helpers::FormOptionsHelper
include CollectionHelpers
class Check... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/hidden_field.rb | Ruby | mit | 48 | main | 247 | # frozen_string_literal: true
module FormProps
module Inputs
class HiddenField < TextField
def render
@options[:auto_complete] = "off"
super
end
def field_type
"hidden"
end
end
end
end |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/color_field.rb | Ruby | mit | 48 | main | 466 | # frozen_string_literal: true
module FormProps
module Inputs
class ColorField < TextField
def render
@options["value"] ||= validate_color_string(value)
super
end
private
def validate_color_string(string)
regex = /#[0-9a-fA-F]{6}/
if regex.match?(string)
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/base.rb | Ruby | mit | 48 | main | 3,300 | # frozen_string_literal: true
module FormProps
module Inputs
class Base < ::ActionView::Helpers::Tags::Base
# Remove when no longer supporting Rails 7
if ActionView::VERSION::STRING < "8"
alias_method :add_default_name_and_field_for_value, :add_default_name_and_id_for_value
alias_meth... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/text_field.rb | Ruby | mit | 48 | main | 656 | # frozen_string_literal: true
require "action_view/helpers/tags/placeholderable"
module FormProps
module Inputs
class TextField < Base
include ActionView::Helpers::Tags::Placeholderable
def render
@options[:size] = @options[:max_length] unless @options.key?(:size)
@options[:type] ||... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/grouped_collection_select.rb | Ruby | mit | 48 | main | 1,316 | # frozen_string_literal: true
module FormProps
module Inputs
class GroupedCollectionSelect < Base
if ActionView::VERSION::STRING >= "7.1"
include ActionView::Helpers::Tags::SelectRenderer
end
include ActionView::Helpers::FormOptionsHelper
include FormOptionsHelper
include Se... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/check_box.rb | Ruby | mit | 48 | main | 1,861 | # frozen_string_literal: true
module FormProps
module Inputs
class CheckBox < Base
def initialize(object_name, method_name, template_object, checked_value, unchecked_value, options)
@checked_value = checked_value
@unchecked_value = unchecked_value
super(object_name, method_name, tem... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/weekday_select.rb | Ruby | mit | 48 | main | 1,035 | # frozen_string_literal: true
module FormProps
module Inputs
class WeekdaySelect < Base
if ActionView::VERSION::STRING >= "7.1"
include ActionView::Helpers::Tags::SelectRenderer
end
include ActionView::Helpers::FormOptionsHelper
include FormOptionsHelper
include SelectRender... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/search_field.rb | Ruby | mit | 48 | main | 574 | # frozen_string_literal: true
module FormProps
module Inputs
class SearchField < FormProps::Inputs::TextField
def render
if @options[:autosave]
if @options[:autosave] == true
@options[:autosave] = request.host.split(".").reverse.join(".")
end
@options[:resu... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/date_field.rb | Ruby | mit | 48 | main | 264 | # frozen_string_literal: true
module FormProps
module Inputs
class DateField < DatetimeField
private
def format_date(value)
value.presence&.strftime("%Y-%m-%d")
end
def field_type
"date"
end
end
end
end |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/collection_select.rb | Ruby | mit | 48 | main | 1,105 | # frozen_string_literal: true
module FormProps
module Inputs
class CollectionSelect < Base
if ActionView::VERSION::STRING >= "7.1"
include ActionView::Helpers::Tags::SelectRenderer
end
include ActionView::Helpers::FormOptionsHelper
include FormOptionsHelper
include SelectRen... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/week_field.rb | Ruby | mit | 48 | main | 253 | # frozen_string_literal: true
module FormProps
module Inputs
class WeekField < DatetimeField
private
def format_date(value)
value&.strftime("%Y-W%V")
end
def field_type
"week"
end
end
end
end |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/datetime_field.rb | Ruby | mit | 48 | main | 647 | # frozen_string_literal: true
module FormProps
module Inputs
class DatetimeField < TextField
def render
@options[:value] ||= format_date(value)
@options[:min] = format_date(datetime_value(@options["min"]))
@options[:max] = format_date(datetime_value(@options["max"]))
super
... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/inputs/time_zone_select.rb | Ruby | mit | 48 | main | 888 | # frozen_string_literal: true
module FormProps
module Inputs
class TimeZoneSelect < Base
if ActionView::VERSION::STRING >= "7.1"
include ActionView::Helpers::Tags::SelectRenderer
end
include ActionView::Helpers::FormOptionsHelper
include FormOptionsHelper
include SelectRende... |
github | thoughtbot/form_props | https://github.com/thoughtbot/form_props | lib/form_props/action_view_extensions/form_helper.rb | Ruby | mit | 48 | main | 3,396 | # frozen_string_literal: true
module FormProps
module ActionViewExtensions
module FormHelper
def form_props(model: nil, scope: nil, url: nil, format: nil, **options, &block)
json = @__json
options = {
allow_method_names_outside_object: true,
controlled: false
}.... |
github | katsuma/itunes-client | https://github.com/katsuma/itunes-client | itunes-client.gemspec | Ruby | mit | 48 | master | 1,395 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'itunes/version'
Gem::Specification.new do |spec|
spec.name = "itunes-client"
spec.version = Itunes::VERSION
spec.authors = ["ryo katsuma"]
spec.email = ["kats... |
github | katsuma/itunes-client | https://github.com/katsuma/itunes-client | Rakefile | Ruby | mit | 48 | master | 397 | require 'rubygems'
require "bundler/gem_tasks"
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rspec/core'
require 'rspec/core/rake_task'
RSpec::C... |
github | katsuma/itunes-client | https://github.com/katsuma/itunes-client | lib/itunes/volume.rb | Ruby | mit | 48 | master | 662 | require 'itunes/util'
module Itunes
class Volume
extend Itunes::Util::Executor
class << self
def up(level = 10)
execute_script("#{script_dir}/up.scpt", level)
self
end
def down(level = 10)
execute_script("#{script_dir}/down.scpt", level)
self
end
... |
github | katsuma/itunes-client | https://github.com/katsuma/itunes-client | lib/itunes/player.rb | Ruby | mit | 48 | master | 1,937 | # coding: utf-8
require 'singleton'
require 'itunes/track'
require 'itunes/util'
require 'itunes/volume'
module Itunes
class Player
extend Itunes::Util::Executor
class FileNotFoundError < StandardError; end;
class EmptyFileError < StandardError; end;
class << self
def add(file_path)
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.