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 LocalStorage | |
def self.[](name) | |
`localStorage.getItem(name)` | |
end | |
def self.[]=(name, value) | |
`localStorage.setItem(name, value)` | |
end | |
def self.key?(name) |
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
// runtime | |
Opal.modules = {}; | |
Opal.register = function(name, body) { | |
Opal.modules[name] = body; | |
}; | |
Opal.require = function(name) { | |
var module = Opal.modules[name]; | |
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
class Bar < Foo | |
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
require 'opal' | |
require 'rails_templates' | |
p Template.paths | |
# => ['login', 'logout', 'user', 'user/new'] |
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
describe NewProductView do | |
# do we have to repeat this? | |
view NewProductView | |
it "tries to add product on click submit" do | |
expect(view).to receive(:add_product).once | |
find('#submit').click | |
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
Product.find(1).then do |product| | |
puts "product: #{product}" | |
end.else do | |
puts "failed :(" | |
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
class User < Vienna::Model | |
attributes :first_name, :last_name | |
end | |
user = User.new | |
first = Frappuccino::Stream.new(user).capture(:changed_first_name) | |
last = Frappuccino::Stream.new(user).capture(:changed_last_name) | |
# last name is any change to first or last name | |
last_name = first.merge(last).map { "#{user.first_name} #{user.last_name}" } |
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 JqueryRspecHelpers | |
def stub_http(action, url, result) | |
expect(HTTP).to receive(action).with(url).and_yield(result) | |
end | |
end | |
describe User do | |
describe ".current" do | |
it "should make an http request for user details" do | |
stub_http(:get, '/current_user', { "name" => "Fred", "admin" => true }) |
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
describe "Timeouts" do | |
async "blah" do | |
default_timeout 100 | |
set_timeout(4000) do | |
run_async { :ok } | |
end | |
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
Opal.register_metadata([ | |
{ | |
"method": "Array#size", | |
"file": "opal/array.rb", | |
"line": 12, | |
"source": "# This method.......\ndef size;....\nend" | |
}, | |
{ | |
"method": "Array#slice", |
NewerOlder