search for: be_success

Displaying 20 results from an estimated 42 matches for "be_success".

2007 Nov 10
2
be_success misleading
Just wondering if anyone else thinks that ''response.should be_success'' is potentially misleading. If you''re writing a spec for an action that is failing in some way it can still have a status 200. So while the HTTP request was technically successful, something in the action was not. Perhaps something like ''response.should have_success_statu...
2014 Jun 09
0
How can I test my controller via rspec for something other than response.should be_success?
...describe Api::V1::PostsController do context 'Post' do before(:each) do @post = FactoryGirl.create(:post) end context '#index' do it "should have a successful response on get index" do get :index, format: :json response.should be_success end end EDIT: 2) How can I use "post :create" when my route is nested. For example... this works great as an rspec controller post :create with a top level resource, such as post it "should get a success response on post create" do post :create, param...
2007 Mar 28
3
respond.should be_successful
I''m wondering: Does it make more sense to add on successful? as an alias for success? in ActionController:TestRequest? I keep getting these two mixed up in my specs and was wondering if it would be helpful to anyone as a small patch to rspec. Best, Scott
2007 Nov 02
5
RSpec, RESTful nested routes and :path_prefix
...wiki/ pages", :project_id=>1, :page => {}} I get why it throws these errors but not how to fix it. The relavant RSpec: it "GET ''create'' should be successful" do post ''create'', :project_id => 1, :page => {} response.should be_success end How do I modify the get request properly? Thanks in advance!
2011 Jan 07
2
"No route matches" error?
...gt;"show", :controller=>"buildings"} What is necessary to make this pass? Here is the test by the way: describe "GET ''show''" do it "should be successful" do get ''show'' response.should be_success end end
2007 Nov 01
2
Writing controller specs
...ent = mock_model(Comment) end it ''should be successful when proper input has been given'' do Comment.should_receive(:new).with(@data).once.and_return(@comment) @comment.should_receive(:save).and_return(true) post :create, {:comment => @data} response.should be_success end end So far so good, although checking the response doesn''t feel exactly right. Then again, the two expectations already cover the example, so checking the response could just as well be left out. Now, on to adding the recording of the IP address: it ''should record the...
2007 Nov 21
7
describe AddressesController, "handling GET /addresses" do
...mock_model(Company) @addresses = mock("addresses") @company.stub!(:addresses).and_return(@addresses) Company.stub!(:find).and_return(@company) end def do_get get :index, :company_id => 1 end it "should be successful" do do_get response.should be_success end ............. All of my tests (4) fail: 4) NoMethodError in ''AddressesController handling GET /addresses should be successful'' You have a nil object when you didn''t expect it! The error occurred while evaluating nil.addresses Please, can someone explain why i...
2007 Jul 17
12
Getting past my login system
...I want to access a page under another controller (say a Students controller). In my students_controller_spec.rb, I want want to make sure http://test.host/students is successfully displayed, so I wrote something like: it "should be successful" do get :index response.should be_success end The problem is that is keeps redirecting to my login page at http://test.host/login. I tried then setting session[:user] and doing a post to my login page to simulate a login so that I could access the correct page, but that does not seem to work. I tried a number of things, including...
2008 Jan 23
2
integrate_views is not executing my views
...rails plugins, and run script/generate rspec_scaffold User name:string This is my users_controller spec: describe UsersController do fixtures :users integrate_views describe "handling GET /users" do it "should be successful" do get :index response.should be_success end end end I then added something wrong (on purpose) in index.html.erb (<% WRONG %>) so that when I visit /users I get a view error (undefined local variable or method....) But when I run the spec everything is ok and the test does NOT fail :-( I can even trash the index.html.erb fi...
2007 Sep 14
2
Testing a nested controller
...nse by response.should ... My routes.rb looks like this: map.resources :writers do |writers| writers.resources :notes end In my notes_controller_spec.rb def do_get writer_id = 1 note_id = 1 get note_path(writer_id, note_id) end it "should show a note" do do_get response.should be_success end But this always ends in an error message: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.rewrite Can anybody help here?? -- by(e) Andreas Wolff
2007 Sep 23
4
Story Runner, autoincrementing
..."/" do |path| post "/session/create", :login => "Jon", :password => "your_momma" response.should redirect_to("/") end And "user is looking at", "/forums/1" do |path| get path response.should be_success end When "creating a new topic titled", "Nicks Mom" do |title| post "/forums/1/topics/1/create", :topic => { :id => 1, :title => title, :body => "She is teh hotZ!" } end Then "user should be redirected to", "...
2007 Sep 14
2
Testing nested controller
...response.should ... My routes.rb looks like this: map.resources :writers do |writers| writers.resources :notes end In my notes_controller_spec.rb def do_get writer_id = 1 note_id = 1 get note_path(writer_id, note_id) end it "should show a note" do do_get response.should be_success end But this always ends in an error message: You have a nil object when you didn''t expect it! The error occurred while evaluating nil.rewrite Can anybody help here?? -- by(e) Andreas Wolff
2007 Dec 23
1
multiple scenarios problem
...;; end When "visiting", "working_page" do |page| get page, nil, :authorization => ActionController::HttpAuthentication::Basic.encode_credentials("name", "pass") end Then "I''m logged in" do response.should be_success end end What happens is that the second scenario''s response is also returning 401 and if I switch the order of the two scenarios, the second scenario (now the one that should return 401) returns 200. Each scenario works if I remove the other one. thanks for any help! Ivo Da...
2011 Feb 06
2
Controller Testing + Devise = boom (undefined @controller, request)
Here I am, trying to learn TDD and BDD. Getting start, most simple case, and the world is falling apart: My test code: it "should respond with success" do puts ''hi'' # get :new # response.should be_success end My stack trace: $ rspec spec "controller: nil" F Failures: 1) VideosController new exposes request and response before and after the action Failure/Error: Unable to find matching line from backtrace NoMethodError: undefined method `request'' for nil:...
2007 Oct 08
6
spec''in controllers request for nested routes
...s/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 do_get response.should be_success end it "should render index template" do do_get response.should render_template(''index'') end end 1) ActiveRecord::RecordNotFound in ''PlayersController handling GET /saltmines/games/1/players should be successful'' Couldn''t find...
2007 Nov 26
8
Renaming RailsExample to RailsExampleGroup
Fyi, I made the following renames: * RailsExample -> RailsExampleGroup * FunctionalExample -> FunctionalExampleGroup * ControllerExample -> ControllerExampleGroup * ViewExample -> ViewExampleGroup * HelperExample -> HelperExampleGroup * ModelExample -> ModelExampleGroup This was done to keep the naming consistent with ExampleGroup.
2008 Jun 12
1
map.resources :foo_items, :as => :foo confusing my controller specs
...tem but when I use the :as attribute in resources to make the URI path be ''/foo'' instead of ''/foo_items'' the default/generated controller specs for AdAssetsController become broken e.g. it "should be successful" do do_get response.should be_success end ''FooItemsController route generation should map { :controller => ''foo_items'', :action => ''index'' } to /foo_items'' FAILED expected: "/foo_items", got: "/foo (using ==) How can I make my controller spec honor the...
2012 Feb 18
0
Rails NameError : uninitialized constant RelationshipsController
...id => @followed } response.should be_redirect end.should change(Relationship, :count).by(1) end it "should create a relationship using Ajax" do lamda do xhr :post, :create, :relationship => { :followed_id => @followed } response.should be_success end.should change(Relationship, :count).by(1) end end describe "DELETE ''destroy''" do before(:each) do @user = test_sign_in(Factory(:user)) @followed = Factory(:user, :email => Factory.next(:email)) @user.follow!(@followed) @...
2007 May 19
2
have_text matcher does not support should_not.
Hello Guys, Doing conversion of some test for some controllers, still with integrated views. Anyway, I have this: it "should not see Join This Group button on profile page as member" do get "show", :id => @group.id response.should be_success response.should_not have_text(/Join This Group/) end But running with spec (0.9.4), drop me the folling error: Matcher does not support should_not. See Spec::Matchers for more information about matchers. Which is contradictory, since RDoc state otherwise: http://rspec.rubyforge.org/rdoc-r...
2008 Jun 07
3
Match render :nothing
Hello guys, Is there any way to match a render :nothing? I coudn''t find any way to do this so i''ve just changed my controllers to do a "head :ok", but it would be nice to know if there is any other way :) -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208