Damian Jones
2008-Sep-12 13:56 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
This is my story: require File.expand_path(File.dirname(__FILE__) + "/helper") Story "Creating a Product", %{ As a User I want to create a product So that I can collect purchase options together under a specific product }, :type => RailsStory do Scenario "User with create product permissions" do Given "No products in the system" do Product.destroy_all end When "I Post to", "/products", :product => {:name => "Product 1", :description => "Product 1 description"} do |path, params| post_via_redirect path, params end Then "show template should be rendered" do response.should render_template("show") end And "the page should show", "Product 1" do |text| response.should have_text(/#{text}/) end And "the page should show", "Product 1 description" And "Confirm the product was successfully saved" end end and this is my create method(pretty standard) def create @product = Product.new params[:product] if @product.save redirect_to product_url(@product) else render :action => :new end end My specs confirm that ''show'' template is rendered after successful save but my story is failing here: Then "show template should be rendered" do response.should render_template("show") end saying expected ''show'' got nil. I am new to Ruby and am trying to start off in the right way, but this is driving me nuts, any one got any ideas? -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2008-Sep-12 14:04 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
On Fri, Sep 12, 2008 at 8:56 AM, Damian Jones <lists at ruby-forum.com> wrote:> This is my story: > > require File.expand_path(File.dirname(__FILE__) + "/helper") > > Story "Creating a Product", %{ > As a User > I want to create a product > So that I can collect purchase options together under a specific > product > > }, :type => RailsStory do > > Scenario "User with create product permissions" do > Given "No products in the system" do > Product.destroy_all > end > > When "I Post to", "/products", :product => > {:name => "Product > 1", :description => "Product 1 description"} do |path, params| > post_via_redirect path, params > end > > Then "show template should be rendered" do > response.should render_template("show") > end > > And "the page should show", "Product 1" do > |text| > response.should have_text(/#{text}/) > end > > And "the page should show", "Product 1 > description" > > And "Confirm the product was successfully saved" > end > end > > and this is my create method(pretty standard) > > def create > @product = Product.new params[:product] > if @product.save > redirect_to product_url(@product) > else > render :action => :new > end > end > > My specs confirm that ''show'' template is rendered after successful > save but my story is failing here: > > Then "show template should be rendered" do > response.should render_template("show") > end > > saying expected ''show'' got nil. > > I am new to Ruby and am trying to start off in the right way, but this > is driving me nuts, any one got any ideas?Stories don''t provide access to internals like which template was rendered. In this case, other steps are expecting text that''s on the resulting page. At a Story level, that''s really all you need. You just need to find the things on this particular page that will differentiate it from other pages. That make sense?
Damian Jones
2008-Sep-12 14:58 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
David Are you saying this part should work: And "the page should show", "Product 1" do |text| response.should have_text(/#{text}/) end because I''m getting nil for this step too. -- Posted via http://www.ruby-forum.com/.
Pat Maddox
2008-Sep-12 15:01 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
On Fri, Sep 12, 2008 at 10:58 AM, Damian Jones <lists at ruby-forum.com> wrote:> David > > Are you saying this part should work: > > And "the page should show", "Product 1" do |text| > response.should have_text(/#{text}/) > end > > because I''m getting nil for this step too.Is the request actually completing successfully? It seems like there might be an exception that''s preventing the page from rendering. Pat
David Chelimsky
2008-Sep-12 15:27 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
On Fri, Sep 12, 2008 at 10:01 AM, Pat Maddox <pergesu at gmail.com> wrote:> On Fri, Sep 12, 2008 at 10:58 AM, Damian Jones <lists at ruby-forum.com> wrote: >> David >> >> Are you saying this part should work: >> >> And "the page should show", "Product 1" do |text| >> response.should have_text(/#{text}/) >> end >> >> because I''m getting nil for this step too. > > Is the request actually completing successfully? It seems like there > might be an exception that''s preventing the page from rendering.That is what it sounds like. Also - once you get this working, there is a general style/approach issue that you may want to ponder - what you''ve got there will output something like this: Given No products in the system When I Post to Then show template should be rendered And the page should show And the page should show And Confirm the product was successfully saved Obviously, this isn''t that helpful as the arguments don''t get rendered. The approach you are taking has not really been recommended for a while and will not be supported in Cucumber, which is probably going to be replacing RSpec''s Story Runner. To make that transition easy for you, I''d recommend either moving to cucumber now, or at least taking the "decoupled step definitions" approach within Story Runner. Check out http://pastie.org/271244 (with the steps, story and output) and let me know if it makes sense to you. HTH, David
Damian Jones
2008-Sep-12 16:22 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
David Chelimsky wrote:> To make that transition easy for you, I''d recommend either moving to > cucumber now, or at least taking the "decoupled step definitions" > approach within Story Runner. Check out http://pastie.org/271244 (with > the steps, story and output) and let me know if it makes sense to you. > > HTH, > DavidThanks for that, unfortunately I am having problems installing the Cucumber gem ERROR: While executing gem ... (Errno::ENOENT) No such file or directory - c:/ruby/lib/ruby/gems/1.8/gems/aslakhellesoy-cuc umber-0.1.5/bin/cucumber -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2008-Sep-12 16:37 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
On Fri, Sep 12, 2008 at 11:22 AM, Damian Jones <lists at ruby-forum.com> wrote:> David Chelimsky wrote: > >> To make that transition easy for you, I''d recommend either moving to >> cucumber now, or at least taking the "decoupled step definitions" >> approach within Story Runner. Check out http://pastie.org/271244 (with >> the steps, story and output) and let me know if it makes sense to you. >> >> HTH, >> David > > Thanks for that, unfortunately I am having problems installing the > Cucumber gem > > ERROR: While executing gem ... (Errno::ENOENT) > No such file or directory - > c:/ruby/lib/ruby/gems/1.8/gems/aslakhellesoy-cuc > umber-0.1.5/bin/cucumberYou don''t need the gem to use cucumber with Rails: script/plugin install git://github.com/aslakhellesoy/cucumber.git script/generate cucumber rake features If you still want the gem anyway, try doing it manually: git clone git://github.com/aslakhellesoy/cucumber.git cd cucumber rake gem rake install_gem Cheers, David> > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Damian Jones
2008-Sep-12 16:39 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
Phew, Thanks all for the input. Just need an outside eye to help me find a stupid mistake. I am using JEdit (on a windows box, unfortunately can''t afford a Mac at the moment!) I had renamed Views/Product to Views/Products in JEdit but didn''t realise it doesn''t update the actual file system. I switched the debugger on and found the exception saying couldn''t find the view in the specified path, check my file system and found the problem. It passes now. Just need to try to get cucumber installed. -- Posted via http://www.ruby-forum.com/.
David Chelimsky
2008-Sep-12 16:40 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
On Fri, Sep 12, 2008 at 11:37 AM, David Chelimsky <dchelimsky at gmail.com> wrote:> On Fri, Sep 12, 2008 at 11:22 AM, Damian Jones <lists at ruby-forum.com> wrote: >> David Chelimsky wrote: >> >>> To make that transition easy for you, I''d recommend either moving to >>> cucumber now, or at least taking the "decoupled step definitions" >>> approach within Story Runner. Check out http://pastie.org/271244 (with >>> the steps, story and output) and let me know if it makes sense to you. >>> >>> HTH, >>> David >> >> Thanks for that, unfortunately I am having problems installing the >> Cucumber gem >> >> ERROR: While executing gem ... (Errno::ENOENT) >> No such file or directory - >> c:/ruby/lib/ruby/gems/1.8/gems/aslakhellesoy-cuc >> umber-0.1.5/bin/cucumber > > You don''t need the gem to use cucumber with Rails: > > script/plugin install git://github.com/aslakhellesoy/cucumber.git > script/generate cucumber > rake features > > If you still want the gem anyway, try doing it manually: > > git clone git://github.com/aslakhellesoy/cucumber.git > cd cucumber > rake gem > rake install_gemFYI - I added a cheat for that: cheat install_cucumber_gem (If you don''t have cheat installed, then "gem install cheat")> > Cheers, > David > >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> >
Damian Jones
2008-Sep-12 18:41 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
When ever I try to install a plugin from a git repository I just get: removing: ../vendor/plugins/cucumber/.git is this because I am on windows, or is there something I need to do? -- Posted via http://www.ruby-forum.com/.
Damian Jones
2008-Sep-13 18:16 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
David Chelimsky wrote:> On Fri, Sep 12, 2008 at 11:37 AM, David Chelimsky <dchelimsky at gmail.com> > wrote: >>> >> script/plugin install git://github.com/aslakhellesoy/cucumber.git >> script/generate cucumber >> rake features >> >> If you still want the gem anyway, try doing it manually: >> >> git clone git://github.com/aslakhellesoy/cucumber.git >> cd cucumber >> rake gem >> rake install_gem > > FYI - I added a cheat for that: > > cheat install_cucumber_gem > > (If you don''t have cheat installed, then "gem install cheat")I have managed to get Cucumber installed along with all the dependancies (I think) but am now getting the error RuntimeError: Could not find [Webrat::TextField, Webrat::TextareaField, Webr at::PasswordField]: :name In my "new" view the HTML produced includes this: <input id="product_name" name="product[name]" size="30" type="text" /> which I beleive is what should be there. Do you think this is a problem with my setup? -- Posted via http://www.ruby-forum.com/.
Damian Jones
2008-Sep-13 18:24 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
Ok I got my story to pass by changing the follwing snippet When /I create a product named (.*) described with (.*)/ do |name, description| visits new_product_path fills_in "product[name]", :with => name fills_in "product[description]", :with => description clicks_button "Create" end don''t know why it doesn''t work with this: fills_in :name, :with => name Webrat api specs say it should -- Posted via http://www.ruby-forum.com/.
Damian Jones
2008-Sep-13 19:51 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
David, are you suggesting I should use the method you posted on Pastie, using stories or should I use Features as suggested on the Cucumber site? -- Posted via http://www.ruby-forum.com/.
Zach Dennis
2008-Sep-16 22:43 UTC
[rspec-users] RSpec story failing because create is not rendering ''show''
On Sat, Sep 13, 2008 at 2:24 PM, Damian Jones <lists at ruby-forum.com> wrote:> Ok I got my story to pass by changing the follwing snippet > > When /I create a product named (.*) described with (.*)/ do |name, > description| > visits new_product_path > fills_in "product[name]", :with => name > fills_in "product[description]", :with => description > clicks_button "Create" > end > > don''t know why it doesn''t work with this: > > fills_in :name, :with => name > > Webrat api specs say it shouldNo it doesn''t. It says that the first argument is considered as an HTML id, name or label. The id is product_name. The name is product[name] and I can''t tell from what you posted if you have a label "name". http://github.com/brynary/webrat/tree/master/lib/webrat/core/scope.rb Zach -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com