This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rubygems" | |
require "rack" | |
require "thin" | |
cgi_inspector = lambda do |env| | |
[200, {}, ["Your request: | |
http method is #{env['REQUEST_METHOD']} | |
path is #{env['PATH_INFO']} | |
params is #{env['QUERY_STRING']} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form action="create" method="POST" id="payment-form"> | |
<span class="payment-errors"> | |
<noscript>JavaScript is not enabled and is required for this form. First enable it in your web browser settings.</noscript> | |
</div> | |
</span> | |
<% if @error_message %> | |
<%= @error_message %> | |
<% end %> | |
<%= hidden_field_tag :authenticity_token, form_authenticity_token -%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RSpec matcher to spec delegations. | |
# | |
# Usage: | |
# | |
# describe Post do | |
# it { should delegate(:name).to(:author).with_prefix } # post.author_name | |
# it { should delegate(:month).to(:created_at) } | |
# it { should delegate(:year).to(:created_at) } | |
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Have you ever had to sleep() in Capybara-WebKit to wait for AJAX and/or CSS animations? | |
describe 'Modal' do | |
should 'display login errors' do | |
visit root_path | |
click_link 'My HomeMarks' | |
within '#login_area' do | |
fill_in 'email', with: 'will@not.work' | |
fill_in 'password', with: 'test' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_with_exception_handling | |
begin | |
puts '1' | |
yield | |
puts '2' | |
rescue Exception | |
puts 'Exception thrown' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def run_with_exception_handling | |
begin | |
puts '1' | |
v = yield | |
puts v | |
rescue Exception | |
puts 'Exception thrown' | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
last_name | first_name | date_of_birth | ||
---|---|---|---|---|
Doe | John | 1982/10/08 | john.doe@foobar.com | |
Ann | Mary | 1975/09/15 | mary.ann@foobar.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'json' | |
class Transformer | |
def initialize(string) | |
@string = string | |
end | |
def transformed_string(type) | |
if type == :json | |
JSON.parse(@string) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1.upto(100) do |i| | |
if i % 3 == 0 && i % 5 == 0 | |
puts 'FizzBuzz' | |
elsif i % 3 == 0 | |
puts 'Fizz' | |
elsif i % 5 == 0 | |
puts 'Buzz' | |
else | |
puts i | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(count < 10).if_true { }.if_false{ } |
OlderNewer