Displaying 20 results from an estimated 2527 matches similar to: "checking associated objects have been deleted"
2010 Jun 25
3
[Rails] Can't get controller test working with RSpec 2 and edge Rails 3
Not sure if this is a Rails 3 issue or an RSpec 2 issue, but I can't seem to
get a standard controller test working - it seems that the 'get' method
can't be found.
I have a controller test that looks like this (named
"discrepancies_controller_spec.rb" in spec/controllers directory):
require
2007 May 15
5
spec_server
hi all
I'm trying to use spec_server to run my specs in rails, but the specs
don't seem to be running any faster, and it looks like they're being
run twice when I use the --drb option ..? The app I'm testing is just
a basic rails app with 2 empty models and a hello world controller.
The specs are
2011 May 27
14
[rails] undefined method `model_name' for NilClass:Class
Never seen the error above before, code:
describe "edit action" do
it "edit action should render edit template" do
food = Food.create(:name=>'mooo') #
Food.any_instance.stubs(:valid?).returns(true)
get :edit, :id => food.id
response.should render_template(:edit)
2007 Feb 17
1
"warning: object#id will be deprecated" with mocks
hi all
I have the following code in a spec:
@user = mock("user")
User.stub!(:authenticate).and_return(@user)
@user.should_receive(:id).once.and_return(99)
post :login, {:username => 'username', :password => 'password'}
session[:user_id].should == 99
it works as expected but I get the
2007 Oct 05
7
Easy AR association stubbing
I've added a method to the mock class that makes it pretty easy to
stub associations in rails. I've been using it for awhile and it seems
to cut down on a lot of setup code for the controller and model specs
that use associations.
#before
@person = mock_model(Person)
posts = mock('post_proxy')
2007 Aug 12
5
stubbing a method that yeilds sequential results
I've just found myself stuck trying to rspec something so am hoping
someone more knowledgable can help.
I have a Connector class which has a class method 'results' that
yields results it get from a network service based on a set of
attributes that I pass to it. I am wanting to yield these
2008 Nov 18
8
Mocking and stubbing model relationships
Before writing specs for a one-to-many relationship between two
models, I did some research and found that some people were creating
proxy mocks, and others were using Matthew Heidemann's
#stub_association! (which essentially does that for, but in a nice,
DRY way):
2006 Jul 04
2
has_many working correctly only on reload!
I have this code that is using svn externals with rails EDGE working
fine for the past couple of months. A couple of days ago, this code
died. Even after deleting vendor/rails, this code doesnt work:
class Tag < ActiveRecord::Base
has_many :taggings
has_many :events, :through => :taggings
2008 Dec 05
10
proxy associantion on controllers
Hello, I'm trying learn Rspec but having problems to understand when and how
user mocks and stubs.
I have a properties_controller with to before_filter actions
(check_administrator_role e load_user)... to access index action of
properties_controller I need have a params[:user] and this parameter
2008 Nov 26
4
rails associations
Hello!
So I'm having some problems working out some probably really easy
associations in Rails. I've Googled around and read some things on
different Rails forums and blogs, but I just haven't seen many solid
examples.
Anyway, my question is a basic "how do I use RSpec with stubs/mocks through
2008 May 26
7
Mocking Models in Controller Specs...
I find myself doing this kind of thing a lot in Controller Specs:
@vacancy = mock_model(Vacancy)
@vacancy.stub!(:reference)
@vacancy.stub!(:title)
@vacancy.stub!(:created_at)
@vacancy.stub!(:updated_at)
@vacancy.stub!(:body)
@vacancy.stub!(:contract)
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 May 31
16
Could anyone please help with rspec/nested resource behavior checking?
My problem has been listed here:
http://railsforum.com/viewtopic.php?pid=25439#p25439
Don't think it would be required to completely re-type it here :)
Thanks!
--
-Daniel Fischer
http://danielfischer.com - Geek Blog
http://abigfisch.com - Portfolio
http://writersbeat.com - Writing Community
2007 Aug 17
11
[rspec] looking for a simple refresher
I've been off the rspec for a few months and I'm trying to get back on it.
1)
Spec::Mocks::MockExpectationError in 'TicketsController handling POST
/tickets should create a new ticket'
Mock 'Ticket_1001' expected :new with ({}) once, but received it 0 times
2007 Jul 24
4
Possible Bug
I'm trying to test some code that has validates each and I've got a very
strange failure
Mock 'Book_1027' expected :store_with_privacy? with (#) but received it with (#)
The Spec
it "should check that a book can save a clip" do
2007 Aug 23
6
controller spec with model that validates_uniqueness
I want to use mocks and stubs to test the controller, but am having
trouble getting my validation not to trigger. Here's the code:
# spec:
Image.stub!(:find).and_return(@image)
@image.should_receive(:save!).once.with(:any_args)
put :update, :id => @image.id, :category_id =>
2007 Nov 21
7
describe AddressesController, "handling GET /addresses" do
Hello,
I'm working with scaffold generated controller test code for handling GET
requests. Address is the model being tested. Address belongs_to Company,
Company has_many addresses.
In my addresses_controller I have:
before_filter :get_company
def index
@addresses =
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
2007 Oct 08
6
spec'in controllers request for nested routes
describe PlayersController, "handling GET /saltmines/games/1/players" do
before do
@game = mock_model(Game, :to_param => "1")
@game.stub_association!(:players, :find => mock_model(Player))
end
def do_get
get :index, :game_id => @game
end
it "should be successful" do
2008 Aug 19
4
When to mock
I noticed that the examples on the rspec website for model code
http://rspec.info/documentation/rails/writing/models.html have no mocks or
stubs. However both the controller example and view example do have mocks
and stubs implemented. I was having some problems getting mocks to work in
my model