Displaying 20 results from an estimated 7000 matches similar to: "mock libraries, Object#send, and Object#__send__"
2008 Jul 25
21
Problems with mock assigned to a constant
Hi all,
Initially I thought this was a bug in the built-in mocking framework(and it
still may be), but I better hash it out on the mailing list before I
file/reopen the ticket:
http://rspec.lighthouseapp.com/projects/5645/tickets/478-mocks-on-constants#ticket-478-6
I thought my example illustrated my problem, but obviously I was passing the
wrong arguments to the mock. I revised my example to
2007 Apr 20
5
stubbing with and without a string
What is the difference between these two ways of mocking (with and
without the string):
mock(''Object'')
and
mock(Object)
?
Scott
2007 Apr 17
8
Verifying that a block calls a method
I have something like the following:
def my_fun
my_fun2 do
raise Error
end
end
I know that I can verify that the method receives my_fun2. How can I
mock/stub out the example to verify that it calls raise Error?
Scott
2007 Aug 14
4
Stubbing all methods
Mocha''s mock/stub framework has the ability to stub all methods on a
mock given. Does RSpec''s mocking framework have this ability? And
if not, is there some reason it shouldn''t be implemeneted?
Regards,
Scott
2007 Aug 14
1
To mock or not mock base classes
Just a general opinion question on idioms/common usage. Is it better
to mock Ruby''s base classes, or to use real instances of those base
classes?
@string = mock String
@string.stub!(:to_s).and_return "hello"
# or:
@string = "hello"
I was wondering which is generally favored, and if so, for what
reasons? Or is it highly dependent on the type of spec which is
2007 Mar 24
15
State Based vs. Behaviour Based Spec/Testing
I''ve notice that a project like Rubinius has both a spec & a test
directory. Rspec has only a spec directory. Obviously I support
BDD, but isn''t there also a place for state based/verification
testing? I sometimes sense that I *do* want to practice Test Driven
Development. That is, I want some assurance that my production code
will run as intended. But I also
2007 Aug 07
2
stubs which yield and return
Is there any reason why a stub couldn''t both yield and return? I''m
looking for a way to mock out a class I''ve made named "AnonymousClass":
class AnonymousClass
def initialize(&blk)
@klass = Class.new
@klass.instance_eval(&blk) if block_given?
end
def new
@klass.new
end
def evaluate(&blk)
2007 Sep 05
6
Caveman Questions
Hello!
I''m just a caveman with some caveman questions.
I''ve been parsing Rspec for quite a while, and I''m writing my first series
of specs. My initial impressions are "Verbose, but understandable. Helpful
and intuitive, but so much to digest." I want to congratulate the folks who
are dedicating a chunk of their lives to writing this, and ask 2 caveman
2007 Aug 16
3
Mocking a non-existent method
I don''t like this:
i = mock(Integer)
i.should_receive(:asdfasdf).and_return(''foo'')
puts i.asdfasdf
Shouldn''t rspec check to see that :asdfasdf is a valid message to be
sending Integer?
Joe
2007 Aug 14
4
(no subject)
How would you spec out something like the following:
def a_method
x = Class.new do
include Enumerable
end
# do something here with x
end
describe "The Anonymous Class" do
before :each do
@anonymous_class = mock Class
Class.stub!(:new).and_return @anonymous_class
end
it "should create a new anonymous class" do
2007 Aug 07
4
Problems with raising errors on a mocked object
I''m trying to mock a object to raise a certain error. By doing so I
get a ArgumentError on ActiveRecord''s save! method:
http://pastie.caboo.se/85628
I''ve tried to debug it but just can''t seem to find what I''m doing
wrong. Any help is greatly appreciated.
Cheers,
Eivind Uggedal
2007 Oct 25
6
Rollbacks, Sqlite3 bug
Okay - so the sqlite bug reported a day or so ago on the list is real
bug. I''m going to file something in the tracker for that...
I also learned that before(:all)...after(:all) is not wrapped in a
transaction, the way before(:each)...after(:each) is. Is there some
reason behind this? Can you not wrap transactions inside transactions?
Scott
2006 Jul 24
6
Mocking causes empty specification blocks
I''ve found myself mocking out a published api in my set-up method.
This has led to some contexts having a large set-up and empty
specifications. As the mocks get auto-verified, the specification
blocks have nothing to do but serve as documentation. Does this sound
bad?
Chris
2007 Apr 10
6
getting output of STDOUT in spec
Consider the following method:
def name_to_terminal
puts "Scott Taylor"
end
How would I spec this out?
Scott
2007 Aug 31
48
Deprecating the mocking framework?
I saw in one of Dave C.''s comments to a ticket that "our current plan
is to deprecate the mocking framework." I hadn''t heard anything about
that, but then again I haven''t paid super close attention to the list.
Are we planning on dumping the mock framework in favor of using Mocha
(or any other framework one might want to plug in?).
Pat
2007 Aug 08
5
and_yield + instance_eval(&block)
I have the following code, which yields instance eval''s the block given:
class Foo
def bar(&blk)
instance_eval &blk
end
def baz
yield
end
end
The effect of this is that self is reassigned:
Foo.new.bar do
# here, self is the instance of Foo
# created by new
end
But normally self is the object in which
Foo.new.bar {...} occurs.
Foo.new.baz do
2007 Oct 23
9
Running rails specs outside of the normal project tree
I want to create a spec/regressions directory with various
regressions (for my rails project). I tried the following:
describe LoginController, "regression for user creation when
steves_sister does not exist", :behavior_type => :controller do
controller_name :login
before :each do
@params = {
"commit"=>"Create Account",
2007 Oct 27
2
Strange warnings with view specs
I''ve been seeing the following in some of my view specs:
.P.P........ignoring attempt to close spec::mocks::mock:0x7334c4c
with td
opened at byte 258, line 20
closed at byte 287, line 20
attributes at open: {}
text around open: "\t</tr>\n\t<tr>\n\t\t<td>#<Spec::Mocks::Mock:0"
text around close:
2007 Apr 10
5
using YAML for --failures and --examples
As it is currently, in trunk, --failures and --examples except a text
file, each line containing the name of a spec.
I''m wondering: Would a a patch to use YAML (instead or as well as)
plain text be welcomed? I''m thinking of a yaml file like the following:
spec_file_1:
file: spec/person_spec.rb
specs:
- should have first name
- should provide email address
2007 May 12
3
[OT] - In Memory Databases
My specs are still taking to long to run in a rails app. Is anyone
using an in-memory database to run their specs? Any pointers or tips?
Scott