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
SELECT lat, lon, SQRT( POW( 69.1 * ( lat - 33.673989 ) , 2 ) + POW( 69.1 * ( 111.858430 - lon ) * COS( lat / 57.3 ) , 2 ) ) AS distance FROM cities where distance < 25 ORDER BY distance; |
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
def test_class(o) | |
case o.class | |
when Foo | |
puts "foo class" | |
else | |
puts "not found" | |
end | |
end | |
o = Foo.new |
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
## Controller | |
class FooController < ActionController::Base | |
def wtf | |
SomeObject.foo | |
end | |
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
Loading development environment (Rails 3.0.7) | |
ruby-1.9.2-p180 :001 > | |
ruby-1.9.2-p180 :002 > | |
ruby-1.9.2-p180 :003 > | |
ruby-1.9.2-p180 :004 > | |
ruby-1.9.2-p180 :005 > ObjectSpace.each_object(Class).select { |v| v < Snippet } | |
=> [] | |
ruby-1.9.2-p180 :006 > Snippet::Cheap.new => #<Snippet::Cheap id: nil, location_id: nil, listing_id: nil, type: "Snippet::Cheap", content: nil, approved: false> | |
ruby-1.9.2-p180 :007 > ruby-1.9.2-p180 :008 > ObjectSpace.each_object(Class).select { |v| v < Snippet } | |
=> [Snippet::Cheap(id: integer, location_id: integer, listing_id: integer, type: string, content: text, approved: boolean)] |
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
Loading development environment (Rails 3.0.7) | |
ruby-1.9.2-p180 :001 > | |
ruby-1.9.2-p180 :002 > | |
ruby-1.9.2-p180 :003 > | |
ruby-1.9.2-p180 :004 > Snippet::Cheap < Snippet | |
=> true | |
ruby-1.9.2-p180 :005 > ObjectSpace.each_object(Class).select { |v| v < Snippet } | |
=> [Snippet::Cheap(id: integer, location_id: integer, listing_id: integer, type: string, content: text, approved: boolean)] | |
ruby-1.9.2-p180 :006 > |
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
## spec | |
it '#index' do | |
mock(controller).index | |
get :index | |
response.should be_success | |
end | |
## controller |
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
class_eval traced_method, __FILE__, __LINE__ |
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 'spec_helper' | |
describe 'wtf' do | |
it "doesn't allow non-mocked method calls if any methods are mocked" do | |
u = User.new | |
mock(u).first_name | |
u.first_name | |
u.last_name | |
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
require 'spec_helper' | |
describe 'wtf' do | |
it "doesn't allow calls to a mocked method with different args" do | |
mock(User).find | |
User.find(1) | |
User.find(23) # where uses find internally | |
end | |
# error unexpected find(23) called |
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
foo = case | |
when true | |
'foo' | |
else | |
'bar' | |
end | |
# foo = 'foo' | |
foo = case | |
when true |
OlderNewer