Displaying 20 results from an estimated 10000 matches similar to: "#add method?"
2007 Sep 16
4
How far to go with ActiveRecord unit tests without hitting the database?
I''m currently try to push my limits a little bit with some of my unit
testing -- trying to avoid saving ActiveRecord objects to the database and
take advantage of mock/stub objects.
How far should I expect to get in this direction? From what I can tell,
ActiveRecord seems to fight me when it comes to associations. In other
words, many associations seem to require database queries.
2007 Sep 25
2
Testing for particular CSS (i.e. display: none)
I have a page that hides elements using CSS display: none.
I don''t expect RSpec to test any changes made by Javascript; I just want to
test how the page loads initially: what is visible and what is not.
Can I test this in RSpec? Or do I need to use something like Selenium?
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
2008 Aug 26
9
stub_model() and ActiveRecord Associations
Hi all,
I have what I thought was quite a simple requirement but something to
do with the way ActiveRecord''s associations work is making it quite
puzzling.
I guess I can sum it up with this failing test:
before(:each) do
@source_comment = @source.comments.create(:user_id => 1)
@target_comment = @target.comments.create(:user_id => 1)
end
2007 Sep 16
4
"Not Implemented" doesn''t show
I''m going through Peepcode''s Rspec Basics for an overview.
He''s just doing a simple spec:
class PeepCode
end
describe PeepCode do
it "should be awsome" do
end
end
So running spec spec/simple_spec.rb should produce according to his screen
cast:
1 example, 0 failures, 1 not implemented
but I only recieve:
1 example, 0 failures
Also spec
2007 Sep 04
3
Model Specs: Fixtures vs Mocks + Stubs?
What is the general opinion about fixtures versus mocking and stubbing
in model specs? I heard from agile on IRC that they save the database
testing for integration testing, but I also see that the caboose
sample applicaiton uses fixtures. I also noticed that on the rspec
site, it says "Ironically (for the traditional TDD''er) these are the
only specs that we feel should actually
2009 Mar 15
7
How to use different mocking frameworks?
Hi,
I''m pretty new to Rspec, so hope someone can help me out with this.
I''m leveraging a couple pre-existing applications in my current
project, both have fairly robust test suites in Rspec already.
However, one is using Rspec''s builit in mocking, and the other is
using mocha.
If I set config.mock_with mocha in spec_helper.rb, then all of the
rspec mocks fail. If I
2007 May 07
6
mock frameworks
Just curious - now that rspec (as of 0.9) let''s you choose your mock
framework, how many of you are actually using (or planning to use)
mocha or flexmock?
Anybody planning to use any other mock framework besides rspec, mocha
or flexmock?
Thanks,
David
2007 Feb 28
4
acts_as_authenticated error with Object#id
I''m getting this when I run my Rails controller specs.
<projectroot>/config/../lib/authenticated_system.rb:16: warning: Object#id
will be deprecated; use Object#object_id
I added "include AuthenticatedTestHelper" to /spec/spec_helper.rb so
that my controller tests^H^H^H^H^Hspecs can use the "login_as" helper
method. Anyone know how to fix this?
--
Cheers,
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 Sep 15
3
How to write a plugin that uses rspec internally?
My team is working on a plugin and we want to use RSpec internally for the
plugin''s tests.
(a) What are some different ways to go about this? Should we rely on the
RSpec gem? Should we expect that the "host" Rails application has installed
the RSpec plugins? Are there other options?
(b) Which approach from (a) would you recommend?
(c) Would you recommend any particular
2007 Jan 30
5
errors while testing resource controller using rpec
I am testing a resource called venue in this piece of code (generated
using script/rspec_resource)
====================
context "Requesting /venues using POST" do
controller_name :venues
setup do
@mock_venue = mock(''Venue'')
@mock_venue.stub!(:save).and_return(true)
@mock_venue.stub!(:to_param).and_return(1)
Venue.stub!(:new).and_return(@mock_venue)
2007 Mar 29
21
a better "should have valid associations"
This is pretty much the same as last time around, if you recall.
Thanks to Wilson for converting to the new form. I''ve added a few
lines. Basically, it iterates over your model associations and does
two things.
- First, just try to call the association. Usually fixes speeling
erors or other such silliness.
- Second, try to find a record with an :include on the association.
This
2007 Sep 16
10
I lost the RSpec fight
I''ve been working on a Rails project with one other developer; he was
using Test::Unit, and I was using RSpec. That works OK for a while, but
obviously it starts causing pain when you have to check in two places to
see if a piece of code is properly tested/spec''d, you can''t use TextMate
shortcuts to switch back and forth between code and test, you have to
duplicate
2007 Apr 28
7
[ rspec-Patches-9605 ] Patch for ER 9472, shared behaviour
Hi all - I''ve applied (to trunk) Bob Cotton''s patch which supports
shared behaviours (link to tracker below).
I''m still toying w/ names, so please be aware that until this is
released w/ 0.9 it should be considered experimental and there will
NOT be translation support for it. It will definitely be included in
some form - just the names (specifically
2007 Jul 18
10
Rails - Mock going out of scope?
Hello list,
I think I have a rails related RSpec problem with a mock going out of
scope on a recursive call to a model.
The code is at: http://pastie.textmate.org/79821 if you want to see it
highlighted. I have pasted it below as well.
Basically, I have an acts_as_nested_set model called "Node", which
works fine. I have a function which finds the language name of the
node instance.
2006 Oct 04
3
do we need stubbing?
Hey all -
The trunk currently supports three types of mocking/stubbing:
Mock Objects (created dynamically at runtime)
Partial Mocking of methods on existing classes
Stubbing of methods on existing objects or classes
The main difference between Partial Mocking and Stubbing is that Stubs
don''t verify.
I''m wondering if we really need the stubbing facility at all, given
that we
2007 Jun 07
4
checking associated objects have been deleted
I have the following model:
class Book < ActiveRecord::Base
has_many :taggings, :dependent => :delete_all
has_many :tags, :through => :taggings
end
is it possible to check that associated taggings are being destroyed
using mocks? I don''t want to test that rails is deleting the
associations, I want to test that I have specified the association as
a dependent one.
the only
2007 Aug 16
17
undefined method `mock_model'' for [RSpec example]:#<Class:0x25550a8>
I am getting:
undefined method `mock_model'' for [RSpec example]:#<Class:0x25550a8>
with my view specs after upgrading to 1.0.8. Is anyone else seeing this?
To isolate the message I did the following setup:
- create new rails project (with edge)
- installed rspec and rspec_on_rails
- ran rake spec
- ran script/generate rspec_scaffold products
- tried to run a builtin view
2008 Mar 04
9
What is your workflow? Or how to use the story runner the right way.
I really would like to know how people are using the Story and Example
runner to write their software.It would be great to get some direction on
it, because I think I''m missing some points.
Taking the outside-in approach in thought:
At first we write a high-level customer-facing story, this story fails.
Then we start using mocks at object level to use them as a design tool,
and so we
2009 Mar 08
2
rspec 1.1.99.12, Rails 2.3.1, undefined method `rspec_options=''
Hi David, all:
I recently upgraded to Rails 2.3.1RC2 (Ubuntu 8.10, ruby 1.8.7
(2008-08-11 patchlevel 72) [i486-linux]) and have been dilligently
following the instructions for upgrading rspec and rspec-rails
according to: http://wiki.github.com/dchelimsky/rspec/rails-with-rspec-gems.
and when I run ''rake gem'' fails with error:
rake aborted!
undefined method