| layout | post | |||
|---|---|---|---|---|
| title | Ruby Hacking Guide ch. 11: Finite-state scanner | |||
| date | 2013-04-01 02:19 | |||
| comments | true | |||
| categories |
|
This file contains hidden or 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
| error = { | |
| message: "Expected true to be false.", | |
| stack: "Error: Expected true to be false.\n at new jasmine.ExpectationResult (http://0.0.0.0:3001/relative/assets/jasmine/1.3.1.js?body=1:114:32)\n at null.toBe (http://0.0.0.0:3001/relative/assets/jasmine/1.3.1.js?body=1:1237:29)\n at null.<anonymous> (http://0.0.0.0:3001/relative/assets/integration/integration_spec.js?body=1:11:27)\n at jasmine.Block.execute (http://0.0.0.0:3001/relative/assets/jasmine/1.3.1.js?body=1:1066:17)\n at jasmine.Queue.next_ (http://0.0.0.0:3001/relative/assets/jasmine/1.3.1.js?body=1:2098:31)\n at jasmine.Queue.start (http://0.0.0.0:3001/relative/assets/jasmine/1.3.1.js?body=1:2051:8)\n at jasmine.Spec.execute (http://0.0.0.0:3001/relative/assets/jasmine/1.3.1.js?body=1:2378:14)\n at jasmine.Queue.next_ (http://0.0.0.0:3001/relative/assets/jasmine/1.3.1.js?body=1:2098:31)\n at jasmine.Queue.start (http://0.0.0.0:3001/relative/assets/jasmine/1.3.1.js?body=1:2051:8)\n at jasmine.Suite.execute (http:// |
This file contains hidden or 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 'faraday' | |
| require 'faraday_middleware' | |
| require 'byebug' | |
| def connection | |
| @connection ||= | |
| Faraday::Connection.new 'http://www.letsrevolutionizetesting.com/' do |c| | |
| c.request :json | |
| c.response :json, :content_type => /\bjson$/ |
This file contains hidden or 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 I15r; end | |
| module Visitable | |
| def accept(visitor) | |
| visitor.send visitor_method_name, self | |
| end | |
| def visitor_method_name | |
| "visit_#{self.class.name}".gsub(/::/, "__") | |
| end |
This file contains hidden or 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
| editor = ENV['EDITOR'] | |
| mapping = { | |
| [:textmate, :txmt, :tm] => :textmate, | |
| [:sublime, :subl, :st] => :sublime, | |
| [:macvim, :mvim, :vim] => :macvim | |
| } | |
| mapping.each do |matches, value| | |
| matches.each do |m| |
This file contains hidden or 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
| -----BEGIN PGP PUBLIC KEY BLOCK----- | |
| Version: OpenPGP.js v.1.20130820 | |
| Comment: http://openpgpjs.org | |
| xo0EUhkGSQEEAIzpd6WBTyNt7wdBenr6Dj9eDnyRRCsy/n6TO7ow1SOT6h+k | |
| t+p8MvYO2G+TprApJeIiFlZPCA6RdP2FPhQePyBSbf3VRrDDlojmRXOs+iWr | |
| yzT1CGrnkkc46wKque6c4BXtz2dVb+y1TSQfn8BaKTfY8pvrj9agbOPCaE2C | |
| gMt1ABEBAAHNJ01hcmsgQnVybnMgPG1hcmt0aGVkZXZlbG9wZXJAZ21haWwu | |
| Y29tPsKcBBABCAAQBQJSGQZKCRCf0oceVRzIIQAASRYEAIdxD0oOrjRWRDbi | |
| NESuwAJG6vJtNdaQ1HLTZixDmUWPlHHcRuxzxg/mU+BPQUGdA29xck54dBsr |
This file contains hidden or 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 JavascriptFixtureGenerationMethods | |
| # Saves the markup to a fixture file using the given name | |
| def save_fixture_for_jasmine(name, markup=html_for('body')) | |
| fixture_path = Rails.root.join('public/fixtures') | |
| Dir.mkdir(fixture_path) unless File.exists?(fixture_path) | |
| fixture_file = File.join(fixture_path, "#{name}.fixture.html") | |
| File.open(fixture_file, 'w') { |f| f << markup } | |
| end |
This file contains hidden or 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
| subject { App.new } | |
| App::PURPOSES.each do |p,_| | |
| context do | |
| before { subject.purpose = p } | |
| its(:purpose){ should == p } | |
| end | |
| end | |
| App::PLATFORMS.each do |p,_| |
This file contains hidden or 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
| 115 lookup = Hash.new { |h,k| h[k] = [] } | |
| 116 specs = @specs.sort_by do |s| | |
| 117 s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s | |
| 118 end | |
| 119 specs.reverse_each do |s| | |
| => 120 lookup[s.name] << s | |
| 121 end | |
| 122 lookup | |
| 123 end | |
| 124 end |
This file contains hidden or 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
| source :rubygems | |
| gem 'rspec' |