Skip to content

Instantly share code, notes, and snippets.

View amyroi's full-sized avatar

Atsuko Mori amyroi

  • Freelance
  • Tokyo
View GitHub Profile
# spec/support/site_prism/user_page.rb
class UserPage
class FormBase < SitePrism::Section
element :first_name, "input[name='user[first_name]']"
element :last_name, "input[name='user[last_name]']"
element :button, "input[name='commit']"
def input(args)
first_name.set args[:first_name]
last_name.set args[:last_name]
button.click
@amyroi
amyroi / strong_parameters + nested_attributes + serialize
Created April 13, 2015 07:58
strong_parameters + nested_attributes + serialize
# model
serialize :body
# controller
def inquiry_params
params.require(:inquiry).permit(:read_at, :inquiry_form_id, inquiry_contents_attributes: [{body: []}, :part_id])
end
require 'spec_helper'
describe MyModel do
it "should create a new instance given valid attributes" do
Factory(:my_model)
end
describe "name" do
it "should be required" do
blank = Factory.build(:my_model, :name => "")
class Facebook::Notification
attr_accessor :canvas_auth, :graph
def initialize
conf = Rails.configuration.facebook_canvas
@canvas_auth = Koala::Facebook::OAuth.new(conf[:app_id], conf[:app_secret])
@graph = Koala::Facebook::API::new(canvas_auth.get_app_access_token, conf[:app_secret])
end
str = ''
yaml_test = str.to_yaml
=>"--- \"\"\n"
YAML.load(yaml_test)
=> ""
@amyroi
amyroi / zeus.rb
Last active August 29, 2015 14:07
require 'zeus/rails'
class CustomPlan < Zeus::Rails
def server Dir.chdir(::Rails.application.root)
`unicorn_rails`
end
end
Zeus.plan = CustomPlan.new