search for: mock_us

Displaying 18 results from an estimated 18 matches for "mock_us".

Did you mean: lock_un
2006 Dec 24
6
What do you think of this controller spec?
Here''s a controller spec I wrote, it''s for a very simple RESTful controller (well, aren''t all RESTful controllers simple? :) I''ve created a couple spec helper methods to refactor some of the common code...for example, require_login_and_correct_user creates two specifications: one for when the user isn''t logged in, and one when the user is logged in but
2007 Nov 13
2
More Rails Pattern Examples?
Hi, I have been reading the documentation and examples on the rspec site. There are two "patterns" from Rails that I am not clear how to implement that are kind of related, and so I am not sure how to start. Does anyone have any examples of how to write rspecs for these? 1/ Nested resources. 2/ Resources that are specific to the current_user. In other words, I only want to
2007 May 26
11
RSpec
Hi RSpec Mailing list, I''m new to RSpec and I am trying to get it running with the caboo.se sample rails app. I installed the current version of rspec with rspec_on_rails I tried to run rake spec but received: 330-07:~/desktop/restful_auth_rspec/vendor multimedia$ rake spec (in /Users/multimedia/Desktop/restful_auth_rspec)
2007 Oct 11
2
Login testing ideas
I''ve been going through Pat''s example story and noticed that there was no checking for a bad login. I assume this is because that would have made the article bigger and more complicated than it needed to be. So the question that comes of of this is: How do folks normally handle the negative case? My plan was to just use another scenario, but as a new person to BDD/TDD,
2007 Nov 04
3
Returning the mock associated with an expectation.
I was reading through the FlexMock docs and noticed the expectation method .mock, which returns the original mock associated with an expectation. It looks really handy for writing nice all-in-one mocks like: mock_user = mock(''User'').expects(:first_name).returns(''Jonah'').mock So I started playing around with mocha and found I could actually already do this! But I''m not sure how. There''s no attr_reader on @mock, and I couldn''t find out where this m...
2010 Jul 03
0
rspec controller test strange error: undefined method `call' for nil:NilClass
...else flash[:error] = ''Error saving Channel.'' render :action => "new" end end end -------- modifying the scaffold spec like this produces strange def mock_channel(stubs={}) @mock_channel ||= mock_model(Channel, stubs) end def mock_user(stubs={}) @mock_user ||= mock_model(User, stubs) end before(:each) do @mock_user = mock_user controller.stub(:current_user).and_return @mock_user end describe "POST create" do describe "with valid params" do it "assigns a newly created cha...
2011 Jul 06
0
undefined method `assigns' and undefined method `post'
...error.. plz help error: undefined method `post'' for #<Spec::Example::ExampleGroup::Subclass_1:0xb7754114> undefined method `assigns'' for #<Spec::Example::ExampleGroup::Subclass_1:0xb785d1b4> Test file describe "GET Index" do def mock_product(stubs={}) @mock_user ||= mock_model(User, stubs).as_null_object end def setup @user = User.new end please give me some help .. thanks Yennie it "assigns all users as @users" do @user.stub(:all){[mock_user]} assigns(:users).should eq([mock_user]) end end -- You received this...
2008 Jan 02
2
Proxies
...r the corollary in FlexMock, check out #ordered > > http://onestepback.org/software/flexmock/classes/FlexMock/Expectation.html#M000082 > > > > Don''t take me too seriously, but I think mocha could trump flexmock''s > > with something like: > > > > mock_user = mock(''User'') do > > initially.expects(:first_name).returns(''Duncan'') > > then.expects(:last_name).returns(''Beevers'') > > > > later.expects(:birthday).returns(''a gentleman never asks'') > >...
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
2007 Apr 11
13
View Specs Fail with "protected method render"
...oller:0x3197dfc>" Here''s an example spec: require File.dirname(__FILE__) + ''/../../spec_helper'' context "/users/new.rhtml" do include UsersHelper setup do @errors = mock("errors") @errors.stub!(:count).and_return(0) @user = mock_user @user.stub!(:errors).and_return @errors assigns[:user] = @user end specify "should render new form" do render "/users/new.rhtml" response.should_have_tag ''form'', :attributes =>{:action => users_path, :method => ''post'...
2007 Sep 11
1
Can NOT overides the stub! in the setup
...p. User.stub!(:find).and_return(@current_user) session[:user] = @current_user.id end Where User is a model. Then I tried to overrides it within a spec in a rails CONTROLLER specs: it "descriptions...." do ... User.should_receive(:find).with("3").and_return(mock_user) get ''show'', :id => 3 end I found only ''3'', that is right, only single quotes can overrides the stub! in setup, the "3", double quotes won''t work. I am wondering if this is the way how it works? Thanks. --Bruce
2007 Nov 21
6
How thorough do you test?
Testing models is great and would not be able to create anything without it, but I am finding testing the controllers and views is a pain. Rest based controllers don''t seem to change that much when compared to the auto-generated code that obviously works. As for views I fail to see why testing it with a mock model does anything. Nothing is ensuring that when changes are made to the
2007 Sep 07
12
Preconditions
Sorry, lots of questions these days. Is there a normal approach for preconditions? In JUnit, I might put a few assertions in the setUp() just to make sure that the test ''data'' I''ve created meets expectations before going to test it. So, for instance, I''ve got an object that is audited using acts_as_audited and I''d like to test the XML that results
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) @vacancy.stub!(:location) @vacancy.stub!(:salary) @vacancy.stub!(:benefits)
2007 Sep 26
10
How do I best setup data for Story Runner?
Just started looking at the Story Runner integration, and am converting a few Rails integration tests to get a feel for it. My integration tests relied on fixtures, and since my models have a significant amount of validation (and hence need valid data unless I save without validation), this has made setup easy. With stories however, I''m wondering what the recommended approach is.
2008 Jan 23
18
Not seeing the failure
All, I''m missing something simple, I think. I am writing a spec to say that my CouponController should create a new coupon from the form parameters, then set the current user. Here''s the spec: describe CouponController, "When posting to save_coupon" do before(:each) do @expectedName = "pepper''s" @expectedAmount = 5 coupon =
2008 Mar 18
11
"Why not MockEverthing" or why use fixtures for all tests?
Hello fellow RSpec users. Before you all start warming up your flame throwers please let me explain my Subject line. I''ve been working over 4 months on a large Rails project with a few other developers. Test coverage was spotty at best, though they *were* RSpec tests. One of the other developers and I had started adding more tests, mostly controller tests using the methodology
2007 May 24
9
Mocking, changing method interfaces and integration tests
Suppose we have a method ''foo'' which internally uses another method ''bar''. Being good BDDers we mock out the ''bar'' method. After all, we only want to spec the ''foo'' method - actually running the ''bar'' method means slower, less maintainable and brittler specs. That''s why we <3 mocking,