Skip to content

Instantly share code, notes, and snippets.

View kethlinmil's full-sized avatar

Tatiana Smirnova kethlinmil

View GitHub Profile
@kethlinmil
kethlinmil / spec_helper.rb
Created March 8, 2017 13:02
File generated with rails generate rspec:install
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require it in any
# files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, consider making
@kethlinmil
kethlinmil / rails_helper.rb
Created March 8, 2017 13:01
File generated with rails generate rspec:install
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
require 'spec_helper'
require 'rspec/rails'
# Add additional requires below this line. Rails is not loaded until this point!
# Requires supporting ruby files with custom matchers and macros, etc, in
@kethlinmil
kethlinmil / .rspec
Created March 8, 2017 13:00
File generated with rails generate rspec:install
--color
--require spec_helper
<h3>Edit <%= human_name %></h3>
<%= "<%= render 'form', #{singular_name}: @#{singular_name} %%>" %>
<h3>Create <%= human_name %></h3>
<%= "<%= render 'form', #{singular_name}: @#{singular_name} %%>" %>
<%= "<%= link_to 'Create new', new_#{singular_name}_path, class: 'btn btn-primary btn-sm mb-2' %%>" %>
<table class="table table-sm">
<tbody>
<%= "<% @#{plural_name}.each do |#{singular_name}| %%>" %>
<tr>
<td> <%= "<%= #{singular_name}.id %%>" %> </td>
<td> [ADD INFO] </td>
<td>
<% if show_action? -%>
<div>
<% editable_attributes.each do |attribute| -%>
<dl class="row">
<dt class="col-sm-3"><%= attribute.human_name.titleize %>:</dt>
<dd class="col-sm-9"><%= "<%= @#{singular_name}.#{attribute.name} %%>" %></dd>
</dl>
<% end -%>
</div>
<p>
<%= "<%= link_to 'Edit', edit_#{singular_name}_path(@#{singular_name}), class: 'btn btn-sm btn-outline-info' %%>" %>
<%= "<%= form_for @#{singular_name} do |f| %%>" %>
<div class="row">
<div class="col-md-4">
<%= "<% if @#{singular_name}.errors.any? %%>" %>
<div id="error_explanation">
<%= "<h2><%= pluralize(@#{singular_name}.errors.count, 'error') %%>" %> prohibited this <%= class_name %> from being saved:</h2>
<ul class="list-unstyled">
<%= "<% @#{singular_name}.errors.full_messages.each do |message| %%>" %>
<%= "<li><%= message %%></li>" %>