Skip to content

Instantly share code, notes, and snippets.

@lynnbright
lynnbright / controller_sample.rb
Last active August 1, 2021 15:28
Use shared_examples to avoid duplicate test examples
class FruitController < ApplicationController
before_action :find_super_market, only: [:index, :show]
before_action :setup_discount, only: [:index, :show]
def index
#...
end
def show
#...
@lynnbright
lynnbright / use_shared_examples.rb
Last active August 1, 2021 15:28
Use shared_examples to avoid duplicate test examples
# spec/support/controllers/shared_examples/expected_discount_examples.rb
RSpec.shared_examples 'an expected @discount' do
let(:super_market) { create(:super_market) }
let(:user) { create(:user, special_pass_available: special_pass_available? }
before { request }
context 'when current_user owns special pass' do
let(:special_pass_available?) { true }
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="container"></div>
body{
background-color: #8E354A;
}
/* title area */
.title h1{
font-weight: 900;
}
.title h1, .title p{
text-align: center;
//基本題
let Rna = {
transcript: function (gene){
let gene_split = gene.split('');
let res = gene_split.map(function(g){
if (g === 'G'){ return 'C'}
else if (g === 'C'){ return 'G'}
else if (g === 'A'){ return 'U'}
else {return 'A'}
}).join('');
//同品項買一送一
let riceBall = [
{
name: "tuna",
type: "riceball",
price: 20,
quantity: 4
},
{
let hotel = {
contact: {
name: "happy hotel",
address: "XXXXXXXXX",
tel: 1336783423,
stars: 5, //暫定
site: "www.happy.com.tw"
},
room: {
@lynnbright
lynnbright / build-a-tribute-page-v2.markdown
Created November 11, 2019 15:22
Build a Tribute Page (V2)
@lynnbright
lynnbright / build-a-tribute-page.markdown
Last active November 7, 2019 15:30
Build a Tribute Page