Displaying 20 results from an estimated 83 matches for "kind_of".
2008 Jan 28
9
Nested matchers
We''re encountering a failure with Mocha 0.5.6.
We had this expectation:
game_version.expects(:attributes=).with(:game_file =>
kind_of(GameFile), :game_id => @game.id)
This expectation was passing with 0.5.5, but fails with 0.5.6.
I added this test to parameter_matcher_acceptance_test.rb, which
passes in 0.5.5 and fails in 0.5.6
def test_should_match_nested_parameters
test_result = run_test do
mock = mock()...
2009 May 18
3
Pagination
Hi,
I am using the will_paginate plugin for my application.
It is showing Previous 1,2,3...22,23,24 Next links
How will I hide the numbers?
I want to have first and last links also. How will i do that?
Thanks in advance.
--
Posted via http://www.ruby-forum.com/.
Overriding date_select in local project to use custom value rather than blank for starting option...
2005 May 08
3
Overriding date_select in local project to use custom value rather than blank for starting option...
I would like to have a date control on a page and I would like a
behavior similar to what you get using date_select with the
:include_blank => true option where the first value in the dropdown is
"- Month -", "- Day -", or "- Year -" rather than a blank value for
the respective month, day, and year select fields.
I took a look at the ruby source for
2006 Sep 13
1
Net::HTTPResponse
...y [1] uses a Net::HTTPResponse object for all it''s
responses from web servers. This class has many subclasses, such as
HTTPSuccess, HTTPRedirecttion, etc.
When obtaining a response, the library suggests to check what it is by testing
the class of the returned object - using case/when or kind_of? (which it does
internally)
So I need a mock object which can pass for a Net::HTTPResponse. However I
can''t create a Net::HTTPResponse directly - the "initialize" method is not
documented, and in the code is commented as "internal use only" - which
suggests it migh...
2011 May 13
4
unexpected results when extending methods to class Class and class Object
...nil
ruby-1.8.7-p330 :051 > @apple = Apple.new
=> #<Apple:0x105f15af8>
ruby-1.8.7-p330 :052 > Apple.like_apples!
hell yeah
=> nil
ruby-1.8.7-p330 :053 > @apple.like_apples!
hell yeah
=> nil
If a class is an object and an object is a class:
ruby-1.8.7-p330 :039 > Class.kind_of? Object
=> true
ruby-1.8.7-p330 :040 > Object.kind_of? Class
=> true
Then why can we access an instance method (extended via Object) directly
as a class method (as shown above), but we cannot access a class method
with an instance of a class (as shown above)?
Thanks for response
--
P...
2007 Feb 24
3
Spec failing [Possible Bug with kind_of? and instance_of?]
I have a spec which is failing, but I just can''t say why. Maybe I''m
missing something painfully obvious?
Here is the pastie of the results & the spec:
http://pastie.caboo.se/42626
The spec to look for is "should have an array of users" I''ve printed
out ("puts''ed") to the terminal the fact that the values are
*opposite* to what
2007 Oct 20
14
Problems with form_for and partials
i''m having problem with a form_for situation where i''m trying to DRY
out the repeated parts of my forms and put them in common/form and
render the form elements via another partial in controller_name/_form.
Here''s the first form
# app/views/common/form
<% form_for ... do |f| -%>
<%= render :partial => "params[:controller]/form", :object => f
2007 Feb 28
12
Specifying that code is called in a block
Not sure if this is possible currently.
I have a section of code like this:
ActiveRecord::Base.transaction do
cow.save!
duck.save!
dog.save!
end
(Names changed to protect the innocent.)
I''d like to specify that the saves run in a transaction. I can do
ActiveRecord::Base.should_receive(:transaction).and_yield
But is there any way to specify that the code is
2008 Oct 14
3
Server settings for BackgrounDRB?
I have backgroundrb working locally and everything''s fine. However, i
can''t get it running on our server.
I read a blog post by David Burger about backgroundrb
(http://david-burger.blogspot.com/2008/04/backgroundrb-rails-notes.html#comment-form)
and it says that you set up your backgroundrb.yml file with a different
section for each environment you want to use. Mine looks like
2009 Nov 17
5
has_many :through and foo.bars.include?
...at: "2009-10-28 11:42:36", updated_at:
"2009-10-28 11:42:36">
>> g.admins.include? User.first
ArgumentError: wrong number of arguments (1 for 0)
from /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/connection_adapters/mysql_adapter.rb:226:in `kind_of?''
from /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/connection_adapters/mysql_adapter.rb:226:in `quote''
from /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.4/lib/
active_record/base.rb:2392:in `quote_bound_value''
from /usr/li...
2006 Aug 11
2
Array#chunk method, maybe someone will find this useful
class Array
# break an array up into <size> chunks
def chunk(size=1)
return self if self.empty?
raise ArgumentError if !size.kind_of? Integer
y = self.length.divmod(size)
rows = (y[1] > 0) ? y[0] + 1 : y[0]
arr = Array.new(rows)
(0...rows).each do |i|
arr[i] = self.slice(size*i, size)
end
(arr.last.length...size).each { |i| arr.last[i] = nil } if
arr.last.length < size
arr
end
end
put...
2006 Jan 17
9
Formatting a float with a set number of decimals
Another newbie question:
How do i convert a float to a string, rounded to a certain number of
decimals?
Thanks
--
Posted via http://www.ruby-forum.com/.
2008 Jun 26
6
ActiveRecord search Query Question
...new to ruby on
rails so please forgive me.
hope some one can help
def conditions_by_like(value, *columns)
myArray = value.gsub(/[^\A-Za-z0-9\s]/, "").split(/ /)
myArray.each do |itemz|
columns = self.user_columns if columns.size==0
columns = columns[0] if columns[0].kind_of?(Array)
conditions = columns.map { |c|
c = c.name if c.kind_of? ActiveRecord::ConnectionAdapters::Column
"`#{c}` LIKE " +
ActiveRecord::Base.connection.quote("%#{itemz}%")
}.join(" OR ")
end
end
--
Posted via http://www.ruby-forum.com/....
2006 Mar 20
2
Testing Models And Fixtures
...02-01 00:00:00
updated_at: 2006_02-02 00:00:00
===========
post_test.rb
===========
require File.dirname(__FILE__) + ''/../test_helper''
class PostTest < Test::Unit::TestCase
fixtures :posts
def setup
@post = Post.find(1)
end
def test_create
assert_kind_of Post, @basic_post
assert_equal @basic_post.id, @post.id
assert_equal @basic_post.title, @post.title
assert_equal @basic_post.body, @post.body
assert_equal @basic_post.created_at,
@post.created_at_before_type_cast
assert_equal @basic_post.updated_at,...
2006 Mar 22
1
Engine Trouble With Edge
...class RootLoadingModule < LoadingModule
# hack to allow adding to the load paths within the Rails
Dependencies mechanism.
# this allows Engine classes to be unloaded and loaded along with
standard
# Rails application classes.
def add_path(path)
@load_paths << (path.kind_of?(ConstantLoadPath) ? path :
ConstantLoadPath.new(path))
end
end
I have the very latest from Engines via. svn. Is anyone else having the
same problems.
Cheers,
Eric Goodwin
2005 Aug 16
1
Defining model classes for enumerations
...oid the tedious work of defining a
class for each one explicitly. Not least, in order to avoid clutter in
the model directory.
Here''s what I''ve come up with:
class EnumRecord < ActiveRecord::Base
def self.define_enums(*enums)
enums.each do |spec|
if spec.kind_of?(Hash)
class_name = spec[:class_name].to_s
raise ArgumentError, ''An enum specification must contain
a :class_name'' if class_name.empty?
order = spec[:order] || ''position''
table_name = spec[:table_name] || class_name...
2006 Aug 11
5
Unit tests - NilClass problem
...end
end
and when trying to run it I get:
------------
Loaded suite customer_test
Started
F
Finished in 0.731 seconds.
1) Failure:
test_create(CustomerTest)
[./../test_helper.rb:31:in `test_creation_of''
customer_test.rb:13:in `test_create'']:
<nil>
expected to be kind_of?
<Customer> but was
<NilClass>.
1 tests, 1 assertions, 1 failures, 0 errors"
-----------------
Any idea what might be wrong here?
Thanks,
John
--
Posted via http://www.ruby-forum.com/.
2006 Apr 06
7
LoginSystem : make @session available to models
...er_create :create_history
before_destroy :destroy_history
def update_history
history (''update'')
end
def create_history
history (''create'')
end
def destroy_history
history (''destroy'')
end
def history(action)
unless kind_of?(History)
history = History.new(:action => action)
history.ref = self
history.save
end
end
end
With, roughly, a History model like :
:user_id # who performed the action
:action # the action
:date # when
:ref_table # the table of the altered model
:ref_id # the id of the...
2006 Jan 30
9
Something as after_successful_validation?
I need to call callback only if the validation was successful, but it
seems it is called also when validation fails.
--
Posted via http://www.ruby-forum.com/.
2006 Jan 10
5
problems overriding module with plugin
Hi I am trying to create a plug-in to fix the error in the rails core
produced by the multiple delete on a HABTM relationship. I have
confirmed that my plug-in is being included into the base during
runtime however the code does not seem to be overridding the base
class.
module ActiveRecord
module Associations
module ClassMethods
def has_and_belongs_to_many(association_id, options =