[rspec-users] assert_select - to do negative tests - need help with syntax please :)

2011-10-11 Thread Gordon
27;, expecting keyword_end (SyntaxError) ...:name => "brand[created_by]", , false It looks as if any attempts I make to denote that I have no 'values' to give to it is not working. Can someone please tell me what the right syntax is for saying, "i expect not to see the brand[created_by]" input attribute at all in the rendered form for adding new entries? Thank you :) Gordon ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] Scope problems for before hooks using helper methods?

2011-10-13 Thread Gordon
Hi, there, I believe I have some problem with scoping. I have a controller spec file which tests a brands resource. At the start of the file, I test the resource's access for different users in a context block a) not signed in b) non-admin user signed in- I call my own helper method, login

Re: [rspec-users] assert_select - to do negative tests - need help with syntax please :)

2011-10-13 Thread Gordon
> > I don't know if you can. Maybe somebody on the Rails list knows. If it can't, it means that people can't use assert_select to expect NOT to find a given element with extra attributes (such as :name) being defined. If that's the case, i think assert_select was either poorly written OR not com

[rspec-users] How do we include support helpers in request specs?

2011-10-13 Thread Gordon
Hi, all :) I have some working support helpers defined in spec/support/ controller_macros.rb. I'm running "rake spec" before a 'git commit' and observed that the spec request for my 'brands' controller, spec/requests/brands_spec.rb fails because a support helper method I defined in spec/support/

[rspec-users] Helper methods can't be called within before hooks. Help, please.

2011-10-13 Thread Gordon
Hi, there, I believe I have some problem with scoping. I have a controller spec file which tests a brands resource. At the start of the file, I test the resource's access for different users in a context block a) not signed in b) non-admin user signed in- I call my own helper method, login_

Re: [rspec-users] Scope problems for before hooks using helper methods?

2011-10-14 Thread Gordon
> Let's see the helper method please. ---spec/support/controller_macros.rb: start -- module ControllerMacros include Devise::TestHelpers # sets up an instance of a non-admin user def login_user before(:each) do @request.env["devise.mapping"] = Devise.mappin

[rspec-users] View spec for 'new' keeps failing despite generated html has expected attribute

2011-10-18 Thread Gordon
Hi guys, I have created a new resource, brands and here's the spec for 'new' which is failing. I do not know what's going on despite checking it out for a few times already -- app/views/brands/new.html.erb - start - New brand <%= render 'form' %> <%= link_to 'Back', brands_p

Re: [rspec-users] View spec for 'new' keeps failing despite generated html has expected attribute

2011-10-19 Thread Gordon
Fixed the issue as soon as I walked off my desk. Thought it was because of the resource object, @brand in spec/views/ parts/new.html.erb_spec.rb not being stubbed properly. Checked and I was right :) So, before(:each) do @brand = assign( :brand, stub_model( Brand,

[rspec-users] upgraded to rails 3.1.0 and found that string value of id has to be used instead of the integer value.

2011-10-25 Thread Gordon
My advance apologies if the title/subject is not too descriptive. Pre: I have just upgraded from rails 3.0.9 to rails 3.1.0 Before the upgrade, running 'rake spec' sees all my specs pass. After the upgrade, I seem to encounter some errors: -- Error extracts start ---

[rspec-users] What does :count actually mean in assert_select?

2011-11-18 Thread Gordon
Hi guys, I tried reading up the RSPEC Book (Dec 2010) and googled a bit but I could not find anything. I'm using Rspec2. Example: spec/factories/categories.rb == FactoryGirl.define do factory :category_intakes, :class => 'category' do name'intakes and filter

[rspec-users] Understanding of extend/include

2011-12-04 Thread Gordon
hi, there I have been looking at https://www.relishapp.com/rspec/rspec-core/docs/helper-methods/define-helper-methods-in-a-module. This is the documentation for usage of extend and include. In the section, "Scenario: extend a module in only some example groups", I refer to the setup in RSpec.c

[rspec-users] How to extend common helper methods to view specs?

2011-12-05 Thread Gordon
ner.start end config.after(:each) do DatabaseCleaner.clean end end -- spec/spec_helper.rb end -- i am already extending it to the view (ie. 'config.extend ControllerMacros, :type => :controller'). What am I missing? Thank you Gordon __

[rspec-users] recommendations for writing view index spec for a resource which behaves differently for different users

2011-12-12 Thread Gordon
hi guys, In my index view specs for a given resource, I have successfully written it for admin users. For the given resource, when admin users are looking at the index page, they should see -a link to add a new resource object -links to delete/edit/show for each resource object created My index

[rspec-users] what does 'these' mean in a PUT controller spec?

2012-01-16 Thread Gordon
hi, all, the spec above is found in my controller spec for a 'category' resource. It's a generated spec. - start extract describe "PUT update" do describe "with valid params" do it "updates the requested category" do catego

[rspec-users] Nested resource view spec seems to be referring to a non-existent route

2012-01-23 Thread Gordon
gories/:id(.:format) {:action=>"destroy", :controller=>"categories"} root / --- routes end --- The form partial has been properly fitted with the parent resource and the nested resource (ie. "form_for [@category, @sub_category]" ). It seems that it's calling a route, sub_category_path which I have never specified. The error comes up when an edit/create form is to be created where a form partial is called. I am really puzzled on why this is happening and have consulted the search results I had via google for 'nested resources with rspec' , 'Rails in Action 3' by Yehuda Katz, and the Rspec book :( If anyone knows what I am missing, I would love to hear your thoughts. thank you :) Gordon ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

[rspec-users] 'new' method works as expected but rspec does not recognise flash contents or redirection

2012-03-26 Thread Gordon
hi all :) Found a spec failing today. Not sure why. When I run my application and successfully added a new object, i can see 1) a redirection has taken place to the index page as expected (302 code returned) from the console 2) the flash notice's message being displayed in the index page BUT w

Re: [rspec-users] A bit confused with the use of assign() to test views

2011-08-03 Thread Gordon Yeong
Hello David Thanks for that. Doesn't assign have 2 arguments with the first being the variable to be assigned to and the second being the contents? On Aug 3, 2011 7:01 PM, "ct9a" wrote: > also, i have just read a little more in the rspec book. > > here's an extract: > > - extract star

Re: [rspec-users] Route is valid but not found :(

2011-08-23 Thread Gordon Yeong
e' => 'Brake pads'} flash[:notice].should eq('Part was successfully updated.') end end Spec extract ends - Thank you for your help, Justin! Gordon Yeong :) ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] Route is valid but not found :(

2011-08-23 Thread Gordon Yeong
> > > Do you have a before filter somewhere that is preventing the > :update_attributes message from being received? > > I have checked my application's controllers (app/controllers/application_controller.rb and app/controllers/parts_controller.rb) and controller spec (spec/controllers/parts_cont

Re: [rspec-users] assert_select - to do negative tests - need help with syntax please :)

2011-10-12 Thread Gordon Yeong
> > What _will_ work is this: > > assert_select "input#brand_created_by", false > > Hmmm. Sadly it does not work :( See below: extract start - Failure/Error: assert_select "input#brand_created_by", false, :name => "brand[created_by]" ArgumentErr

Re: [rspec-users] assert_select - to do negative tests - need help with syntax please :)

2011-10-13 Thread Gordon Yeong
> > > This ^^ does include :name => "". > > What happens when you just run > > assert_select "input#brand_created_by", false > > this runs successfully but how do I do it with the :name? :( I just want to be complete and explicit :) ___ rspec-users

Re: [rspec-users] Helper methods can't be called within before hooks. Help, please.

2011-10-14 Thread Gordon Yeong
It's just that I did not find my reply surface after 20 mins and was wondering if it was lost. Sorry about that, everyone :( my apologies. On 14 October 2011 16:01, Justin Ko wrote: > > On Oct 13, 2011, at 8:59 PM, Gordon wrote: > > > > > > > Hi, there, &

Re: [rspec-users] What does :count actually mean in assert_select?

2011-11-18 Thread Gordon Yeong
I think i answered my own question. :count refers to the number of fixture objects. The reason why :count => 2 was passing for views index specs is because 2 objects are being mocked and they are identical. Hence, there are 2 stock tests: 1) asserts that there are 2 elements which have the

Re: [rspec-users] 'new' method works as expected but rspec does not recognise flash contents or redirection

2012-03-26 Thread Gordon Yeong
c.rb" again and all tests are passing. Could it really be the stale Gemfile.lock file? hmmm On 26 March 2012 21:47, Gordon wrote: > hi all :) > > Found a spec failing today. > Not sure why. > > When I run my application and successfully added a new object, i can > see