- Email: [email protected]
- Twitter: @rsim
- Website or Blog: http://blog.rayapps.com
- Company: EazyOne
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 "rubygems" | |
require "activerecord" | |
# ActiveRecord::Base.establish_connection :adapter=>"oracle_enhanced",:username=>"hr",:password=>"hr",:database=>"orcl" | |
ActiveRecord::Base.establish_connection :adapter=>"jdbcsqlite3", :database=>"jruby_test.sqlite3", :timeout => 5000 | |
ActiveRecord::Schema.define do | |
suppress_messages do | |
create_table :posts, :force => true do |t| | |
t.string :title |
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
1) | |
'Adapter with mysql DataMapper::Adapters::MysqlAdapter#read with a Collection bind value with an inclusion comparison that is not loaded should return expected values' FAILED | |
expected: [{#<DataMapper::Property @model=Article @name=:name>=>"Test 1", #<DataMapper::Property @model=Article @name=:parent_name>=>"Test 0"}, {#<DataMapper::Property @model=Article @name=:name>=>"Test 2", #<DataMapper::Property @model=Article @name=:parent_name>=>"Test 1"}, {#<DataMapper::Property @model=Article @name=:name>=>"Test 3", #<DataMapper::Property @model=Article @name=:parent_name>=>"Test 2"}, {#<DataMapper::Property @model=Article @name=:name>=>"Test 4", #<DataMapper::Property @model=Article @name=:parent_name>=>"Test 3"}], | |
got: [{#<DataMapper::Property @model=Article @name=:name>=>"Test 0", #<DataMapper::Property @model=Article @name=:parent_name>=>nil}] (using ==) | |
2) | |
'Adapter with mysql DataMapper::Adapters::MysqlAdapter#read with a Collection bind value with an inclusion comparison that is loaded should return e |
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
1) | |
'DataMapper::Query#difference with mysql with other having a limit should put each query into a subquery and AND them together, and negate the other' FAILED | |
expected: #<DataMapper::Query::Conditions::AndOperation:0x6a22a6bb @operands=#<Set: {#<DataMapper::Query::Conditions::EqualToComparison @subject=#<DataMapper::Property @model=User @name=:name> @dumped_value="Dan Kubb" @loaded_value="Dan Kubb">, #<DataMapper::Query::Conditions::NotOperation:0x5f44426c @operands=#<Set: {#<DataMapper::Query::Conditions::InclusionComparison @subject=#<DataMapper::Associations::OneToMany::Relationship:0xc00a029 @reader_visibility=:public, @query={}, @child_repository_name=#<DataMapper::Repository @name=default>, @parent_model=User, @max=Infinity, @options={:min=>0, :max=>Infinity, :child_key=>[:name], :parent_key=>[:name], :child_repository_name=>#<DataMapper::Repository @name=default>, :parent_repository_name=>#<DataMapper::Repository @name=default>}, @min=0, @parent_repository_name=#<DataMapper::Repository @name=default>, |
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 define_equivalent_method(methods) | |
respond_to = [] | |
equivalent = [] | |
methods.each do |method| | |
respond_to << "other.respond_to?(#{method.inspect})" | |
equivalent << "#{method} == other.#{method}" | |
end | |
class_eval <<-RUBY, __FILE__, __LINE__ + 1 |
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 "rubygems" | |
gem "activerecord", "= 2.3.5" | |
gem "activerecord-oracle_enhanced-adapter", "= 1.2.3" | |
require "active_record" | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Base.establish_connection( :adapter => "oracle_enhanced", | |
:database => "orcl", :username => "hr", :password => "hr") | |
ActiveRecord::Base.connection.instance_eval do |
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::Runner.configure do |config| | |
config.extend(DataMapper::Spec::AdapterHelpers) | |
config.include(DataMapper::Spec::PendingHelpers) | |
config.after :all do | |
# global model cleanup | |
descendants = DataMapper::Model.descendants.to_a | |
while model = descendants.shift | |
descendants.concat(model.descendants.to_a - [ model ]) | |
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::Runner.configure do |config| | |
config.extend(DataMapper::Spec::AdapterHelpers) | |
config.include(DataMapper::Spec::PendingHelpers) | |
config.after :all do | |
# global model cleanup | |
descendants = DataMapper::Model.descendants.to_a | |
while model = descendants.shift | |
descendants.concat(model.descendants.to_a - [ model ]) | |
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 rank(arr) | |
count = {} | |
arr.each{|item| count[item] = (count[item]||0) + 1} | |
rank = 1 # initial ranking | |
ranking = {} | |
count.keys.sort.reverse.each{|item| ranking[item] = rank; rank += count[item]} | |
arr.map{|item| ranking[item]} | |
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
# put this file in spec/javascripts/support directory | |
require 'barista' | |
require 'logger' | |
require File.join(Rails.root, 'config/initializers/barista_config') | |
Barista.configure do |c| | |
c.env = 'test' | |
c.logger = Logger.new(STDOUT) | |
c.logger.level = Logger::INFO |