From lists at ruby-forum.com Mon Sep 1 05:43:44 2008 From: lists at ruby-forum.com (Joseph Wilk) Date: Mon, 1 Sep 2008 11:43:44 +0200 Subject: [rspec-users] story vs feature (was Documentation for Plain-Text Stories) In-Reply-To: <30B96A63-7091-4083-B502-ED7BF24E7E43@mattwynne.net> References: <427DBD9F-48C7-4356-85B9-95C4D62167B7@mattwynne.net> <8d961d900808180257oc464fc5v1aa03a5450457576@mail.gmail.com> <48A9D18D.3070704@e4net.com> <8d961d900808181501n413e48a3qfe76c0d834d0d98a@mail.gmail.com> <48AA4BFD.6010401@e4net.com> <23AA4548-4AAC-4C42-AE53-9AB771D3BFF6@gmail.com> <48ABA5F9.1070801@e4net.com> <82ED9EC8-28B6-42FF-A548-6303D8DE135D@gmail.com> <6EC03468-7552-4CB4-8307-103AF4266C42@parkerhill.com> <57c63afe0808200720r17b9963fm55b98ccee0c7bd3f@mail.gmail.com> <1341C3E7-DB99-4F7D-8576-60F2107B3C7F@parkerhill.com> <57c63afe0808240931v440c5e9ekd6ad9d4f36f7240f@mail.gmail.com> <20080830181203.GQ3867@uivelo.tilus.net> <3C05E277-985C-4C63-AE49-4342CD703E47@railsnewbie.com> <30B96A63-7091-4083-B502-ED7BF24E7E43@mattwynne.net> Message-ID: I find pronouncing the R with a piratey 'arrrrr spec' helps avoid any arse or peck embarrassment. I'm still struggling with how to pronounce rspec in Japanese. The best I've managed is 'l spec' All these darn r's :) -- Joseph Wilk http://www.joesniff.co.uk Matt Wynne wrote: > On 30 Aug 2008, at 19:31, Scott Taylor wrote: > >> >> Scott > > :) > > One of the main adoption barriers we had with rspec at the BBC was > the uniquely British problem of 'rspec' sounding, to the uninitiated, > rather too much like 'arse peck'. -- Posted via http://www.ruby-forum.com/. From matt at mattwynne.net Mon Sep 1 13:08:10 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 1 Sep 2008 18:08:10 +0100 Subject: [rspec-users] Cucumber: Running a single feature / scenario Message-ID: <9AA10895-5708-4DBD-A807-AA7F81ED2BE8@mattwynne.net> Am taking cucumber for a first spin today - first impressions are good. How do I go about running a single feature or scenario so I don't have to run the whole lot when I'm working on a particular one? cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. -------------- next part -------------- An HTML attachment was scrubbed... URL: From matt at mattwynne.net Mon Sep 1 13:12:59 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 1 Sep 2008 18:12:59 +0100 Subject: [rspec-users] Cucumber: GivenScenario doesn't seem to work Message-ID: <9BAE9E84-1144-4A40-8832-DC6E5AB89F08@mattwynne.net> I'm hardly a story-runner expert, so I may be making a dumb mistake here... I'm trying to get one scenario to run another as part of its Given clause. It looks like this: Scenario: Admin user merges two venues GivenScenario Admin user views two venues When I go to "/admin/venues" Then I should see "Venue1" Obviously the When / Then bits will get more complicated once I get this working. In another .feature file, I have the following scenario (which passes) Scenario: Admin user views two venues Given the default city exists ... The scenario "Admin user merges two venues" fails with this ugly backtrace: /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/ lib/cucumber/tree/scenario.rb:45:in `given_scenario_steps': You have a nil object when you didn't expect it! (NoMethodError) The error occurred while evaluating nil.steps from /Users/matt/ Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/ cucumber/tree/given_scenario.rb:9:in `steps' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/tree/scenario.rb:41:in `steps' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/tree/scenario.rb:41:in `map' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/tree/scenario.rb:41:in `steps' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/tree/scenario.rb:9:in `accept' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/executor.rb:62:in `visit_scenario' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/executor.rb:53:in `visit_regular_scenario' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/tree/feature.rb:47:in `accept' ... 6 levels... from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/executor.rb:36:in `visit_features' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/cli.rb:84:in `execute!' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/lib/cucumber/cli.rb:11:in `execute' from /Users/matt/Documents/projects/songkick/skweb/vendor/ plugins/cucumber/bin/cucumber:3 rake aborted! Command failed with status (1): [/usr/local/bin/ruby -I "/Users/matt/ Docume...] What am I doing wrong? cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at deadorange.com Mon Sep 1 13:24:28 2008 From: nick at deadorange.com (Nick Hoffman) Date: Mon, 1 Sep 2008 13:24:28 -0400 Subject: [rspec-users] Application-wide spec_helper method In-Reply-To: <3c30da400808300935l4cfcee95o90de951bcbc3c22a@mail.gmail.com> References: <9C60741D-BEE4-4A9B-9DFA-F32BF134759D@deadorange.com> <57c63afe0808280502g6fc2ccf0r57d939167ad0ccb6@mail.gmail.com> <3B4561D4-9743-49EC-8103-43FF40B69F2E@deadorange.com> <85d99afe0808281027o78627c3aj6610a6eeab48cffd@mail.gmail.com> <4E011A29-B8F4-4B5B-AB40-B2E0A59746D5@deadorange.com> <85d99afe0808300833lfc12d8dle101408fb983df55@mail.gmail.com> <3c30da400808300935l4cfcee95o90de951bcbc3c22a@mail.gmail.com> Message-ID: On 2008-08-30, at 12:35, Mark Wilden wrote: > On Sat, Aug 30, 2008 at 8:33 AM, Zach Dennis > wrote: > On Fri, Aug 29, 2008 at 11:05 PM, Scott Taylor > > This isn't ruby - if you want ruby to include it, you'll need a > require > > statement (or a load, or autoload). > > I think Scott means to say "this isn't rspec, you need to tell ruby to > load the file using require". > > I think Zach means to say "this isn't Rails." :) > > ///ark Thanks guys. My bad for not realising that this had to do with Rails rather than RSpec! -Nick From jonathan at parkerhill.com Mon Sep 1 13:28:21 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Mon, 1 Sep 2008 13:28:21 -0400 Subject: [rspec-users] opening a response in browser (webrat) Message-ID: Given I am running an rspec story And it uses webrat And I am using rdebug When I am at a breakpoint (eg after a 'visits' in a step) Then how can I open the current response in a browser to see what the page actually looks like at that point? From zach.dennis at gmail.com Mon Sep 1 14:32:20 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Mon, 1 Sep 2008 14:32:20 -0400 Subject: [rspec-users] opening a response in browser (webrat) In-Reply-To: References: Message-ID: <85d99afe0809011132t5db102aak9cfbec04630fe67a@mail.gmail.com> In the past I've done this... File.open(RAILS_ROOT + "/public/duh.html", "w"){ |f| f.puts response.body } And then in terminal I go to my project root and type "open public/duh.html". Although you may be able to get away with doing this in your debugging session: system "open #{RAILS_ROOT}/public/duh.html" HTH, Zach On Mon, Sep 1, 2008 at 1:28 PM, Jonathan Linowes wrote: > Given I am running an rspec story > And it uses webrat > And I am using rdebug > > When I am at a breakpoint (eg after a 'visits' in a step) > > Then how can I open the current response in a browser to see what the page > actually looks like at that point? > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From priit at mx.ee Mon Sep 1 15:25:00 2008 From: priit at mx.ee (Priit Tamboom) Date: Mon, 1 Sep 2008 22:25:00 +0300 Subject: [rspec-users] cucumber and openid Message-ID: Hi! I'm new to Cucumber/Story Runner, but not so new to Rspec in general. I googled a lot before posting :-) I would like to mock openid consumer however I'm running out of ideas how to access session. I know I should avoid mocking in integration testing, but in this case it makes sense. Perhaps I can somehow mock session[:current_user_id] like it is possible in rspec. Given /I am logged in as admin/ do user = User.find(:first) session.stub!(:current_user_id).and_return(user.id) end Any hints how it can solve my mocking in Cucumber would be welcome! Cheers, Priit From dchelimsky at gmail.com Mon Sep 1 15:45:56 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 1 Sep 2008 14:45:56 -0500 Subject: [rspec-users] Cucumber: Running a single feature / scenario In-Reply-To: <9AA10895-5708-4DBD-A807-AA7F81ED2BE8@mattwynne.net> References: <9AA10895-5708-4DBD-A807-AA7F81ED2BE8@mattwynne.net> Message-ID: <57c63afe0809011245o3ef36a69hd8a7aa7ad0fc01ee@mail.gmail.com> On Mon, Sep 1, 2008 at 12:08 PM, Matt Wynne wrote: > Am taking cucumber for a first spin today - first impressions are good. > How do I go about running a single feature or scenario so I don't have to > run the whole lot when I'm working on a particular one? There's no support for this yet in Story Runner or Cucumber. Feel free to add a feature request at http://rspec.lighthouseapp.com/projects/16211. From aslak.hellesoy at gmail.com Mon Sep 1 16:30:34 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 1 Sep 2008 22:30:34 +0200 Subject: [rspec-users] Cucumber: Running a single feature / scenario In-Reply-To: <57c63afe0809011245o3ef36a69hd8a7aa7ad0fc01ee@mail.gmail.com> References: <9AA10895-5708-4DBD-A807-AA7F81ED2BE8@mattwynne.net> <57c63afe0809011245o3ef36a69hd8a7aa7ad0fc01ee@mail.gmail.com> Message-ID: <8d961d900809011330y1bcc1178qac683e6e08b22c6a@mail.gmail.com> On Mon, Sep 1, 2008 at 9:45 PM, David Chelimsky wrote: > On Mon, Sep 1, 2008 at 12:08 PM, Matt Wynne wrote: >> Am taking cucumber for a first spin today - first impressions are good. >> How do I go about running a single feature or scenario so I don't have to >> run the whole lot when I'm working on a particular one? > > There's no support for this yet in Story Runner or Cucumber. Feel free Yes there is. It's been in Cucumber for at least a month. > to add a feature request at > http://rspec.lighthouseapp.com/projects/16211. cucumber --help Example: cucumber path/to/file.feature --line 33 Or with Rake: rake features FEATURE=path/to/file.feature CUCUMBER_OPTS="--line 33" It's not documented on the Wiki yet. Pass the line number of one of the steps. I think it's broken when GivenScenario is involved. Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon Sep 1 16:31:37 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 1 Sep 2008 22:31:37 +0200 Subject: [rspec-users] cucumber and openid In-Reply-To: References: Message-ID: <8d961d900809011331y560de168lfbc5433b57fff8b4@mail.gmail.com> On Mon, Sep 1, 2008 at 9:25 PM, Priit Tamboom wrote: > Hi! > > I'm new to Cucumber/Story Runner, but not so new to Rspec in general. > I googled a lot before > posting :-) > > I would like to mock openid consumer however I'm running out of ideas > how to access session. > I know I should avoid mocking in integration testing, but in this case > it makes sense. > Perhaps I can somehow mock session[:current_user_id] like it is > possible in rspec. > > Given /I am logged in as admin/ do > user = User.find(:first) > session.stub!(:current_user_id).and_return(user.id) > end > > Any hints how it can solve my mocking in Cucumber would be welcome! > Mocking in Cucumber works just like in RSpec. Are you getting any errors? Aslak > Cheers, > Priit > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Sep 1 16:31:50 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 1 Sep 2008 15:31:50 -0500 Subject: [rspec-users] Cucumber: Running a single feature / scenario In-Reply-To: <8d961d900809011330y1bcc1178qac683e6e08b22c6a@mail.gmail.com> References: <9AA10895-5708-4DBD-A807-AA7F81ED2BE8@mattwynne.net> <57c63afe0809011245o3ef36a69hd8a7aa7ad0fc01ee@mail.gmail.com> <8d961d900809011330y1bcc1178qac683e6e08b22c6a@mail.gmail.com> Message-ID: <57c63afe0809011331n7a6d99d2tc0bb4eb2d426c4fe@mail.gmail.com> On Mon, Sep 1, 2008 at 3:30 PM, aslak hellesoy wrote: > On Mon, Sep 1, 2008 at 9:45 PM, David Chelimsky wrote: >> On Mon, Sep 1, 2008 at 12:08 PM, Matt Wynne wrote: >>> Am taking cucumber for a first spin today - first impressions are good. >>> How do I go about running a single feature or scenario so I don't have to >>> run the whole lot when I'm working on a particular one? >> >> There's no support for this yet in Story Runner or Cucumber. Feel free > > Yes there is. It's been in Cucumber for at least a month. Sorry man - didn't realize. >> to add a feature request at >> http://rspec.lighthouseapp.com/projects/16211. > > cucumber --help > > Example: > > cucumber path/to/file.feature --line 33 > > Or with Rake: > > rake features FEATURE=path/to/file.feature CUCUMBER_OPTS="--line 33" > > It's not documented on the Wiki yet. Pass the line number of one of > the steps. I think it's broken when GivenScenario is involved. > > Aslak > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aslak.hellesoy at gmail.com Mon Sep 1 16:34:11 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Mon, 1 Sep 2008 22:34:11 +0200 Subject: [rspec-users] Cucumber: GivenScenario doesn't seem to work In-Reply-To: <9BAE9E84-1144-4A40-8832-DC6E5AB89F08@mattwynne.net> References: <9BAE9E84-1144-4A40-8832-DC6E5AB89F08@mattwynne.net> Message-ID: <8d961d900809011334l3d24bb78g8e7d45239b20f5d4@mail.gmail.com> On Mon, Sep 1, 2008 at 7:12 PM, Matt Wynne wrote: > I'm hardly a story-runner expert, so I may be making a dumb mistake here... > I'm trying to get one scenario to run another as part of its Given clause. > It looks like this: > Scenario: Admin user merges two venues > GivenScenario Admin user views two venues > When I go to "/admin/venues" > Then I should see "Venue1" > Obviously the When / Then bits will get more complicated once I get this > working. > In another .feature file, I have the following scenario (which passes) > Scenario: Admin user views two venues > Given the default city exists > ... > > The scenario "Admin user merges two venues" fails with this ugly backtrace: > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/tree/scenario.rb:45:in > `given_scenario_steps': You have a nil object when you didn't expect it! > (NoMethodError) > The error occurred while evaluating nil.steps from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/tree/given_scenario.rb:9:in > `steps' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/tree/scenario.rb:41:in > `steps' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/tree/scenario.rb:41:in > `map' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/tree/scenario.rb:41:in > `steps' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/tree/scenario.rb:9:in > `accept' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/executor.rb:62:in > `visit_scenario' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/executor.rb:53:in > `visit_regular_scenario' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/tree/feature.rb:47:in > `accept' > ... 6 levels... > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/executor.rb:36:in > `visit_features' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/cli.rb:84:in > `execute!' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/lib/cucumber/cli.rb:11:in > `execute' > from > /Users/matt/Documents/projects/songkick/skweb/vendor/plugins/cucumber/bin/cucumber:3 > rake aborted! > Command failed with status (1): [/usr/local/bin/ruby -I > "/Users/matt/Docume...] > > What am I doing wrong? > GivenScenario only works when you're pointing to a scenario in the same feature/same feature file. Please add a feature request if you want it to work differently. http://rspec.lighthouseapp.com/projects/16211-cucumber/overview Aslak > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > In case you wondered: The opinions expressed in this email are my own and do > not necessarily reflect the views of any former, current or future employers > of mine. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Mon Sep 1 17:31:08 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 1 Sep 2008 16:31:08 -0500 Subject: [rspec-users] cucumber and openid In-Reply-To: <8d961d900809011331y560de168lfbc5433b57fff8b4@mail.gmail.com> References: <8d961d900809011331y560de168lfbc5433b57fff8b4@mail.gmail.com> Message-ID: <57c63afe0809011431i1e7badeen17e1e944fa88621f@mail.gmail.com> On Mon, Sep 1, 2008 at 3:31 PM, aslak hellesoy wrote: > On Mon, Sep 1, 2008 at 9:25 PM, Priit Tamboom wrote: >> Hi! >> >> I'm new to Cucumber/Story Runner, but not so new to Rspec in general. >> I googled a lot before >> posting :-) >> >> I would like to mock openid consumer however I'm running out of ideas >> how to access session. >> I know I should avoid mocking in integration testing, but in this case >> it makes sense. >> Perhaps I can somehow mock session[:current_user_id] like it is >> possible in rspec. >> >> Given /I am logged in as admin/ do >> user = User.find(:first) >> session.stub!(:current_user_id).and_return(user.id) >> end >> >> Any hints how it can solve my mocking in Cucumber would be welcome! >> > > Mocking in Cucumber works just like in RSpec. Are you getting any errors? The session that RailsStory (in 'spec/story') and in cucumber exposes is an ActionController::Integration::Session, not the Hash you get from ActionController::Base.session (as is the case in ControllerExampleGroup or rails functional tests). So you're not setting mock expectations on the object you think you are. I haven't worked with open ID, nor do I know what approach your app uses to communicate with open ID, but if you wrap that access in a method, then you can just override that method in your steps file (or any other .rb file as long as you require it) and have it set up state the way you want it. Make sense? > > Aslak > >> Cheers, >> Priit >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Mon Sep 1 18:32:57 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 1 Sep 2008 23:32:57 +0100 Subject: [rspec-users] Cucumber: GivenScenario doesn't seem to work In-Reply-To: <8d961d900809011334l3d24bb78g8e7d45239b20f5d4@mail.gmail.com> References: <9BAE9E84-1144-4A40-8832-DC6E5AB89F08@mattwynne.net> <8d961d900809011334l3d24bb78g8e7d45239b20f5d4@mail.gmail.com> Message-ID: <7D803DAC-72CA-4786-A28B-F4068B1AC8FA@mattwynne.net> On 1 Sep 2008, at 21:34, aslak hellesoy wrote: > On Mon, Sep 1, 2008 at 7:12 PM, Matt Wynne wrote: >> I'm hardly a story-runner expert, so I may be making a dumb >> mistake here... >> >> The scenario "Admin user merges two venues" fails with this ugly >> backtrace: >> rake aborted! >> Command failed with status (1): [/usr/local/bin/ruby -I >> "/Users/matt/Docume...] >> >> What am I doing wrong? >> > > GivenScenario only works when you're pointing to a scenario in the > same feature/same feature file. > > Please add a feature request if you want it to work differently. > http://rspec.lighthouseapp.com/projects/16211-cucumber/overview It is done: http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/3- create-givenscenario-dependency-accross-feature-files From matt at mattwynne.net Mon Sep 1 18:58:37 2008 From: matt at mattwynne.net (Matt Wynne) Date: Mon, 1 Sep 2008 23:58:37 +0100 Subject: [rspec-users] Cucumber: Running a single feature / scenario In-Reply-To: <8d961d900809011330y1bcc1178qac683e6e08b22c6a@mail.gmail.com> References: <9AA10895-5708-4DBD-A807-AA7F81ED2BE8@mattwynne.net> <57c63afe0809011245o3ef36a69hd8a7aa7ad0fc01ee@mail.gmail.com> <8d961d900809011330y1bcc1178qac683e6e08b22c6a@mail.gmail.com> Message-ID: On 1 Sep 2008, at 21:30, aslak hellesoy wrote: > cucumber --help > > Example: > > cucumber path/to/file.feature --line 33 > > Or with Rake: > > rake features FEATURE=path/to/file.feature CUCUMBER_OPTS="--line 33" > > It's not documented on the Wiki yet. Pass the line number of one of > the steps. I think it's broken when GivenScenario is involved. > > Aslak Thanks Aslak. i've added a bit more detail to the github wiki to explain the line number thing. From tmhaines at gmail.com Mon Sep 1 19:22:08 2008 From: tmhaines at gmail.com (Tim Haines) Date: Tue, 2 Sep 2008 11:22:08 +1200 Subject: [rspec-users] specs pass when run with other app specs, but fail when run independently Message-ID: Hi there, I've noticed something a little odd with the session_controller specs that are generated from the rails plugin restful_authentication. When they're run with all the other app specs (i.e. when I first fire up autospec) the specs all pass. However, if I touch the session_controller_spec file so only the session_controller specs are run, some fail with the error message protected method `logged_in?' called for # Can anyone explain why this might be or where I should start digging to try and resolve this? Cheers, Tim. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jonathan at parkerhill.com Mon Sep 1 19:26:03 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Mon, 1 Sep 2008 19:26:03 -0400 Subject: [rspec-users] opening a response in browser (webrat) In-Reply-To: <85d99afe0809011132t5db102aak9cfbec04630fe67a@mail.gmail.com> References: <85d99afe0809011132t5db102aak9cfbec04630fe67a@mail.gmail.com> Message-ID: thanks perhaps a bit hackery, I've added this to my shared steps file: Given "(show me)" do show_me end When "(show me)" do show_me end Then "(show me)" do show_me end and to my helper.rb def show_me File.open(RAILS_ROOT + "/public/dbug.html", "w"){ |f| f.puts response.body } system "open http://localhost:3000/dbug.html" #debugger end so now anywhere in any story i can add (for debugging) And (show me) :) On Sep 1, 2008, at 2:32 PM, Zach Dennis wrote: > In the past I've done this... > > File.open(RAILS_ROOT + "/public/duh.html", "w"){ |f| f.puts > response.body } > > And then in terminal I go to my project root and type "open > public/duh.html". Although you may be able to get away with doing this > in your debugging session: > > system "open #{RAILS_ROOT}/public/duh.html" > > HTH, > > Zach > > On Mon, Sep 1, 2008 at 1:28 PM, Jonathan Linowes > wrote: >> Given I am running an rspec story >> And it uses webrat >> And I am using rdebug >> >> When I am at a breakpoint (eg after a 'visits' in a step) >> >> Then how can I open the current response in a browser to see what >> the page >> actually looks like at that point? >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > > -- > Zach Dennis > http://www.continuousthinking.com > http://www.mutuallyhuman.com > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From ben at benmabey.com Mon Sep 1 20:41:49 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 01 Sep 2008 18:41:49 -0600 Subject: [rspec-users] opening a response in browser (webrat) In-Reply-To: References: <85d99afe0809011132t5db102aak9cfbec04630fe67a@mail.gmail.com> Message-ID: <48BC8BCD.8070008@benmabey.com> Actually, webrat already has a method for this. It will even modify the CSS and image's paths to work correctly.. In your step simply type: save_and_open_page -Ben Jonathan Linowes wrote: > thanks > perhaps a bit hackery, I've added this to my shared steps file: > > Given "(show me)" do > show_me > end > When "(show me)" do > show_me > end > Then "(show me)" do > show_me > end > > and to my helper.rb > > def show_me > File.open(RAILS_ROOT + "/public/dbug.html", "w"){ |f| f.puts > response.body } > system "open http://localhost:3000/dbug.html" > #debugger > end > > so now anywhere in any story i can add (for debugging) > > And (show me) > > :) > > On Sep 1, 2008, at 2:32 PM, Zach Dennis wrote: > >> In the past I've done this... >> >> File.open(RAILS_ROOT + "/public/duh.html", "w"){ |f| f.puts >> response.body } >> >> And then in terminal I go to my project root and type "open >> public/duh.html". Although you may be able to get away with doing this >> in your debugging session: >> >> system "open #{RAILS_ROOT}/public/duh.html" >> >> HTH, >> >> Zach >> >> On Mon, Sep 1, 2008 at 1:28 PM, Jonathan Linowes >> wrote: >>> Given I am running an rspec story >>> And it uses webrat >>> And I am using rdebug >>> >>> When I am at a breakpoint (eg after a 'visits' in a step) >>> >>> Then how can I open the current response in a browser to see what >>> the page >>> actually looks like at that point? >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> >> >> -- >> Zach Dennis >> http://www.continuousthinking.com >> http://www.mutuallyhuman.com >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From dchelimsky at gmail.com Mon Sep 1 23:15:55 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Mon, 1 Sep 2008 22:15:55 -0500 Subject: [rspec-users] specs pass when run with other app specs, but fail when run independently In-Reply-To: References: Message-ID: <57c63afe0809012015p8e0374fmffc1bf123b6b774c@mail.gmail.com> On Mon, Sep 1, 2008 at 6:22 PM, Tim Haines wrote: > Hi there, > > I've noticed something a little odd with the session_controller specs that > are generated from the rails plugin restful_authentication. When they're > run with all the other app specs (i.e. when I first fire up autospec) the > specs all pass. However, if I touch the session_controller_spec file so > only the session_controller specs are run, some fail with the error message > protected method `logged_in?' called for # > > Can anyone explain why this might be or where I should start digging to try > and resolve this? logged_in? is protected in the module AuthenticatedSystem. Chances are that you've got a code example that's doing this: controller.logged_in? instead of this: controller.send(:logged_in?) and something that's not getting loaded when you run just sessions_controller_spec is including AuthenticatedSystem into the example group directly. > > Cheers, > > Tim. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tmhaines at gmail.com Tue Sep 2 00:17:01 2008 From: tmhaines at gmail.com (Tim Haines) Date: Tue, 2 Sep 2008 16:17:01 +1200 Subject: [rspec-users] specs pass when run with other app specs, but fail when run independently In-Reply-To: <57c63afe0809012015p8e0374fmffc1bf123b6b774c@mail.gmail.com> References: <57c63afe0809012015p8e0374fmffc1bf123b6b774c@mail.gmail.com> Message-ID: Hi David, You were spot on. The generated authenticated_system_spec included AuthenticatedSystem. If I include AuthenticatedSystem into the SessionsController spec, then the specs all pass. This is a problem with the standard specs that resful_authentication builds for you - so I'll looking at getting those fixed.. I'm kind of curios that the specs are testing these protected methods - I would have expected that's generally not a done thing as they're not a public part of the API? I guess there's 3 options as to how to patch: 1) include AuthenticatedSystem, or 2) change the specs to use .send, or 3) remove the specs that are calling protected methods. Do you have any guidance on the best path forward here? Cheers, Tim. On Tue, Sep 2, 2008 at 3:15 PM, David Chelimsky wrote: > On Mon, Sep 1, 2008 at 6:22 PM, Tim Haines wrote: > > Hi there, > > > > I've noticed something a little odd with the session_controller specs > that > > are generated from the rails plugin restful_authentication. When they're > > run with all the other app specs (i.e. when I first fire up autospec) the > > specs all pass. However, if I touch the session_controller_spec file so > > only the session_controller specs are run, some fail with the error > message > > protected method `logged_in?' called for # > > > > Can anyone explain why this might be or where I should start digging to > try > > and resolve this? > > logged_in? is protected in the module AuthenticatedSystem. Chances are > that you've got a code example that's doing this: > > controller.logged_in? > > instead of this: > > controller.send(:logged_in?) > > and something that's not getting loaded when you run just > sessions_controller_spec is including AuthenticatedSystem into the > example group directly. > > > > > Cheers, > > > > Tim. > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tmhaines at gmail.com Tue Sep 2 00:21:11 2008 From: tmhaines at gmail.com (Tim Haines) Date: Tue, 2 Sep 2008 16:21:11 +1200 Subject: [rspec-users] specs pass when run with other app specs, but fail when run independently In-Reply-To: <57c63afe0809012015p8e0374fmffc1bf123b6b774c@mail.gmail.com> References: <57c63afe0809012015p8e0374fmffc1bf123b6b774c@mail.gmail.com> Message-ID: Actually, it was patched in June. The patch author chose to use .send. http://github.com/technoweenie/restful-authentication/commit/8307820bee893b2ebbbf990b947a878ebe8b7624 Cheers, Tim. On Tue, Sep 2, 2008 at 3:15 PM, David Chelimsky wrote: > On Mon, Sep 1, 2008 at 6:22 PM, Tim Haines wrote: > > Hi there, > > > > I've noticed something a little odd with the session_controller specs > that > > are generated from the rails plugin restful_authentication. When they're > > run with all the other app specs (i.e. when I first fire up autospec) the > > specs all pass. However, if I touch the session_controller_spec file so > > only the session_controller specs are run, some fail with the error > message > > protected method `logged_in?' called for # > > > > Can anyone explain why this might be or where I should start digging to > try > > and resolve this? > > logged_in? is protected in the module AuthenticatedSystem. Chances are > that you've got a code example that's doing this: > > controller.logged_in? > > instead of this: > > controller.send(:logged_in?) > > and something that's not getting loaded when you run just > sessions_controller_spec is including AuthenticatedSystem into the > example group directly. > > > > > Cheers, > > > > Tim. > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ben at benmabey.com Tue Sep 2 01:49:57 2008 From: ben at benmabey.com (Ben Mabey) Date: Mon, 01 Sep 2008 23:49:57 -0600 Subject: [rspec-users] specs pass when run with other app specs, but fail when run independently In-Reply-To: References: <57c63afe0809012015p8e0374fmffc1bf123b6b774c@mail.gmail.com> Message-ID: <48BCD405.3050706@benmabey.com> Tim Haines wrote: > Hi David, > > You were spot on. The generated authenticated_system_spec included > AuthenticatedSystem. If I include AuthenticatedSystem into the > SessionsController spec, then the specs all pass. This is a problem > with the standard specs that resful_authentication builds for you - so > I'll looking at getting those fixed.. > > I'm kind of curios that the specs are testing these protected methods > - I would have expected that's generally not a done thing as they're > not a public part of the API? Yep, you're right. In general specing protected/private methods isn't something you want to do. The only time I have a spec for such a method is a result of a refactoring. Since the goal is to spec the behaviour of an object it makes sense IMO to use black box testing and only spec the public API as you pointed out. Whenever I find myself wanting to spec non-public methods or to stub them I take that as a hint to extract the methods out into other objects and then spec their public interfaces. restful_auth does several things from a testing and design point of view that aren't ideal though. > > I guess there's 3 options as to how to patch: > 1) include AuthenticatedSystem, or > 2) change the specs to use .send, or > 3) remove the specs that are calling protected methods. If you really want to spec the protected methods or want to keep the existing specs around I would favor using the send method because it keeps you "feeling dirty" everytime you do it. Removing the specs that are calling the protected methods would be better IMO but you could not simply remove them.. they would need to be refactored to be specing the public API while still covering all of the functionality provided in the protected methods. Again, the fact that they have been specing the protected methods is an indication that another object may want to be born to handle the extra responsibility... Just my two cents.. HTH, Ben > > Do you have any guidance on the best path forward here? > > Cheers, > > Tim. > > > On Tue, Sep 2, 2008 at 3:15 PM, David Chelimsky > wrote: > > On Mon, Sep 1, 2008 at 6:22 PM, Tim Haines > wrote: > > Hi there, > > > > I've noticed something a little odd with the session_controller > specs that > > are generated from the rails plugin restful_authentication. > When they're > > run with all the other app specs (i.e. when I first fire up > autospec) the > > specs all pass. However, if I touch the session_controller_spec > file so > > only the session_controller specs are run, some fail with the > error message > > protected method `logged_in?' called for > # > > > > Can anyone explain why this might be or where I should start > digging to try > > and resolve this? > > logged_in? is protected in the module AuthenticatedSystem. Chances are > that you've got a code example that's doing this: > > controller.logged_in? > > instead of this: > > controller.send(:logged_in?) > > and something that's not getting loaded when you run just > sessions_controller_spec is including AuthenticatedSystem into the > example group directly. > > > > > Cheers, > > > > Tim. > > > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > > > ------------------------------------------------------------------------ > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Tue Sep 2 02:35:02 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 2 Sep 2008 07:35:02 +0100 Subject: [rspec-users] specs pass when run with other app specs, but fail when run independently In-Reply-To: <48BCD405.3050706@benmabey.com> References: <57c63afe0809012015p8e0374fmffc1bf123b6b774c@mail.gmail.com> <48BCD405.3050706@benmabey.com> Message-ID: > functionality provided in the protected methods. Again, the fact that > they have been specing the protected methods is an indication that > another object may want to be born to handle the extra > responsibility... +1. The desire to unit test private methods always rings the 'refactor: extract class' siren in my head. From matt at mattwynne.net Tue Sep 2 09:50:53 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 2 Sep 2008 14:50:53 +0100 Subject: [rspec-users] Cucumber: Before(:all) Message-ID: Is there a way right now to run some setup code once after environment.rb has loaded but before all the scenarios are run? And how about a teardown after everything's done? cheers, Matt ---- http://blog.mattwynne.net http://songkick.com In case you wondered: The opinions expressed in this email are my own and do not necessarily reflect the views of any former, current or future employers of mine. -------------- next part -------------- An HTML attachment was scrubbed... URL: From aslak.hellesoy at gmail.com Tue Sep 2 10:24:31 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 2 Sep 2008 16:24:31 +0200 Subject: [rspec-users] Cucumber: Before(:all) In-Reply-To: References: Message-ID: <8d961d900809020724t3b1ee3ecmfc798ba9ed02abe6@mail.gmail.com> On Tue, Sep 2, 2008 at 3:50 PM, Matt Wynne wrote: > Is there a way right now to run some setup code once after environment.rb > has loaded but before all the scenarios are run? Yes. Just use Ruby :-) Put it at the "main level" in one of your ruby files under steps/ > And how about a teardown after everything's done? at_exit do .. end For example: # steps/globals.rb User.create! :name => 'matt' at_exit do User.destroy_all end Would this work for you? Aslak > cheers, > Matt > ---- > http://blog.mattwynne.net > http://songkick.com > In case you wondered: The opinions expressed in this email are my own and do > not necessarily reflect the views of any former, current or future employers > of mine. > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From matt at mattwynne.net Tue Sep 2 10:53:24 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 2 Sep 2008 15:53:24 +0100 Subject: [rspec-users] Cucumber: Before(:all) In-Reply-To: <8d961d900809020724t3b1ee3ecmfc798ba9ed02abe6@mail.gmail.com> References: <8d961d900809020724t3b1ee3ecmfc798ba9ed02abe6@mail.gmail.com> Message-ID: On 2 Sep 2008, at 15:24, aslak hellesoy wrote: > On Tue, Sep 2, 2008 at 3:50 PM, Matt Wynne wrote: >> Is there a way right now to run some setup code once after >> environment.rb >> has loaded but before all the scenarios are run? > > Yes. Just use Ruby :-) > > Put it at the "main level" in one of your ruby files under steps/ > >> And how about a teardown after everything's done? > > at_exit do > .. > end > > For example: > > # steps/globals.rb > > User.create! :name => 'matt' > > at_exit do > User.destroy_all > end > > Would this work for you? > > Aslak It looks good, but the before stuff doesn't work for me - it looks as though the rails environment hasn't been loaded yet - I get ' uninitialized constant User (NameError)' From aslak.hellesoy at gmail.com Tue Sep 2 11:03:58 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 2 Sep 2008 17:03:58 +0200 Subject: [rspec-users] Cucumber: Before(:all) In-Reply-To: References: <8d961d900809020724t3b1ee3ecmfc798ba9ed02abe6@mail.gmail.com> Message-ID: <8d961d900809020803x5ceac65gd26bf179ebd9924f@mail.gmail.com> On Tue, Sep 2, 2008 at 4:53 PM, Matt Wynne wrote: > On 2 Sep 2008, at 15:24, aslak hellesoy wrote: > >> On Tue, Sep 2, 2008 at 3:50 PM, Matt Wynne wrote: >>> >>> Is there a way right now to run some setup code once after environment.rb >>> has loaded but before all the scenarios are run? >> >> Yes. Just use Ruby :-) >> >> Put it at the "main level" in one of your ruby files under steps/ >> >>> And how about a teardown after everything's done? >> >> at_exit do >> .. >> end >> >> For example: >> >> # steps/globals.rb >> >> User.create! :name => 'matt' >> >> at_exit do >> User.destroy_all >> end >> >> Would this work for you? >> >> Aslak > > It looks good, but the before stuff doesn't work for me - it looks as though > the rails environment hasn't been loaded yet - I get ' uninitialized > constant User (NameError)' I assume you've followed the Wiki instructions about how to set up Cucumber with Rails: http://github.com/aslakhellesoy/cucumber/wikis (I should move this to a separate Rails page) Then you should have a steps/env.rb file that looks like this: http://github.com/aslakhellesoy/cucumber/tree/master/generators/cucumber/templates/env.rb You can put the code in this file, or you can put it in another one and do this at the top: require File.dirname(__FILE__) + '/env' HTH, Aslak > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From aidy.lewis at googlemail.com Tue Sep 2 11:54:25 2008 From: aidy.lewis at googlemail.com (aidy lewis) Date: Tue, 2 Sep 2008 16:54:25 +0100 Subject: [rspec-users] Cucumber: Before(:all) In-Reply-To: <8d961d900809020803x5ceac65gd26bf179ebd9924f@mail.gmail.com> References: <8d961d900809020724t3b1ee3ecmfc798ba9ed02abe6@mail.gmail.com> <8d961d900809020803x5ceac65gd26bf179ebd9924f@mail.gmail.com> Message-ID: <7ac2300c0809020854t6dff4d32x8fb74d22f74fce7b@mail.gmail.com> Hi, >, aslak hellesoy wrote (sometime today): > at_exit do > .. > end If I had a number of steps, stories and runners where would I put the kernal at_exit method? At the last 'Then' in a step file? At the bottom of that particular runner file? I assume there would be numerous at_exit methods i.e. different teardowns. Cheers Aidy From aslak.hellesoy at gmail.com Tue Sep 2 12:36:32 2008 From: aslak.hellesoy at gmail.com (=?UTF-8?Q?Aslak_Helles=C3=B8y?=) Date: Tue, 2 Sep 2008 18:36:32 +0200 Subject: [rspec-users] Cucumber: Before(:all) In-Reply-To: <7ac2300c0809020854t6dff4d32x8fb74d22f74fce7b@mail.gmail.com> References: <8d961d900809020724t3b1ee3ecmfc798ba9ed02abe6@mail.gmail.com> <8d961d900809020803x5ceac65gd26bf179ebd9924f@mail.gmail.com> <7ac2300c0809020854t6dff4d32x8fb74d22f74fce7b@mail.gmail.com> Message-ID: <25268380-DA7A-4BE0-BAB2-BD310E2806F4@gmail.com> > Hi, > >> , aslak hellesoy wrote (sometime today): > >> at_exit do >> .. >> end > > If I had a number of steps, stories and runners where would I put the > kernal at_exit method? > > At the last 'Then' in a step file? No, never inside a step. You should only register each at_exit hook once. > At the bottom of that particular > runner file? I assume there would be Not sure what you mean by runner file. Stick the global setup code and at_exit hook(s) at the top level in a ruby file inside your steps folder. This file shouldn't contain any step defs. Aslak > numerous at_exit methods i.e. > different teardowns. > > Cheers > > Aidy > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From matt at mattwynne.net Tue Sep 2 13:20:13 2008 From: matt at mattwynne.net (Matt Wynne) Date: Tue, 2 Sep 2008 18:20:13 +0100 Subject: [rspec-users] Cucumber: Before(:all) In-Reply-To: <8d961d900809020803x5ceac65gd26bf179ebd9924f@mail.gmail.com> References: <8d961d900809020724t3b1ee3ecmfc798ba9ed02abe6@mail.gmail.com> <8d961d900809020803x5ceac65gd26bf179ebd9924f@mail.gmail.com> Message-ID: <5B84D49C-FD04-498E-835F-4E16C42CA2AF@mattwynne.net> > > I assume you've followed the Wiki instructions about how to set up > Cucumber with Rails: > http://github.com/aslakhellesoy/cucumber/wikis (I should move this to > a separate Rails page) > > Then you should have a steps/env.rb file that looks like this: > http://github.com/aslakhellesoy/cucumber/tree/master/generators/ > cucumber/templates/env.rb > Done all that. > You can put the code in this file, or you can put it in another one > and do this at the top: > require File.dirname(__FILE__) + '/env' Aha. So I assumed that the features/steps/env.rb file was what was loading all the other files in features/steps. Sounds a bit silly when I write it down. Thanks Aslak From greg.hauptmann.ruby at gmail.com Tue Sep 2 17:05:10 2008 From: greg.hauptmann.ruby at gmail.com (Greg Hauptmann) Date: Wed, 3 Sep 2008 07:05:10 +1000 Subject: [rspec-users] RSpec sundry questions Message-ID: Hi, Q1 - Can I assume that the core testing framework (e.g. rails unit testing versus RSpec) is a kind of separate issue to whether you using mocking or not? i.e. you could use Mocha with either the rails unit test framework or Rspec? Or is there something in Rspec that integrates moreso with mocking? Q2 - Anyone know where the "build" method that Ryan used in his Rails cast? Was this a mocha method? (I couldn't see it in the api). Reference: http://railscasts.com/episodes/81-fixtures-in-rails-2-0 Q3 - Lastly......I want to jump into RSpec or Rails unit testing....I'm thinking RSpec....has RSpec got more people using it than other testing frameworks now? i.e. for Rails developers? Thanks From aslak.hellesoy at gmail.com Tue Sep 2 17:29:54 2008 From: aslak.hellesoy at gmail.com (aslak hellesoy) Date: Tue, 2 Sep 2008 23:29:54 +0200 Subject: [rspec-users] RSpec sundry questions In-Reply-To: References: Message-ID: <8d961d900809021429p31516fc7j958ca8287f87e8db@mail.gmail.com> On Tue, Sep 2, 2008 at 11:05 PM, Greg Hauptmann wrote: > Hi, > > Q1 - Can I assume that the core testing framework (e.g. rails unit > testing versus RSpec) is a kind of separate issue to whether you using > mocking or not? i.e. you could use Mocha with either the rails unit > test framework or Rspec? Or is there something in Rspec that > integrates moreso with mocking? > I'm not sure I understand the question. Mocha can be used with Rails, RSpec, Test::Unit, plain Ruby libraries... The same is true about RSpec's built-in mocking library. The only mocking-specific thing about RSpec is that it ships with mocking built-in. But if you're happier with Test::Unit style tests, TU+mocha will technically do the same (more or less). > Q2 - Anyone know where the "build" method that Ryan used in his Rails > cast? Was this a mocha method? (I couldn't see it in the api). > Reference: http://railscasts.com/episodes/81-fixtures-in-rails-2-0 > Where is the "build" method in this screencast? (I didn't check the sound). > Q3 - Lastly......I want to jump into RSpec or Rails unit > testing....I'm thinking RSpec....has RSpec got more people using it > than other testing frameworks now? i.e. for Rails developers? > The only survey I know about is this: http://on-ruby.blogspot.com/2007/12/ruby-dev-tools-survey-results.html Aslak > Thanks > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From tmhaines at gmail.com Tue Sep 2 17:49:01 2008 From: tmhaines at gmail.com (Tim Haines) Date: Wed, 3 Sep 2008 09:49:01 +1200 Subject: [rspec-users] GiT and RSpec In-Reply-To: <48476.216.185.71.22.1212419653.squirrel@webmail.harte-lyne.ca> References: <48476.216.185.71.22.1212419653.squirrel@webmail.harte-lyne.ca> Message-ID: Hi James, Thanks for writing these instructions up in detail. I've just followed them and will play around with them over the next few days. A couple of questions 1) I assume with submodules I can create and switch to branches of the submodules if I want to try my app out with some patches applied to rspec or rails? There's no hidden gotch'ya here? 2) When I'm getting near deployment for production (a few months away yet) I'm thinking of freezing to a tagged version of Rails. (Not sure this terminology is still correct with Git - but basically I might stick with Rails 2.2 or something - but I'm not sure this has benefits anymore). How would you go about this? Cheers, Tim. On Tue, Jun 3, 2008 at 3:14 AM, James B. Byrne wrote: > > > > > Message: 2 > > Date: Thu, 29 May 2008 06:35:01 -0700 > > From: David Chelimsky > > Subject: Re: [rspec-users] Coloured output in rspec 1.1.4 > > To: rspec-users at rubyforge.org > > Message-ID: <175B70FE-B706-4C03-8B20-C5B207268AD6 at gmail.com> > > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > > > On May 29, 2008, at 6:32 AM, Juanma Cervera wrote: > > > >> David Chelimsky wrote: > >>> > >>> Actually - that is not from 1.1.4 - it's a patch that was introduced > >>> after the 1.1.4 release. Did you follow the install directions at > >>> http://github.com/dchelimsky/rspec-rails/wikis? > >> > >> More or less. > >> I have git-cloned from github repositories instead of make > >> "script/plugin install" > > > > script/plugin install doesn't support getting a specific version from > > git yet. To do that you have to use 'git clone' and then 'git checkout > > 1.1.4' (in this case). > > > > As an alternative to script/plugin or git-clone, you can employ > git-submodules > (on GiT v1.5.3 or later) to obtain the effect of subversion externals. For > example: > > ---> > > $ git-submodule add \ > git://github.com/dchelimsky/rspec.git \ > vendor/plugins/rspec > > Initialized empty Git repository in > /home/byrnejb/projects/proforma.git/vendor/plugins/rspec/.git/ > remote: Counting objects: 46810, done. > remote: Compressing objects: 100% (10646/10646), done. > remote: Total 46810 (delta 33521), reused 46810 (delta 33521) > Receiving objects: 100% (46810/46810), 5.99 MiB | 103 KiB/s, done. > Resolving deltas: 100% (33521/33521), done. > > $ ll vendor/plugins > total 16 > drwxrwxr-x 6 byrnejb byrnejb 4096 May 28 14:06 routing_navigator > drwxrwxr-x 12 byrnejb byrnejb 4096 Jun 2 10:09 rspec > > $ git-submodule add \ > git://github.com/dchelimsky/rspec-rails.git \ > vendor/plugins/rspec-rails > > Initialized empty Git repository in > /home/byrnejb/projects/proforma.git/vendor/plugins/rspec-rails/.git/ > remote: Counting objects: 46530, done. > remote: Compressing objects: 100% (10649/10649), done. > remote: Total 46530 (delta 33241), reused 46530 (delta 33241) > Receiving objects: 100% (46530/46530), 5.94 MiB | 63 KiB/s, done. > Resolving deltas: 100% (33241/33241), done. > > $ git-status > # On branch master > # Changes to be committed: > # (use "git reset HEAD ..." to unstage) > # > # modified: .gitmodules > # new file: vendor/plugins/rspec > # new file: vendor/plugins/rspec-rails > # > > $ git-submodule init > > Submodule 'vendor/plugins/rspec' (git://github.com/dchelimsky/rspec.git) > registered for path 'vendor/plugins/rspec' > Submodule 'vendor/plugins/rspec-rails' > (git://github.com/dchelimsky/rspec-rails.git) registered for path > 'vendor/plugins/rspec-rails' > > $ git-status > # On branch master > # Changes to be committed: > # (use "git reset HEAD ..." to unstage) > # > # modified: .gitmodules > # new file: vendor/plugins/rspec > # new file: vendor/plugins/rspec-rails > # > > $ git-commit -m "Added Rspec and Rspec-Rails as submodules" > > Created commit b4d1133: Added Rspec and Rspec-Rails as submodules > 3 files changed, 8 insertions(+), 0 deletions(-) > create mode 160000 vendor/plugins/rspec > create mode 160000 vendor/plugins/rspec-rails > > $ git-status > # On branch master > nothing to commit (working directory clean) > > $ git-push # over ssh > !!Warning!! - Any attempt to obtain access to this device without > authorization is a criminal act. > byrnejb at vcs-git.hamilton.harte-lyne.ca's password: > Counting objects: 9, done. > Compressing objects: 100% (5/5), done. > Writing objects: 100% (5/5), 607 bytes, done. > Total 5 (delta 1), reused 0 (delta 0) > To ssh:// > byrnejb at vcs-git.hamilton.harte-lyne.ca/var/data/vcs-git/hll/proforma.git > ab5353b..b4d1133 master -> master > > $ > > <--- > > Now, when anyone pulls from the canonical repository they will get Rspec > and > Rspec-on-Rails as well, but as submodules pulled directly from the RSpec > repositories. Further, updating all submodules thereafter requires just > these > three steps: > > $git-submodule update > $git-commit > $git-push > > This is how I load edge rails as well, as a submodule: > > $ git-submodule add git://github.com/rails/rails.git vendor/rails > $ git-submodule init > $ git-commit > $ git-push > > Once you do this you can locally checkout any version or branch that is > available in the submodule. > > Regards, > > -- > *** E-Mail is NOT a SECURE channel *** > James B. Byrne mailto:ByrneJB at Harte-Lyne.ca > Harte & Lyne Limited http://www.harte-lyne.ca > 9 Brockley Drive vox: +1 905 561 1241 > Hamilton, Ontario fax: +1 905 561 0757 > Canada L8E 3C3 > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris at cobaltedge.com Tue Sep 2 17:56:34 2008 From: chris at cobaltedge.com (Christopher Bailey) Date: Tue, 2 Sep 2008 14:56:34 -0700 Subject: [rspec-users] GiT and RSpec In-Reply-To: References: <48476.216.185.71.22.1212419653.squirrel@webmail.harte-lyne.ca> Message-ID: <443c240c0809021456o7a5eddbesdd7166cbdd828f44@mail.gmail.com> I would voice a word of caution on using submodules in Git. Yes, they are similar to svn:externals, but in my experience, they are very fragile. The fragility comes in when/if you need to switch the submodule URL/definition from what it is currently to something else. I've had no end of trouble with this, as have several others. My current take on Git submodules is that I either don't use them, or I fork whatever it is I'd want as a submodule, and reference my fork as the submodule. That way, if I need to make changes, switch from someone's git repo of something to someone else's or whatever, all that is contained in my fork, instead of having to switch the submodule in my project. On Tue, Sep 2, 2008 at 2:49 PM, Tim Haines wrote: > Hi James, > > Thanks for writing these instructions up in detail. I've just followed > them and will play around with them over the next few days. A couple of > questions > > 1) I assume with submodules I can create and switch to branches of the > submodules if I want to try my app out with some patches applied to rspec or > rails? There's no hidden gotch'ya here? > > 2) When I'm getting near deployment for production (a few months away yet) > I'm thinking of freezing to a tagged version of Rails. (Not sure this > terminology is still correct with Git - but basically I might stick with > Rails 2.2 or something - but I'm not sure this has benefits anymore). How > would you go about this? > > Cheers, > > Tim. > > On Tue, Jun 3, 2008 at 3:14 AM, James B. Byrne wrote: > >> >> > >> > Message: 2 >> > Date: Thu, 29 May 2008 06:35:01 -0700 >> > From: David Chelimsky >> > Subject: Re: [rspec-users] Coloured output in rspec 1.1.4 >> > To: rspec-users at rubyforge.org >> > Message-ID: <175B70FE-B706-4C03-8B20-C5B207268AD6 at gmail.com> >> > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes >> > >> > On May 29, 2008, at 6:32 AM, Juanma Cervera wrote: >> > >> >> David Chelimsky wrote: >> >>> >> >>> Actually - that is not from 1.1.4 - it's a patch that was introduced >> >>> after the 1.1.4 release. Did you follow the install directions at >> >>> http://github.com/dchelimsky/rspec-rails/wikis? >> >> >> >> More or less. >> >> I have git-cloned from github repositories instead of make >> >> "script/plugin install" >> > >> > script/plugin install doesn't support getting a specific version from >> > git yet. To do that you have to use 'git clone' and then 'git checkout >> > 1.1.4' (in this case). >> > >> >> As an alternative to script/plugin or git-clone, you can employ >> git-submodules >> (on GiT v1.5.3 or later) to obtain the effect of subversion externals. >> For >> example: >> >> ---> >> >> $ git-submodule add \ >> git://github.com/dchelimsky/rspec.git \ >> vendor/plugins/rspec >> >> Initialized empty Git repository in >> /home/byrnejb/projects/proforma.git/vendor/plugins/rspec/.git/ >> remote: Counting objects: 46810, done. >> remote: Compressing objects: 100% (10646/10646), done. >> remote: Total 46810 (delta 33521), reused 46810 (delta 33521) >> Receiving objects: 100% (46810/46810), 5.99 MiB | 103 KiB/s, done. >> Resolving deltas: 100% (33521/33521), done. >> >> $ ll vendor/plugins >> total 16 >> drwxrwxr-x 6 byrnejb byrnejb 4096 May 28 14:06 routing_navigator >> drwxrwxr-x 12 byrnejb byrnejb 4096 Jun 2 10:09 rspec >> >> $ git-submodule add \ >> git://github.com/dchelimsky/rspec-rails.git \ >> vendor/plugins/rspec-rails >> >> Initialized empty Git repository in >> /home/byrnejb/projects/proforma.git/vendor/plugins/rspec-rails/.git/ >> remote: Counting objects: 46530, done. >> remote: Compressing objects: 100% (10649/10649), done. >> remote: Total 46530 (delta 33241), reused 46530 (delta 33241) >> Receiving objects: 100% (46530/46530), 5.94 MiB | 63 KiB/s, done. >> Resolving deltas: 100% (33241/33241), done. >> >> $ git-status >> # On branch master >> # Changes to be committed: >> # (use "git reset HEAD ..." to unstage) >> # >> # modified: .gitmodules >> # new file: vendor/plugins/rspec >> # new file: vendor/plugins/rspec-rails >> # >> >> $ git-submodule init >> >> Submodule 'vendor/plugins/rspec' (git://github.com/dchelimsky/rspec.git) >> registered for path 'vendor/plugins/rspec' >> Submodule 'vendor/plugins/rspec-rails' >> (git://github.com/dchelimsky/rspec-rails.git) registered for path >> 'vendor/plugins/rspec-rails' >> >> $ git-status >> # On branch master >> # Changes to be committed: >> # (use "git reset HEAD ..." to unstage) >> # >> # modified: .gitmodules >> # new file: vendor/plugins/rspec >> # new file: vendor/plugins/rspec-rails >> # >> >> $ git-commit -m "Added Rspec and Rspec-Rails as submodules" >> >> Created commit b4d1133: Added Rspec and Rspec-Rails as submodules >> 3 files changed, 8 insertions(+), 0 deletions(-) >> create mode 160000 vendor/plugins/rspec >> create mode 160000 vendor/plugins/rspec-rails >> >> $ git-status >> # On branch master >> nothing to commit (working directory clean) >> >> $ git-push # over ssh >> !!Warning!! - Any attempt to obtain access to this device without >> authorization is a criminal act. >> byrnejb at vcs-git.hamilton.harte-lyne.ca's password: >> Counting objects: 9, done. >> Compressing objects: 100% (5/5), done. >> Writing objects: 100% (5/5), 607 bytes, done. >> Total 5 (delta 1), reused 0 (delta 0) >> To ssh:// >> byrnejb at vcs-git.hamilton.harte-lyne.ca/var/data/vcs-git/hll/proforma.git >> ab5353b..b4d1133 master -> master >> >> $ >> >> <--- >> >> Now, when anyone pulls from the canonical repository they will get Rspec >> and >> Rspec-on-Rails as well, but as submodules pulled directly from the RSpec >> repositories. Further, updating all submodules thereafter requires just >> these >> three steps: >> >> $git-submodule update >> $git-commit >> $git-push >> >> This is how I load edge rails as well, as a submodule: >> >> $ git-submodule add git://github.com/rails/rails.git vendor/rails >> $ git-submodule init >> $ git-commit >> $ git-push >> >> Once you do this you can locally checkout any version or branch that is >> available in the submodule. >> >> Regards, >> >> -- >> *** E-Mail is NOT a SECURE channel *** >> James B. Byrne mailto:ByrneJB at Harte-Lyne.ca >> Harte & Lyne Limited http://www.harte-lyne.ca >> 9 Brockley Drive vox: +1 905 561 1241 >> Hamilton, Ontario fax: +1 905 561 0757 >> Canada L8E 3C3 >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Christopher Bailey Cobalt Edge LLC http://cobaltedge.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From tmhaines at gmail.com Tue Sep 2 18:41:22 2008 From: tmhaines at gmail.com (Tim Haines) Date: Wed, 3 Sep 2008 10:41:22 +1200 Subject: [rspec-users] Controller specs erroneously loading views in edge rails? In-Reply-To: <18656E85-26FE-4E5D-A015-04540FC1510B@artweb-design.de> References: <87fc2bcc-f42e-4a90-bfed-fdaec43c4c6b@25g2000hsx.googlegroups.com> <791A8191-D2C0-47C0-AE62-5765D6E090FE@artweb-design.de> <57c63afe0808230728g6d7cb048w23017945b91a67f3@mail.gmail.com> <18656E85-26FE-4E5D-A015-04540FC1510B@artweb-design.de> Message-ID: Hi guys, After updating to edge rails I've just struck this problem too. I've just grabbed fresh updates of rspec, rspec-rails, and rails and I'm receiving a few controller spec failures related to view rendering when views shouldn't be rendered (failures relate to mock objects not having expected attributes and methods). I've logged this in lighthouse -> http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/516 Here's a copy of the full backtrace of one of the fails: vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:376:in `raise_named_route_error' vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:340:in `generate' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:208:in `rewrite_path' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:187:in `rewrite_url' vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:165:in `rewrite' vendor/rails/actionpack/lib/action_controller/base.rb:630:in `url_for' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:85:in `send' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:85:in `url_for' (eval):15:in `user_path' vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:111:in `__send__' vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:111:in `polymorphic_url' vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:118:in `polymorphic_path' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:91:in `url_for' vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:228:in `link_to' app/views/home/index.html.erb:5 app/views/home/index.html.erb:4:in `each' app/views/home/index.html.erb:4 vendor/rails/actionpack/lib/action_view/renderable.rb:35:in `send' vendor/rails/actionpack/lib/action_view/renderable.rb:35:in `render' vendor/rails/actionpack/lib/action_view/template.rb:68:in `render_template' vendor/rails/actionpack/lib/action_view/base.rb:266:in `orig_render' vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:26:in `render' vendor/rails/actionpack/lib/action_view/base.rb:369:in `_render_with_layout' vendor/rails/actionpack/lib/action_view/base.rb:260:in `orig_render' vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:26:in `render' vendor/rails/actionpack/lib/action_controller/base.rb:1118:in `render_for_file' vendor/rails/actionpack/lib/action_controller/base.rb:881:in `render_without_benchmark' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb:213:in `render' vendor/rails/actionpack/lib/action_controller/base.rb:853:in `render_without_benchmark' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in `realtime' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in `render' vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb:213:in `render' vendor/rails/actionpack/lib/action_controller/base.rb:1170:in `default_render' vendor/rails/actionpack/lib/action_controller/base.rb:1176:in `perform_action_without_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in `measure' vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue' vendor/rails/actionpack/lib/action_controller/rescue.rb:202:in `perform_action_without_caching' vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in `perform_action' vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in `cache' vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache' vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in `perform_action' vendor/rails/actionpack/lib/action_controller/base.rb:535:in `send' vendor/rails/actionpack/lib/action_controller/base.rb:535:in `process_without_filters' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' vendor/rails/actionpack/lib/action_controller/base.rb:535:in `process_without_filters' vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_without_session_management_support' vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in `process_without_test' vendor/rails/actionpack/lib/action_controller/test_process.rb:18:in `process' vendor/rails/actionpack/lib/action_controller/test_process.rb:400:in `process' vendor/rails/actionpack/lib/action_controller/test_process.rb:371:in `get' controllers/home_controller_spec.rb:12 vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in `instance_eval' vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in `eval_block' vendor/plugins/rspec/lib/spec/example/example_methods.rb:21:in `execute' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:48:in `timeout' vendor/plugins/rspec/lib/spec/example/example_methods.rb:18:in `execute' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:305:in `execute_examples' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in `each' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in `execute_examples' vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:132:in `run' vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in `run' vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `each' vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in `run' vendor/plugins/rspec/lib/spec/runner/options.rb:115:in `run_examples' vendor/plugins/rspec/lib/spec.rb:21:in `run' vendor/plugins/rspec/lib/spec/runner.rb:192:in `register_at_exit_hook' controllers/home_controller_spec On Sun, Aug 24, 2008 at 8:57 AM, Sven Fuchs wrote: > Ok, done. > > > http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/508-recent-changes-in-actionpack-break-controller-specs > > Thanks! > > > On 23.08.2008, at 16:28, David Chelimsky wrote: > > There are a number of changes to action pack recently that are >> incompatible with rspec. Please report these to lighthouse. >> >> Thanks, >> David >> >> On Sat, Aug 23, 2008 at 6:12 AM, Sven Fuchs >> wrote: >> >>> Trying to port an existing app to current Rails edge I've seen similar >>> things yesterday. I've also updated RSpec/Rails to recent edge. >>> >>> Here are two workarounds I've come up with for two of the problems. I'm >>> not >>> sure if they cause other problems themselves, but maybe they're still >>> useful >>> as a hint. >>> >>> http://pastie.org/private/5ueehxiqhdgok0d8udksa >>> >>> I don't feel familiar enough with RSpec's guts to provide a patch. >>> >>> #render_partial on ActionView::Base seems to break because the method >>> signature has changed. >>> #render on ControllerExampleGroup seems to break because #render_file >>> apparently has been removed. >>> >>> >>> >>> On 23.08.2008, at 00:30, John Reilly wrote: >>> >>> Hello, >>>> >>>> I think I may have found a bug between rspec and edge rails... But I'm >>>> new to this so I'm hoping someone else can confirm before I go filing >>>> bug reports. >>>> >>>> Basically, I'm seeing what "appears" to be my controller specs >>>> deciding to load the views, even though I haven't called >>>> integrate_views. When I generate a default rspec_scaffold, the specs >>>> fail with an ActionView::TemplateError: >>>> >>>> % script/generate rspec_scaffold Bike name:string sku:string >>>>> ... >>>>> rake spec >>>>> ... >>>>> Mock 'Bike_1017' received unexpected message :name with (no args) >>>>> On line #11 of app/views/index.html.erb >>>>> >>>> >>>> If I modify the generated index spec like this, the spec passes: >>>> >>>> ...snip... >>>> >>>>> >>>>> it "should expose all bikes as @bikes" do >>>>> Bike.should_receive(:find).with(:all).and_return([mock_bike]) >>>>> >>>>> # adding these lines cause the spec to pass... >>>>> mock_bike.should_receive(:name) >>>>> mock_bike.should_receive(:sku) >>>>> >>>>> get :index >>>>> assigns[:bikes].should == [mock_bike] >>>>> end >>>>> >>>> >>>> ...snip... >>>> >>>> While this "fixes" the failures, it's no longer an isolated test of >>>> the controller. >>>> >>>> After spending some time with git-bisect, it looks like this problem >>>> was introduced in a commit to edge rails: >>>> >>>> >>>> http://github.com/rails/rails/commit/1129a24caff9f1804c2bff6569c0cbd8598dfa86 >>>> >>>> The default rspec_scaffold tests pass before this commit, and fail >>>> after this commit. >>>> >>>> More details here: >>>> http://johnreilly.tumblr.com/post/47016047/rspec-is-mocking-me >>>> >>>> Am I insane? Or does this happen for anyone else? :-) >>>> >>>> Thanks, >>>> -- John Reilly >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> >>> -- >>> sven fuchs svenfuchs at artweb-design.de >>> artweb design http://www.artweb-design.de >>> gr?nberger 65 + 49 (0) 30 - 47 98 69 96 (phone) >>> d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile) >>> >>> >>> >>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >>> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -- > sven fuchs svenfuchs at artweb-design.de > artweb design http://www.artweb-design.de > gr?nberger 65 + 49 (0) 30 - 47 98 69 96 (phone) > d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile) > > > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pergesu at gmail.com Tue Sep 2 19:48:20 2008 From: pergesu at gmail.com (Pat Maddox) Date: Tue, 2 Sep 2008 19:48:20 -0400 Subject: [rspec-users] GiT and RSpec In-Reply-To: References: <48476.216.185.71.22.1212419653.squirrel@webmail.harte-lyne.ca> Message-ID: <810a540e0809021648q581fde84p6d1737d95f4352e5@mail.gmail.com> On Tue, Sep 2, 2008 at 5:49 PM, Tim Haines wrote: > Hi James, > > Thanks for writing these instructions up in detail. I've just followed them > and will play around with them over the next few days. A couple of > questions > > 1) I assume with submodules I can create and switch to branches of the > submodules if I want to try my app out with some patches applied to rspec or > rails? There's no hidden gotch'ya here? There is. If you ever run "git submodule init" (and/or update, I don't remember) again then it'll blow away your entire local repo. Meaning if you've made changes that you haven't pushed, you lose them all. Suck. Also, if you're actually making changes to the child repo, and you're working collaboratively, you're going to be dealing with a bunch of headaches. Basically, submodules work by git saying "vendor/plugins/rspec points to commit abc123 from git://github.com/yourmirror/rspec.git". If you make changes to the repo and commit, git will update the reference to the new commit. Now let's say one of your coworkers makes a non-conflicting change and commits...well, now the parent repo has conflicting changes (you say that the submodule points to foo456 and your coworker says it points to bar789). You get a conflict in the parent repo, now you have to resolve it, and you have to do it every single time. This was the system we originally had when the RSpec repo moved to git and it was a massive PITA. Basically, if you want to track remote repos, but you're not doing active development on them, submodules work fine. The second you want to start making changes, submodules are going to be a bitch. I wrote a gem and some sake tasks to help with this a bit. It's very simple but it's worked beautifully so far for me. http://github.com/pat-maddox/giternal/tree/master > 2) When I'm getting near deployment for production (a few months away yet) > I'm thinking of freezing to a tagged version of Rails. (Not sure this > terminology is still correct with Git - but basically I might stick with > Rails 2.2 or something - but I'm not sure this has benefits anymore). How > would you go about this? Freezing is something that I want to put into giternal but so far haven't had a strong enough need to. I might work on it soon just for the heck of it :) The basic idea I have is to flatten the repo...so you move the .git dir to .git.frozen, add the whole external and commit. Then to unfreeze you remove the dir from version control (though without deleting it locally) and move .git.frozen back to .git. Again, something I want to put in giternal but haven't done yet. Pat From lists at ruby-forum.com Wed Sep 3 01:46:34 2008 From: lists at ruby-forum.com (Daniel Hoey) Date: Wed, 3 Sep 2008 07:46:34 +0200 Subject: [rspec-users] `exit?': undefined method `run?' for Test::Unit:Module ( In-Reply-To: <17685410.post@talk.nabble.com> References: <17685410.post@talk.nabble.com> Message-ID: <994fa24c9ba35fdbf08f0174979db821@ruby-forum.com> I had the same problem with some of my specs. Solved by adding require 'test/unit' to the spec file. Not complete sure why this occurs but the Test::Unit.run? method is defined in test/unit.rb. kasutaja wrote: > Why am I getting this error if running from Netbeans or just from > command > line with executing blah_spec.rb? If I run with spec bla blah > blah_spec.rb > then it's fine. > > . > > Finished in 0.264 seconds > > 1 example, 0 failures > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec.rb:27:in `exit?': > undefined method `run?' for Test::Unit:Module (NoMethodError) > from > c:/ruby/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/spec/runner.rb:193:in > `register_at_exit_hook' > from C:/projects/xpstuff/watir/src/list_sitt.rb:3 -- Posted via http://www.ruby-forum.com/. From keith at dancingtext.com Wed Sep 3 05:52:56 2008 From: keith at dancingtext.com (Keith McDonnell) Date: Wed, 03 Sep 2008 11:52:56 +0200 Subject: [rspec-users] fixture instantiated in before block? Message-ID: <48BE5E78.4020602@dancingtext.com> Hi all, Are fixtures not loaded & instantiated in the before block? I thought they /should/ be :) eg before(:all) do [@matt_applying_for_it, @matt, @it_industry].each { |v| puts v.inspect } end it "should ..." do [@matt_applying_for_it, @matt, @it_industry].each { |v| puts v.inspect } end => nil nil nil # # # Is this a bug or expected behavior? Thanks, Keith From tmhaines at gmail.com Wed Sep 3 06:58:45 2008 From: tmhaines at gmail.com (Tim Haines) Date: Wed, 3 Sep 2008 22:58:45 +1200 Subject: [rspec-users] Controller specs erroneously loading views in edge rails? In-Reply-To: References: <87fc2bcc-f42e-4a90-bfed-fdaec43c4c6b@25g2000hsx.googlegroups.com> <791A8191-D2C0-47C0-AE62-5765D6E090FE@artweb-design.de> <57c63afe0808230728g6d7cb048w23017945b91a67f3@mail.gmail.com> <18656E85-26FE-4E5D-A015-04540FC1510B@artweb-design.de> Message-ID: Ian White has just submitted a patch for this. Thanks Ian. http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/516 Tim. On Wed, Sep 3, 2008 at 10:41 AM, Tim Haines wrote: > Hi guys, > > After updating to edge rails I've just struck this problem too. I've just > grabbed fresh updates of rspec, rspec-rails, and rails and I'm receiving a > few controller spec failures related to view rendering when views shouldn't > be rendered (failures relate to mock objects not having expected attributes > and methods). > > I've logged this in lighthouse -> > http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/516 > > Here's a copy of the full backtrace of one of the fails: > > > vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:376:in > `raise_named_route_error' > > vendor/rails/actionpack/lib/action_controller/routing/route_set.rb:340:in > `generate' > vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:208:in > `rewrite_path' > vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:187:in > `rewrite_url' > vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:165:in > `rewrite' > vendor/rails/actionpack/lib/action_controller/base.rb:630:in `url_for' > vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:85:in > `send' > vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:85:in > `url_for' > (eval):15:in `user_path' > > vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:111:in > `__send__' > > vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:111:in > `polymorphic_url' > > vendor/rails/actionpack/lib/action_controller/polymorphic_routes.rb:118:in > `polymorphic_path' > vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:91:in > `url_for' > vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:228:in > `link_to' > app/views/home/index.html.erb:5 > app/views/home/index.html.erb:4:in `each' > app/views/home/index.html.erb:4 > vendor/rails/actionpack/lib/action_view/renderable.rb:35:in `send' > vendor/rails/actionpack/lib/action_view/renderable.rb:35:in `render' > vendor/rails/actionpack/lib/action_view/template.rb:68:in > `render_template' > vendor/rails/actionpack/lib/action_view/base.rb:266:in `orig_render' > > vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:26:in > `render' > vendor/rails/actionpack/lib/action_view/base.rb:369:in > `_render_with_layout' > vendor/rails/actionpack/lib/action_view/base.rb:260:in `orig_render' > > vendor/plugins/rspec-rails/lib/spec/rails/extensions/action_view/base.rb:26:in > `render' > vendor/rails/actionpack/lib/action_controller/base.rb:1118:in > `render_for_file' > vendor/rails/actionpack/lib/action_controller/base.rb:881:in > `render_without_benchmark' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in > `render' > > vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in > `realtime' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in > `render' > > vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb:213:in > `render' > vendor/rails/actionpack/lib/action_controller/base.rb:853:in > `render_without_benchmark' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in > `render' > > vendor/rails/activesupport/lib/active_support/core_ext/benchmark.rb:8:in > `realtime' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb:51:in > `render' > > vendor/plugins/rspec-rails/lib/spec/rails/example/controller_example_group.rb:213:in > `render' > vendor/rails/actionpack/lib/action_controller/base.rb:1170:in > `default_render' > vendor/rails/actionpack/lib/action_controller/base.rb:1176:in > `perform_action_without_filters' > vendor/rails/actionpack/lib/action_controller/filters.rb:617:in > `call_filters' > vendor/rails/actionpack/lib/action_controller/filters.rb:610:in > `perform_action_without_benchmark' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in > `measure' > vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in > `perform_action_without_rescue' > vendor/rails/actionpack/lib/action_controller/rescue.rb:202:in > `perform_action_without_caching' > > vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in > `perform_action' > > vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_cache.rb:48:in > `cache' > vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache' > > vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in > `perform_action' > vendor/rails/actionpack/lib/action_controller/base.rb:535:in `send' > vendor/rails/actionpack/lib/action_controller/base.rb:535:in > `process_without_filters' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in > `synchronize' > vendor/rails/actionpack/lib/action_controller/base.rb:535:in > `process_without_filters' > vendor/rails/actionpack/lib/action_controller/filters.rb:606:in > `process_without_session_management_support' > > vendor/rails/actionpack/lib/action_controller/session_management.rb:130:in > `process_without_test' > vendor/rails/actionpack/lib/action_controller/test_process.rb:18:in > `process' > vendor/rails/actionpack/lib/action_controller/test_process.rb:400:in > `process' > vendor/rails/actionpack/lib/action_controller/test_process.rb:371:in > `get' > controllers/home_controller_spec.rb:12 > vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in > `instance_eval' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:83:in > `eval_block' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:21:in > `execute' > > /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:48:in > `timeout' > vendor/plugins/rspec/lib/spec/example/example_methods.rb:18:in > `execute' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:305:in > `execute_examples' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in > `each' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:304:in > `execute_examples' > vendor/plugins/rspec/lib/spec/example/example_group_methods.rb:132:in > `run' > vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:22:in > `run' > vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in > `each' > vendor/plugins/rspec/lib/spec/runner/example_group_runner.rb:21:in > `run' > vendor/plugins/rspec/lib/spec/runner/options.rb:115:in `run_examples' > vendor/plugins/rspec/lib/spec.rb:21:in `run' > vendor/plugins/rspec/lib/spec/runner.rb:192:in `register_at_exit_hook' > controllers/home_controller_spec > > On Sun, Aug 24, 2008 at 8:57 AM, Sven Fuchs wrote: > >> Ok, done. >> >> >> http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/508-recent-changes-in-actionpack-break-controller-specs >> >> Thanks! >> >> >> On 23.08.2008, at 16:28, David Chelimsky wrote: >> >> There are a number of changes to action pack recently that are >>> incompatible with rspec. Please report these to lighthouse. >>> >>> Thanks, >>> David >>> >>> On Sat, Aug 23, 2008 at 6:12 AM, Sven Fuchs >>> wrote: >>> >>>> Trying to port an existing app to current Rails edge I've seen similar >>>> things yesterday. I've also updated RSpec/Rails to recent edge. >>>> >>>> Here are two workarounds I've come up with for two of the problems. I'm >>>> not >>>> sure if they cause other problems themselves, but maybe they're still >>>> useful >>>> as a hint. >>>> >>>> http://pastie.org/private/5ueehxiqhdgok0d8udksa >>>> >>>> I don't feel familiar enough with RSpec's guts to provide a patch. >>>> >>>> #render_partial on ActionView::Base seems to break because the method >>>> signature has changed. >>>> #render on ControllerExampleGroup seems to break because #render_file >>>> apparently has been removed. >>>> >>>> >>>> >>>> On 23.08.2008, at 00:30, John Reilly wrote: >>>> >>>> Hello, >>>>> >>>>> I think I may have found a bug between rspec and edge rails... But I'm >>>>> new to this so I'm hoping someone else can confirm before I go filing >>>>> bug reports. >>>>> >>>>> Basically, I'm seeing what "appears" to be my controller specs >>>>> deciding to load the views, even though I haven't called >>>>> integrate_views. When I generate a default rspec_scaffold, the specs >>>>> fail with an ActionView::TemplateError: >>>>> >>>>> % script/generate rspec_scaffold Bike name:string sku:string >>>>>> ... >>>>>> rake spec >>>>>> ... >>>>>> Mock 'Bike_1017' received unexpected message :name with (no args) >>>>>> On line #11 of app/views/index.html.erb >>>>>> >>>>> >>>>> If I modify the generated index spec like this, the spec passes: >>>>> >>>>> ...snip... >>>>> >>>>>> >>>>>> it "should expose all bikes as @bikes" do >>>>>> Bike.should_receive(:find).with(:all).and_return([mock_bike]) >>>>>> >>>>>> # adding these lines cause the spec to pass... >>>>>> mock_bike.should_receive(:name) >>>>>> mock_bike.should_receive(:sku) >>>>>> >>>>>> get :index >>>>>> assigns[:bikes].should == [mock_bike] >>>>>> end >>>>>> >>>>> >>>>> ...snip... >>>>> >>>>> While this "fixes" the failures, it's no longer an isolated test of >>>>> the controller. >>>>> >>>>> After spending some time with git-bisect, it looks like this problem >>>>> was introduced in a commit to edge rails: >>>>> >>>>> >>>>> http://github.com/rails/rails/commit/1129a24caff9f1804c2bff6569c0cbd8598dfa86 >>>>> >>>>> The default rspec_scaffold tests pass before this commit, and fail >>>>> after this commit. >>>>> >>>>> More details here: >>>>> http://johnreilly.tumblr.com/post/47016047/rspec-is-mocking-me >>>>> >>>>> Am I insane? Or does this happen for anyone else? :-) >>>>> >>>>> Thanks, >>>>> -- John Reilly >>>>> >>>>> _______________________________________________ >>>>> rspec-users mailing list >>>>> rspec-users at rubyforge.org >>>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>>> >>>> >>>> -- >>>> sven fuchs svenfuchs at artweb-design.de >>>> artweb design http://www.artweb-design.de >>>> gr?nberger 65 + 49 (0) 30 - 47 98 69 96 (phone) >>>> d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile) >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >>> >> >> -- >> sven fuchs svenfuchs at artweb-design.de >> artweb design http://www.artweb-design.de >> gr?nberger 65 + 49 (0) 30 - 47 98 69 96 (phone) >> d-10245 berlin + 49 (0) 171 - 35 20 38 4 (mobile) >> >> >> >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From loop at superinfinite.com Wed Sep 3 07:56:28 2008 From: loop at superinfinite.com (Bart Zonneveld) Date: Wed, 3 Sep 2008 13:56:28 +0200 Subject: [rspec-users] Speccing the existance of an unchecked checkbox Message-ID: <2054A5D2-B86A-4C8A-A032-1E058B8D4101@superinfinite.com> Hey list, I found myself trying to verify there are some non-checked checkboxes in a template today, and am kinda stumped how to do it :). A checked checkbox is easy, have_tag('input[type=checkbox] [checked=checked]). But, an unchecked checkbox hasn't got the checked attribute at all. And as it so happens, I want to test for a number of checked, and a number of unchecked checkboxes. So, just testing for input[type=checkbox] would return the number of checked *and* unchecked checkboxes.. any ideas? bartz ps: that's prolly the most occurences of 'check' in a single email... From dchelimsky at gmail.com Wed Sep 3 08:46:23 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 3 Sep 2008 07:46:23 -0500 Subject: [rspec-users] fixture instantiated in before block? In-Reply-To: <48BE5E78.4020602@dancingtext.com> References: <48BE5E78.4020602@dancingtext.com> Message-ID: <57c63afe0809030546y2a9c29fel401fd24806d1e4b1@mail.gmail.com> On Wed, Sep 3, 2008 at 4:52 AM, Keith McDonnell wrote: > Hi all, > > Are fixtures not loaded & instantiated in the before block? I thought they > /should/ be :) eg > > before(:all) do Try before(:each) instead. Read the warning at the bottom of http://rspec.info/documentation/before_and_after.html. Cheers, David > [@matt_applying_for_it, @matt, @it_industry].each { |v| puts v.inspect } > end > > it "should ..." do > [@matt_applying_for_it, @matt, @it_industry].each { |v| puts v.inspect } > end > > => > nil > nil > nil > # > # > # > > Is this a bug or expected behavior? > > Thanks, > > Keith > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From dchelimsky at gmail.com Wed Sep 3 09:28:02 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 3 Sep 2008 08:28:02 -0500 Subject: [rspec-users] Speccing the existance of an unchecked checkbox In-Reply-To: <2054A5D2-B86A-4C8A-A032-1E058B8D4101@superinfinite.com> References: <2054A5D2-B86A-4C8A-A032-1E058B8D4101@superinfinite.com> Message-ID: <57c63afe0809030628y2b76f429qfaf2cbbe2d10fed9@mail.gmail.com> On Wed, Sep 3, 2008 at 6:56 AM, Bart Zonneveld wrote: > Hey list, > > I found myself trying to verify there are some non-checked checkboxes in a > template today, and am kinda stumped how to do it :). > A checked checkbox is easy, > have_tag('input[type=checkbox][checked=checked]). But, an unchecked checkbox > hasn't got the checked attribute at all. And as it so happens, I want to > test for a number of checked, and a number of unchecked checkboxes. So, just > testing for input[type=checkbox] would return the number of checked *and* > unchecked checkboxes.. > > any ideas? Let's say you want 10 checked and 5 unchecked. You could do this: response.should have_tag("input[type=checkbox]", 15) response.should have_tag("input[type=checkbox][checked=checked]", 10) It's not perfectly expressive, but a good example name would help: it "should have 15 checkboxes, 10 checked, 5 unchecked" do render "/path/to/file" response.should have_tag("input[type=checkbox]", 15) response.should have_tag("input[type=checkbox][checked=checked]", 10) end WDYT? > bartz > ps: that's prolly the most occurences of 'check' in a single email... > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From loop at superinfinite.com Wed Sep 3 09:31:50 2008 From: loop at superinfinite.com (Bart Zonneveld) Date: Wed, 3 Sep 2008 15:31:50 +0200 Subject: [rspec-users] Speccing the existance of an unchecked checkbox In-Reply-To: <57c63afe0809030628y2b76f429qfaf2cbbe2d10fed9@mail.gmail.com> References: <2054A5D2-B86A-4C8A-A032-1E058B8D4101@superinfinite.com> <57c63afe0809030628y2b76f429qfaf2cbbe2d10fed9@mail.gmail.com> Message-ID: On 3 sep 2008, at 15:28, David Chelimsky wrote: > On Wed, Sep 3, 2008 at 6:56 AM, Bart Zonneveld > wrote: >> Hey list, >> >> I found myself trying to verify there are some non-checked >> checkboxes in a >> template today, and am kinda stumped how to do it :). >> A checked checkbox is easy, >> have_tag('input[type=checkbox][checked=checked]). But, an unchecked >> checkbox >> hasn't got the checked attribute at all. And as it so happens, I >> want to >> test for a number of checked, and a number of unchecked checkboxes. >> So, just >> testing for input[type=checkbox] would return the number of checked >> *and* >> unchecked checkboxes.. >> >> any ideas? > > Let's say you want 10 checked and 5 unchecked. You could do this: > > response.should have_tag("input[type=checkbox]", 15) > response.should have_tag("input[type=checkbox][checked=checked]", 10) > > It's not perfectly expressive, but a good example name would help: > > it "should have 15 checkboxes, 10 checked, 5 unchecked" do > render "/path/to/file" > response.should have_tag("input[type=checkbox]", 15) > response.should have_tag("input[type=checkbox][checked=checked]", 10) > end > > WDYT? Yeah, that's how I ended up doing it. Googled around a bit, and apparently you cannot do something like input[type=checkbox][checked! =checked]. I'll file a ticket for assert_select. thanks, bartz From matt at mattwynne.net Wed Sep 3 09:38:11 2008 From: matt at mattwynne.net (Matt Wynne) Date: Wed, 3 Sep 2008 14:38:11 +0100 Subject: [rspec-users] Speccing the existance of an unchecked checkbox In-Reply-To: References: <2054A5D2-B86A-4C8A-A032-1E058B8D4101@superinfinite.com> <57c63afe0809030628y2b76f429qfaf2cbbe2d10fed9@mail.gmail.com> Message-ID: On 3 Sep 2008, at 14:31, Bart Zonneveld wrote: > > On 3 sep 2008, at 15:28, David Chelimsky wrote: > >> On Wed, Sep 3, 2008 at 6:56 AM, Bart Zonneveld >> wrote: >>> Hey list, >>> >>> I found myself trying to verify there are some non-checked >>> checkboxes in a >>> template today, and am kinda stumped how to do it :). >>> A checked checkbox is easy, >>> have_tag('input[type=checkbox][checked=checked]). But, an >>> unchecked checkbox >>> hasn't got the checked attribute at all. And as it so happens, I >>> want to >>> test for a number of checked, and a number of unchecked >>> checkboxes. So, just >>> testing for input[type=checkbox] would return the number of >>> checked *and* >>> unchecked checkboxes.. >>> >>> any ideas? >> >> Let's say you want 10 checked and 5 unchecked. You could do this: >> >> response.should have_tag("input[type=checkbox]", 15) >> response.should have_tag("input[type=checkbox][checked=checked]", 10) >> >> It's not perfectly expressive, but a good example name would help: >> >> it "should have 15 checkboxes, 10 checked, 5 unchecked" do >> render "/path/to/file" >> response.should have_tag("input[type=checkbox]", 15) >> response.should have_tag("input[type=checkbox][checked=checked]", >> 10) >> end >> >> WDYT? > > Yeah, that's how I ended up doing it. Googled around a bit, and > apparently you cannot do something like input[type=checkbox] > [checked!=checked]. > I'll file a ticket for assert_select. > > thanks, > bartz I guess you could also consider putting response.body into a HPricot object and doing something fancy with that. IIRC, asset_select isn't using HPricot which seems like a shame - I seem to remember barking up this tree myself a few weeks ago... cheers, Matt From dchelimsky at gmail.com Wed Sep 3 09:44:57 2008 From: dchelimsky at gmail.com (David Chelimsky) Date: Wed, 3 Sep 2008 08:44:57 -0500 Subject: [rspec-users] Speccing the existance of an unchecked checkbox In-Reply-To: References: <2054A5D2-B86A-4C8A-A032-1E058B8D4101@superinfinite.com> <57c63afe0809030628y2b76f429qfaf2cbbe2d10fed9@mail.gmail.com> Message-ID: <57c63afe0809030644x19806c69pe9b8b58ee4b94280@mail.gmail.com> On Wed, Sep 3, 2008 at 8:38 AM, Matt Wynne wrote: > On 3 Sep 2008, at 14:31, Bart Zonneveld wrote: > >> >> On 3 sep 2008, at 15:28, David Chelimsky wrote: >> >>> On Wed, Sep 3, 2008 at 6:56 AM, Bart Zonneveld >>> wrote: >>>> >>>> Hey list, >>>> >>>> I found myself trying to verify there are some non-checked checkboxes in >>>> a >>>> template today, and am kinda stumped how to do it :). >>>> A checked checkbox is easy, >>>> have_tag('input[type=checkbox][checked=checked]). But, an unchecked >>>> checkbox >>>> hasn't got the checked attribute at all. And as it so happens, I want to >>>> test for a number of checked, and a number of unchecked checkboxes. So, >>>> just >>>> testing for input[type=checkbox] would return the number of checked >>>> *and* >>>> unchecked checkboxes.. >>>> >>>> any ideas? >>> >>> Let's say you want 10 checked and 5 unchecked. You could do this: >>> >>> response.should have_tag("input[type=checkbox]", 15) >>> response.should have_tag("input[type=checkbox][checked=checked]", 10) >>> >>> It's not perfectly expressive, but a good example name would help: >>> >>> it "should have 15 checkboxes, 10 checked, 5 unchecked" do >>> render "/path/to/file" >>> response.should have_tag("input[type=checkbox]", 15) >>> response.should have_tag("input[type=checkbox][checked=checked]", 10) >>> end >>> >>> WDYT? >> >> Yeah, that's how I ended up doing it. Googled around a bit, and apparently >> you cannot do something like input[type=checkbox][checked!=checked]. >> I'll file a ticket for assert_select. >> >> thanks, >> bartz > > I guess you could also consider putting response.body into a HPricot object > and doing something fancy with that. > > IIRC, asset_select isn't using HPricot which seems like a shame - I seem to > remember barking up this tree myself a few weeks ago... You might be interested in this: http://github.com/pd/rspec_hpricot_matchers > > cheers, > Matt > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > From patrickdavidreiner at gmail.com Wed Sep 3 10:22:20 2008 From: patrickdavidreiner at gmail.com (patrick_r) Date: Wed, 3 Sep 2008 07:22:20 -0700 (PDT) Subject: [rspec-users] Setting instance variables for controllers Message-ID: <19283500.post@talk.nabble.com> Hi everyone, I have been trying to find an answer to this question and have not been able to. Any help is greatly appreciated. I am using Rails 2.1.0 and Rspec 1.1.4. How can I set an instance variable in my Rspec test that is then available to my controller while the test is running? For example: (I tried to keep this as simple as possible while illustrating what I mean) ---application_controller.rb--- ApplicationController before_filter :set_user def set_user @user = User.find( 5 ) end end ---cart_controller.rb--- CartController def index if @user render :action => 'cart_full' else render :action => 'cart_empty' end end end ---Rspec--- describe CartController do describe "index" do it "should render 'cart_full' if @user is set" do # This is where I need to set @user response.should render_template( : cart_full ) end it "should render 'cart_empty' if @user is not set" do response.should render_template( : cart_empty ) end end end Is this even possible to do? I thought that controller.set_instance_variable( :@user, ... ) would do the trick but it does not seem to work. Thank you! -- View this message in context: http://www.nabble.com/Setting-instance-variables-for-controllers-tp19283500p19283500.html Sent from the rspec-users mailing list archive at Nabble.com. From mauricio.linhares at gmail.com Wed Sep 3 10:40:51 2008 From: mauricio.linhares at gmail.com (=?ISO-8859-1?Q?Maur=EDcio_Linhares?=) Date: Wed, 3 Sep 2008 11:40:51 -0300 Subject: [rspec-users] Setting instance variables for controllers In-Reply-To: <19283500.post@talk.nabble.com> References: <19283500.post@talk.nabble.com> Message-ID: You don't need to set the instance variable, you can stub the find call: describe CartController do describe "index" do before do @user = mock_model( User ) end it "should render 'cart_full' if @user is set" do # This is where I need to set @user User.stub!( :find ).with('your-id-param-here').and_return( @user ) response.should render_template( : cart_full ) end it "should render 'cart_empty' if @user is not set" do response.should render_template( : cart_empty ) end end end On Wed, Sep 3, 2008 at 11:22 AM, patrick_r wrote: > > Hi everyone, > > I have been trying to find an answer to this question and have not been able > to. Any help is greatly appreciated. > > I am using Rails 2.1.0 and Rspec 1.1.4. > > How can I set an instance variable in my Rspec test that is then available > to my controller while the test is running? For example: > > (I tried to keep this as simple as possible while illustrating what I mean) > > > ---application_controller.rb--- > > ApplicationController > > before_filter :set_user > > def set_user > @user = User.find( 5 ) > end > > end > > > ---cart_controller.rb--- > > CartController > > def index > if @user > render :action => 'cart_full' > else > render :action => 'cart_empty' > end > end > > end > > > ---Rspec--- > > describe CartController do > > describe "index" do > > it "should render 'cart_full' if @user is set" do > # This is where I need to set @user > response.should render_template( : cart_full ) > end > > it "should render 'cart_empty' if @user is not set" do > response.should render_template( : cart_empty ) > end > > end > > end > > > > Is this even possible to do? > > I thought that controller.set_instance_variable( :@user, ... ) would do the > trick but it does not seem to work. > > Thank you! > -- > View this message in context: http://www.nabble.com/Setting-instance-variables-for-controllers-tp19283500p19283500.html > Sent from the rspec-users mailing list archive at Nabble.com. > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > -- Maur?cio Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) Jo?o Pessoa, PB, +55 83 8867-7208 From mailing_lists at railsnewbie.com Wed Sep 3 10:53:14 2008 From: mailing_lists at railsnewbie.com (Scott Taylor) Date: Wed, 3 Sep 2008 10:53:14 -0400 Subject: [rspec-users] Setting instance variables for controllers In-Reply-To: References: <19283500.post@talk.nabble.com> Message-ID: <5465D3C1-DD49-4600-BE40-BF9B3DCBBFBF@railsnewbie.com> On Sep 3, 2008, at 10:40 AM, Maur?cio Linhares wrote: > You don't need to set the instance variable, you can stub the find > call: Or you could also stub the call to User::find. Also - you don't *WANT* to set the instance variable - it's an encapsulation violation - there is nothing in the public interface about it. Remember, these are not only specs, but *examples*. Would you want someone writing production code modeled off of that spec? Scott From jonathan at parkerhill.com Wed Sep 3 11:29:39 2008 From: jonathan at parkerhill.com (Jonathan Linowes) Date: Wed, 3 Sep 2008 11:29:39 -0400 Subject: [rspec-users] Setting instance variables for controllers In-Reply-To: <5465D3C1-DD49-4600-BE40-BF9B3DCBBFBF@railsnewbie.com> References: <19283500.post@talk.nabble.com> <5465D3C1-DD49-4600-BE40-BF9B3DCBBFBF@railsnewbie.com> Message-ID: <86C1B2EE-81BF-46AC-82EA-65160DC72CDB@parkerhill.com> On Sep 3, 2008, at 10:53 AM, Scott Taylor wrote: > > On Sep 3, 2008, at 10:40 AM, Maur?cio Linhares wrote: > >> You don't need to set the instance variable, you can stub the find >> call: > > > Or you could also stub the call to User::find. > > Also - you don't *WANT* to set the instance variable - it's an > encapsulation violation - there is nothing in the public interface > about it. Remember, these are not only specs, but *examples*. > Would you want someone writing production code modeled off of that > spec? > > Scott Often I'll encapsulate important instance variables (especially ones assigned in before_filters) in a method, like current_user, current_project, etc. def current_project @project end Then these are easily stubbed in specs. controller.stub!(:current_project).and_return(project) Further, I usually mock the entire before_filter methods before_filter :find_project with a shared method like def mock_find_project project = @project || mock_project controller.stub!(:find_project).and_return(project) controller.stub!(:current_project).and_return(project) project end Lastly, I maintain the find_project method in application.rb so it can be shared among controllers, and tested separately. (either with shared behaviors, or in my case i've rigged up an application_controller_spec that lets me test methods in application.rb independent of a specific controller). --linoj > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users From zach.dennis at gmail.com Wed Sep 3 12:06:54 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 3 Sep 2008 12:06:54 -0400 Subject: [rspec-users] webrat question, form without buttons Message-ID: <85d99afe0809030906w662b4a58o9565faab0b39bb85@mail.gmail.com> Can you submit a form that has no submit button/image? -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From nick at deadorange.com Wed Sep 3 12:40:37 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 3 Sep 2008 12:40:37 -0400 Subject: [rspec-users] webrat question, form without buttons In-Reply-To: <85d99afe0809030906w662b4a58o9565faab0b39bb85@mail.gmail.com> References: <85d99afe0809030906w662b4a58o9565faab0b39bb85@mail.gmail.com> Message-ID: <9BA1CFB0-E3DD-4F6E-A1D2-25DD7FC222E9@deadorange.com> On 2008-09-03, at 12:06, Zach Dennis wrote: > Can you submit a form that has no submit button/image? You can submit a form using Javascript. From zach.dennis at gmail.com Wed Sep 3 13:15:48 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 3 Sep 2008 13:15:48 -0400 Subject: [rspec-users] webrat question, form without buttons In-Reply-To: <9BA1CFB0-E3DD-4F6E-A1D2-25DD7FC222E9@deadorange.com> References: <85d99afe0809030906w662b4a58o9565faab0b39bb85@mail.gmail.com> <9BA1CFB0-E3DD-4F6E-A1D2-25DD7FC222E9@deadorange.com> Message-ID: <85d99afe0809031015w5019396as827e5d88aa6fca64@mail.gmail.com> On Wed, Sep 3, 2008 at 12:40 PM, Nick Hoffman wrote: > On 2008-09-03, at 12:06, Zach Dennis wrote: >> >> Can you submit a form that has no submit button/image? > > You can submit a form using Javascript. That's why we don't have submit buttons. =) But in the context of webrat, if there is a form w/o a submit button, how can you submit it? Obviossly, clicks_button doesn't work anymore. Thanks, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From nick at deadorange.com Wed Sep 3 13:31:43 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 3 Sep 2008 13:31:43 -0400 Subject: [rspec-users] webrat question, form without buttons In-Reply-To: <85d99afe0809031015w5019396as827e5d88aa6fca64@mail.gmail.com> References: <85d99afe0809030906w662b4a58o9565faab0b39bb85@mail.gmail.com> <9BA1CFB0-E3DD-4F6E-A1D2-25DD7FC222E9@deadorange.com> <85d99afe0809031015w5019396as827e5d88aa6fca64@mail.gmail.com> Message-ID: <65186687-35DE-4622-920B-E27ACF957CB0@deadorange.com> On 2008-09-03, at 13:15, Zach Dennis wrote: > On Wed, Sep 3, 2008 at 12:40 PM, Nick Hoffman > wrote: >> You can submit a form using Javascript. > > That's why we don't have submit buttons. =) > > But in the context of webrat, if there is a form w/o a submit button, > how can you submit it? Obviossly, clicks_button doesn't work anymore. > Thanks, During regular use in a browser, how is your form submitted? From zach.dennis at gmail.com Wed Sep 3 13:38:06 2008 From: zach.dennis at gmail.com (Zach Dennis) Date: Wed, 3 Sep 2008 13:38:06 -0400 Subject: [rspec-users] webrat question, form without buttons In-Reply-To: <65186687-35DE-4622-920B-E27ACF957CB0@deadorange.com> References: <85d99afe0809030906w662b4a58o9565faab0b39bb85@mail.gmail.com> <9BA1CFB0-E3DD-4F6E-A1D2-25DD7FC222E9@deadorange.com> <85d99afe0809031015w5019396as827e5d88aa6fca64@mail.gmail.com> <65186687-35DE-4622-920B-E27ACF957CB0@deadorange.com> Message-ID: <85d99afe0809031038s1ba2b856w8cf32a3782305452@mail.gmail.com> On Wed, Sep 3, 2008 at 1:31 PM, Nick Hoffman wrote: > On 2008-09-03, at 13:15, Zach Dennis wrote: >> >> On Wed, Sep 3, 2008 at 12:40 PM, Nick Hoffman wrote: >>> >>> You can submit a form using Javascript. >> >> That's why we don't have submit buttons. =) >> >> But in the context of webrat, if there is a form w/o a submit button, >> how can you submit it? Obviossly, clicks_button doesn't work anymore. >> Thanks, > > During regular use in a browser, how is your form submitted? > When the user clicks a button, but all of the handy dandy work is done in unobtrusive-style javascript. It's not a submit button. It's a CSS-made button with listeners attached, -- Zach Dennis http://www.continuousthinking.com http://www.mutuallyhuman.com From nick at deadorange.com Wed Sep 3 13:51:58 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 3 Sep 2008 13:51:58 -0400 Subject: [rspec-users] webrat question, form without buttons In-Reply-To: <85d99afe0809031038s1ba2b856w8cf32a3782305452@mail.gmail.com> References: <85d99afe0809030906w662b4a58o9565faab0b39bb85@mail.gmail.com> <9BA1CFB0-E3DD-4F6E-A1D2-25DD7FC222E9@deadorange.com> <85d99afe0809031015w5019396as827e5d88aa6fca64@mail.gmail.com> <65186687-35DE-4622-920B-E27ACF957CB0@deadorange.com> <85d99afe0809031038s1ba2b856w8cf32a3782305452@mail.gmail.com> Message-ID: <8AF91C19-1BE7-4ED1-86AA-F5B29AF90DC2@deadorange.com> On 2008-09-03, at 13:38, Zach Dennis wrote: > When the user clicks a button, but all of the handy dandy work is done > in unobtrusive-style javascript. It's not a submit button. It's a > CSS-made button with listeners attached, I'm afraid I can't be of much help with that. I've barely used Webrat. Sorry, mate! From nick at deadorange.com Wed Sep 3 13:57:00 2008 From: nick at deadorange.com (Nick Hoffman) Date: Wed, 3 Sep 2008 13:57:00 -0400 Subject: [rspec-users] Writing specs for a module Message-ID: <6FE71575-D33E-4E57-8FE6-A6BC881E0D3E@deadorange.com> I'm writing specs for a module for my Rails app. The module will live in lib/ . For now, I've created the directory spec/lib/ to store the specs for files in lib/ . However, I'm curious to know if there's a currently accepted location in which to store these types of specs. Thanks, Nick From pergesu at gmail.com Wed Sep 3 14:26:55 2008 From: pergesu at gmail.com (Pat Maddox) Date: Wed, 3 Sep 2008 14:26:55 -0400 Subject: [rspec-users] Writing specs for a module In-Reply-To: <6FE71575-D33E-4E57-8FE6-A6BC881E0D3E@deadorange.com> References: <6FE71575-D33E-4E57-8FE6-A6BC881E0D3E@deadorange.com> Message-ID: <810a540e0809031126o7ee5eacdw1762b0758500fac8@mail.gmail.com> On Wed, Sep 3, 2008 at 1:57 PM, Nick Hoffman wrote: > I'm writing specs for a module for my Rails app. The module will live in > lib/ . For now, I've created the directory spec/lib/ to store the specs for > files in lib/ . However, I'm curious to know if there's a currently accepted > location in which to store these types of specs. That's where I put them. Pat From patrickdavidreiner at gmail.com Wed Sep 3 15:12:02 2008 From: patrickdavidreiner at gmail.com (patrick_r) Date: Wed, 3 Sep 2008 12:12:02 -0700 (PDT) Subject: [rspec-users] Setting instance variables for controllers In-Reply-To: <19283500.post@talk.nabble.com> References: <19283500.post@talk.nabble.com> Message-ID: <19295990.post@talk.nabble.com> Thank you very much for all your help, this made everything crystal clear! -- View this message in context: http://www.nabble.com/Setting-instance-variables-for-controllers-tp19283500p19295990.html Sent from the rspec-users mailing list archive at Nabble.com. From jarkko at jlaine.net Wed Sep 3 16:55:52 2008 From: jarkko at jlaine.net (Jarkko Laine) Date: Wed, 3 Sep 2008 22:55:52 +0200 Subject: [rspec-users] webrat question, form without buttons In-Reply-To: <85d99afe0809031038s1ba2b856w8cf32a3782305452@mail.gmail.com> References: <85d99afe0809030906w662b4a58o9565faab0b39bb85@mail.gmail.com> <9BA1CFB0-E3DD-4F6E-A1D2-25DD7FC222E9@deadorange.com> <85d99afe0809031015w5019396as827e5d88aa6fca64@mail.gmail.com> <65186687-35DE-4622-920B-E27ACF957CB0@deadorange.com> <85d99afe0809031038s1ba2b856w8cf32a3782305452@mail.gmail.com> Message-ID: On 3.9.2008, at 19.38, Zach Dennis wrote: > On Wed, Sep 3, 2008 at 1:31 PM, Nick Hoffman > wrote: >> On 2008-09-03, at 13:15, Zach Dennis wrote: >>> >>> On Wed, Sep 3, 2008 at 12:40 PM, Nick Hoffman >>> wrote: >>>> >>>> You can submit a form using Javascript. >>> >>> That's why we don't have submit buttons. =) >>> >>> But in the context of webrat, if there is a form w/o a submit >>> button, >>> how can you submit it? Obviossly, clicks_button doesn't work >>> anymore. >>> Thanks, >> >> During regular use in a browser, how is your form submitted? >> > > When the user clicks a button, but all of the handy dandy work is done > in unobtrusive-style javascript. It's not a submit button. It's a > CSS-made button with listeners attached, If you're going unobtrusive, why not go all the way and have a real submit button there that gets replaced by the javascript with your custom button? //jarkko -- Jarkko Laine http://jlaine.net http://dotherightthing.com http://www.railsecommerce.com http://odesign.fi From ben at benmabey.com Wed Sep 3 18:21:58 2008 From: ben at benmabey.com (Ben Mabey) Date: Wed, 03 Sep 2008 16:21:58 -0600 Subject: [rspec-users] webrat question, form without buttons In-Reply-To: References: <85d99afe0809030906w662b4a58o9565faab0b39bb85@mail.gmail.com> <9BA1CFB0-E3DD-4F6E-A1D2-25DD7FC222E9@deadorange.com> <85d99afe0809031015w5019396as827e5d88aa6fca64@mail.gmail.com> <65186687-35DE-4622-920B-E27ACF957CB0@deadorange.com> <85d99afe0809031038s1ba2b856w8cf32a3782305452@mail.gmail.com> Message-ID: <48BF0E06.8000207@benmabey.com> Jarkko Laine wrote: > > On 3.9.2008, at 19.38, Zach Dennis wrote: > >> On Wed, Sep 3, 2008 at 1:31 PM, Nick Hoffman >> wrote: >>> On 2008-09-03, at 13:15, Zach Dennis wrote: >>>> >>>> On Wed, Sep 3, 2008 at 12:40 PM, Nick Hoffman >>>> wrote: >>>>> >>>>> You can submit a form using Javascript. >>>> >>>> That's why we don't have submit buttons. =) >>>> >>>> But in the context of webrat, if there is a form w/o a submit button, >>>> how can you submit it? Obviossly, clicks_button doesn't work anymore. >>>> Thanks, >>> >>> During regular use in a browser, how is your form submitted? >>> >> >> When the user clicks a button, but all of the handy dandy work is done >> in unobtrusive-style javascript. It's not a submit button. It's a >> CSS-made button with listeners attached, > > If you're going unobtrusive, why not go all the way and have a real > submit button there that gets replaced by the javascript with your > custom button? +1 In fact that is really,IMO, what unobtrusive JS means. People without JS should still have buttons and can use the site, they just don't get all the pretty colors. If you don't want to hide it with JS you could also just embed the buttons within