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
sample_text = "foo bar http://github.com/akitaonrails/chainable_methods foo bar" | |
sample_link = URI.extract(sample_text).first | |
uri = URI.parse(sample_link) | |
response = HTTParty.get(uri) | |
doc = Nokogiri::HTML.parse(response) | |
title = doc.css("H1").text |
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
module MagicalValidation | |
module Model | |
extend ActiveSupport::Concern | |
delegate :errors, :hints, :messages, to: :@result, prefix: :nested | |
attr_reader :result | |
def initialize(hash) | |
@result = self.class.schema.call(hash) | |
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
# Functions: | |
(square = ((x) -> x * x)) | |
# Arrays: | |
(list = [1, 2, 3, 4, 5]) | |
# Objects: | |
(math = ( | |
root: Math.sqrt | |
square: square |
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
# Create an empty controller | |
class PagesController < ApplicationController | |
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
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
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::Matchers.define :have_widget_elements_for do |widget| | |
match do |actual| | |
puts actual.to_yaml | |
@errors = {} | |
expected_elements = { | |
:widget => ".widget", | |
:content_type => ".#{widget.content_type}", | |
:body => ".body", | |
:title => ".title", |