Displaying 20 results from an estimated 28 matches for "mockexpectationerror".
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
./spec/controllers/tickets_controller_spec.rb:16:
script/spec:4:
class TicketsController < ApplicationController...
2007 Sep 30
9
Problems with testing nested routes using mocking
Hello forum
I have there to files
#----- virtual_host_controller.rb
class VirtualHostsController < ApplicationController
before_filter :capture_domain
# GET /domain/1/virtual_hosts/1
def show
@virtual_host = @domain.virtual_hosts.find(params[:id])
respond_to do |format|
format.html # show.rhtml
end
end
private
def capture_domain
if
2008 Jun 04
5
controller filters running twice in 1.1.4?
....
Adding this code to application.rb:
before_filter :foo
def foo
"foo"
end
and an example in users_controller_spec.rb:
it "should call foo via a before filter" do
controller.should_receive(:foo)
do_get
end
results in this:
1)
Spec::Mocks::MockExpectationError in ''UsersController handling GET
/users.xml should call foo''
Mock ''UsersController'' expected :foo with (any args) once, but received it
twice
script/spec:4:
Is any one else seeing this?
Thanks,
Matt
--
View this message in context: http://www.nabble.com/contr...
2007 Jun 05
6
Help with spec controller
Hello,
I haven''t been able to create a controller spec.
You can see the code here:
http://pastie.caboo.se/67980
The error message I''m getting is:
Spec::Mocks::MockExpectationError in ''PersonController should tell the Person
model to create a new person on POST to create''
Mock ''person'' received unexpected message :save with (no args)
/home/gramos/src/rails/dental/config/../app/controllers/person_controller.rb:26:in
`create''
./spec/...
2007 Dec 04
10
Unexpected message on :attr_accessor
...eceive(:find).and_return(@user)
@user.should_receive(:password_confirmation)
get ''edit'', :id => @user.id
end
I am asking it to expect that I will be assigning something to that
attribute in the "edit" method. Unfortunately, the spec fails with
Spec::Mocks::MockExpectationError in ''UsersController should find User on
GET to users/edit/:id''
Mock ''user'' received unexpected message :password_confirmation= with
("password")
Initially I thought that my "should_receive" expectation was incorrectly
written, but if I commen...
2008 Nov 13
6
.with(:anything) issue
Hi,
I''m using a expectation like this :
repository.should_receive(:add_gem).with("test.txt", :anything)
When I run my spec, it fails with the following message :
Spec::Mocks::MockExpectationError in ''MiniGemServer should add a new gem to
the repository after it has been uploaded''
#<MiniGemServer::Repository:0xb11164> expected :add_gem with ("test.txt",
:anything) but received it with ("test.txt",
"C:/DOCUME~1/xyzuser/LOCALS~1/Temp/RackMultipa...
2007 Mar 27
2
mocking/stubbing newbie questions
...=> 1
end
it "should find all terms associated with the user" do
User.should_receive(:find).with("1")
end
end
the controller code:
class TermsController < ApplicationController
def index
User.find(1)
end
end
the spec results:
1)
Spec::Mocks::MockExpectationError in ''GET /users/1/terms should find
all terms associated with the user''
User expected :find with ("1") once, but received it 0 times
./spec/controllers/terms_controller_spec.rb:43:
./script/rails_spec_server:21:in `run''
./script/rails_spec_server:42:
Thanks f...
2007 Feb 15
17
Odd parameter munging with with()
Hi,
I have this setup block:
setup do
session[:login] = ''jhughes''
@user = mock("user")
User.stub!(:find).and_return(@user)
@params = {:cn => "Bilbo Baggins",
:telephoneNumber => "416-277-4418",
:mail => "bilbo at baggins.com"}
end
And then this spec:
specify "should update and save the
2007 Sep 18
2
rSpec / Nested Routes / Mocks
I''m having a terrible time trying to test a nested route with rSpec.
I can''t seem to tell rSpec to expect the call @item.user. The
following error message plagues me not matter how I try to fuss with
the mock:
Spec::Mocks::MockExpectationError in ''ItemsController handling POST /
items should redirect to the new course on successful save''
Mock ''Item_1002'' received unexpected message :user= with (#<User:
0x..fdb7bcd38 @name="User_1003">)
Any help would be greatly appreciated.
Here'...
2007 Jun 15
6
problem getting started with stubbing in rails controller specs
...on.stub!(:find).and_return(@mock_stations)
get ''index'', :locale => ''en''
end
it "should find stations" do
Station.should_receive(:find).with(:all).and_return
(@mock_stations)
end
end
It fails with this error:
Spec::Mocks::MockExpectationError in ''GET to index should find stations''
Station expected :find with (:all) once, but received it 0 times
./spec/controllers/stations_controller_spec.rb:22:
I can see in the log that the database is not hit for Station.find
(:all), so the stubbing seems to have worked. Guess I'...
2010 Jul 13
2
[Rspec] Difference between stub and message expectation with any_number_of_times
I''m wondering what''s the difference between stub and message expectation
with any_number_of_times, for example:
myMock = mock("mymock")
myMock.stub!(:is_a?).with(MyClass).and_return(false)
and
myMock = mock("mymock")
myMock.should_receive(:is_a?).with(MyClass).any_number_of_times.and_return(false)
because is_a? may not be called at all, it just like a
2007 Apr 11
12
redirection doesn''t get detected well?
I''m doing a redirect in one of my controller actions and somehow I can''t
spec it, see this pastie: http://pastie.caboo.se/53120.
When following the link from a browser I''m being redirected to the right
page.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
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 results
from my Intermediate class up to the next
2008 Sep 24
19
How to define request.domain in when testing
Hi,
My application relies on request.domain for doing its job. The problem I
am encountering, is that when running tests, request.domain returns
"test.host", how can I change that so that it returns "mysite.com"?
Thanks in advance.
--
Posted via http://www.ruby-forum.com/.
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 = @company.addresses.find(:all)
respond_to do |format|
format.html # index.html.erb
format.xml {
2008 Jul 25
21
Problems with mock assigned to a constant
...obviously I was passing the
wrong arguments to the mock. I revised my example to more clearly state my
problem:
http://gist.github.com/2372
This is a snip of a some code from a library I''m writing. When I run this
spec I get the following:
# spec migration_spec.rb
.F
1)
Spec::Mocks::MockExpectationError in ''Migration should find the records''
Mock ''MyModel Class'' received unexpected message :count with (no args)
./migration.rb:14:in `run''
./migration_spec.rb:19:
Finished in 0.009164 seconds
2 examples, 1 failure
---------------------------------------...
2007 Dec 13
16
"Tricks" for testing after_create callback???
...cipient => people(:john)
}
SantasMailbox.should_receive(:deliver_secret_santa).with(Message.new(msg_creation_parms))
Message.create(msg_creation_parms)
end
end
This fails, but only because the model object has an id and time
stamps assigned as it''s saved.
Spec::Mocks::MockExpectationError in ''Message from anyone should be
sent on save''
Mock ''Class'' expected :deliver_secret_santa with (#<Message id: nil,
subject: "Subj", body: "hi", sender_id: 343839476, recipient_id:
21341157, message_type: nil, created_at: nil, updated_at:...
2008 Apr 29
1
Spec''ing controller macros
...# ...
end
My current attempt seems to be quite unsuccessful:
1) when I include the controller.should_receive(:session) statement, the
index action no longer seems to be actually called (ie a breakpoint placed
in the index method is not triggered)
2) I receive the following error:
Spec::Mocks::MockExpectationError in ''ApplicationController should turn off
session management for requests made by robot user agent''
Mock ''FooController'' expected :session with (:off) but received it with (no
args)
./spec/controllers/application_spec.rb:19:
Any suggestions?
Thanks much,
Matt...
2009 Oct 19
0
Help with controllers specs
...end
end
end
**************************************
The method is_admin in Application Controller
def is_admin?
logged_in? && current_user.role == Role.find(Role::ADMINISTRATOR)
end
***************************************************
The error I have is
Spec::Mocks::MockExpectationError in ''UsersController GET edit
authenticated user should find user and return object''
Mock ''User_1015'' received unexpected message :role with (no args)
How should I verify the method is_admin?
Thank you
EM
-------------- next part --------------
An HTML a...
2007 Apr 13
1
spec''ing out a trap/SIGINT
How would you spec out a call to Signal.trap (a ^C or a unix SIGINT)?
Scott