[rspec-users] features and form filling - going declarative?

2008-11-06 Thread Andrew Premdas
I'm working on writing features for a wizard. The wizard collects information from a number of different forms, and you can navigate through it in a number of ways. Anyhow one of these forms is a customer form collecting name, and email. In the context of the wizard I feel that the following scena

Re: [rspec-users] rake features and cucumber feature/name not producing same result

2008-11-06 Thread Mikel Lindsaar
On Thu, Nov 6, 2008 at 11:28 PM, Joseph Wilk <[EMAIL PROTECTED]>wrote: > If you are using cucumber with rails and used the rails generator you > should find in your generated features/steps/env.rb file (In the latest > cucumber version 0.1.9 this is in features/support/env.rb): > Yes, I was alre

Re: [rspec-users] Hash / params causing errors

2008-11-06 Thread Ramon Tayag
A bit dryer: ... @params = { "login" => "loginator", "email" => "[EMAIL PROTECTED]" } ... User.should_receive(:new).with(@params).and_return(@user) ... Ramon Tayag ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listi

Re: [rspec-users] Hash / params causing errors

2008-11-06 Thread Ramon Tayag
Thanks for you reply. With what you said I ended up doing this before do @user = mock_model(User, :to_param => "1", :login => "loginator", :email => "[EMAIL PROTECTED]", :save! => true) User.stub!(:new).and_return(@user) @params = { :login => "loginator", :email => "[EMAIL PROTECTED

Re: [rspec-users] Hash / params causing errors

2008-11-06 Thread David Chelimsky
On Thu, Nov 6, 2008 at 9:53 PM, Ramon Tayag <[EMAIL PROTECTED]> wrote: > Hey everyone, > > I'm trying to spec a controller and I can't seem to get a test to pass > because rspec seems to see the difference between params I expect and > params that I pass. However, this comes from the same params >

[rspec-users] Hash / params causing errors

2008-11-06 Thread Ramon Tayag
Hey everyone, I'm trying to spec a controller and I can't seem to get a test to pass because rspec seems to see the difference between params I expect and params that I pass. However, this comes from the same params variable. What should I do to get this to work? Spec::Mocks::MockExpectationErr

Re: [rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)

2008-11-06 Thread Mark Wilden
> i run "rake spec --trace" That's not running anything twice, I think. "Invoke" is printed when the task is called, then the tasks it depends on are invoked, then the task is executed. The environment task is invoked several times, but it's only actually executed once. /// On Thu, Nov 6, 2008 a

Re: [rspec-users] cucumber docs

2008-11-06 Thread Tim Walker
Thank you very much Aslak. That looks great. FWIW I have taught a class "Executable Requirements with FitNesse" as the director of training and coaching at Valtech and on the faculty of agile university. I went back to a real job recently and am now employed on a new enterprise class RoR project as

Re: [rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)

2008-11-06 Thread Greg Hauptmann
i run "rake spec --trace" On 11/6/08, Greg Hauptmann <[EMAIL PROTECTED]> wrote: > anyone able to explain logic behind "rake spec" startup? i.e. the > below steps & why things occur when they do > > Macintosh-2:myequity greg$ rake spec --trace > (in /Users/greg/source/myequity) > ** Invoke spec (fi

Re: [rspec-users] Specing based on user roles

2008-11-06 Thread David Chelimsky
On Thu, Nov 6, 2008 at 4:52 PM, Pat Maddox <[EMAIL PROTECTED]> wrote: > Fernando Perez <[EMAIL PROTECTED]> writes: > >>> And why wouldn't you want to test that? >>> >> I want to test for it, it's just that I don't want to copy/paste spec >> like an idiot. >> >> >>> def for_roles *roles >>> roles.

Re: [rspec-users] cucumber docs

2008-11-06 Thread aslak hellesoy
On Thu, Nov 6, 2008 at 11:51 PM, Tim Walker <[EMAIL PROTECTED]> wrote: > Thanks guys, I may have overlooked some of the stuff there. A lot of > what I was looking for was in the "Step Organization" page. > > Still not clear on some of the dynamic substitutions and syntax, etc. > I just jotted down

Re: [rspec-users] cucumber docs

2008-11-06 Thread Tim Walker
Thanks guys, I may have overlooked some of the stuff there. A lot of what I was looking for was in the "Step Organization" page. Still not clear on some of the dynamic substitutions and syntax, etc. Thanks, Tim On Thu, Nov 6, 2008 at 3:22 PM, Joseph Wilk <[EMAIL PROTECTED]> wrote: > I suggest y

Re: [rspec-users] cucumber docs

2008-11-06 Thread Tim Walker
Yes, thank you very much. Not too much there. I had seen a blog post where Aslak mentioned he'd worked some on the documentation so thought I was missing the 1000 page tome "Cucumbers: Sometimes quality is long and green..." Thanks, Tim On Thu, Nov 6, 2008 at 3:05 PM, Ben Mabey <[EMAIL PROTECTED

Re: [rspec-users] cucumber docs

2008-11-06 Thread Joseph Wilk
I suggest you checkout the wiki that Cucumber has on Github . http://github.com/aslakhellesoy/cucumber/wikis Lots of useful information. HTH -- Joseph Wilk http://www.joesniff.co.uk On Thu, Nov 6, 2008 at 9:30 PM, Tim Walker <[EMAIL PROTECTED]> wrote: > Hi all, > > What is the best source for

Re: [rspec-users] Verifying some understanding about manipulating DB data in before/after callbacks in RSpec

2008-11-06 Thread Wes Gamble
Stephen Eley wrote: On Thu, Nov 6, 2008 at 4:32 PM, Wes Gamble <[EMAIL PROTECTED]> wrote: Attempting to manipulate data directly in the DB in a before/after callback doesn't make sense since those changes will not persist across tests because of the transactionality implied by "self.use_trans

Re: [rspec-users] Verifying some understanding about manipulating DB data in before/after callbacks in RSpec

2008-11-06 Thread Mark Wilden
On Thu, Nov 6, 2008 at 1:32 PM, Wes Gamble <[EMAIL PROTECTED]> wrote: > We had an after(:each) callback that looked like this: > > PurchaseOrder.find(:all).each {|po| > DraftInvoice.find_all_by_po_number(po.po_number).each {|di| di.destroy}} > > which we were hoping would reset some purchase orde

Re: [rspec-users] cucumber docs

2008-11-06 Thread Ben Mabey
Tim Walker wrote: Hi all, What is the best source for cucumber documentation. I did the rdoc thing but that was more of the API view. Is there any usage guides, etc. besides the examples and what you get when you download it or is the documentation hidden in there and I just didn't see it. Many

Re: [rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)

2008-11-06 Thread Mark Wilden
On Thu, Nov 6, 2008 at 1:07 PM, Greg Hauptmann < [EMAIL PROTECTED]> wrote: > I'm still a bit confused - I'll try to be more specific in questions: > > * rake db:test:prepare - Check for pending migrations and load the test > schema > ==> Q1. DOES NOT RUN IN PENDING MIGRATIONS TO TEST DATABASE? >

Re: [rspec-users] Verifying some understanding about manipulating DB data in before/after callbacks in RSpec

2008-11-06 Thread Stephen Eley
On Thu, Nov 6, 2008 at 4:32 PM, Wes Gamble <[EMAIL PROTECTED]> wrote: > > Attempting to manipulate data directly in the DB in a before/after callback > doesn't make sense since those changes will not persist across tests because > of the transactionality implied by "self.use_transactional_fixtures

Re: [rspec-users] Specing based on user roles

2008-11-06 Thread Pat Maddox
Fernando Perez <[EMAIL PROTECTED]> writes: >> And why wouldn't you want to test that? >> > I want to test for it, it's just that I don't want to copy/paste spec > like an idiot. > > >> def for_roles *roles >> roles.each do |role| >> before(:each) { login_as role } >> yield >> end >> e

[rspec-users] cucumber docs

2008-11-06 Thread Tim Walker
Hi all, What is the best source for cucumber documentation. I did the rdoc thing but that was more of the API view. Is there any usage guides, etc. besides the examples and what you get when you download it or is the documentation hidden in there and I just didn't see it. Many thanks in advance!

[rspec-users] Verifying some understanding about manipulating DB data in before/after callbacks in RSpec

2008-11-06 Thread Wes Gamble
We had an after(:each) callback that looked like this: PurchaseOrder.find(:all).each {|po| DraftInvoice.find_all_by_po_number(po.po_number).each {|di| di.destroy}} which we were hoping would reset some purchase order data in a certain way. However, because we have "self.use_transactional_fix

Re: [rspec-users] Specing based on user roles

2008-11-06 Thread Fernando Perez
> And why wouldn't you want to test that? > I want to test for it, it's just that I don't want to copy/paste spec like an idiot. > def for_roles *roles > roles.each do |role| > before(:each) { login_as role } > yield > end > end > > describe OrdersController do > describe "GET in

Re: [rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)

2008-11-06 Thread Greg Hauptmann
I'm still a bit confused - I'll try to be more specific in questions: * rake db:test:prepare - Check for pending migrations and load the test schema ==> Q1. DOES NOT RUN IN PENDING MIGRATIONS TO TEST DATABASE? ==> Q2. RE TEST SCHEMA - ARE THE MIGRATIONS USE TO CREATE THE DATABASE OR THE DEVELO

Re: [rspec-users] mocking named_scope utilization

2008-11-06 Thread Pat Maddox
"Chris Flipse" <[EMAIL PROTECTED]> writes: > I dunno ... creating a bunch of joining methods seems to be an awfully > disjoint way to deal with something that is, admittedly, designed to > laugh in the face of the Law of Demeter. > > I've been handling chains through some heavy use of null_object

Re: [rspec-users] Testing variables in controllers?

2008-11-06 Thread Ramon Tayag
Cool thanks Fernando, Matt, Nick - it seems like I haven't made my models fat enough. That seems to be the answer :) Ramon Tayag On Fri, Nov 7, 2008 at 12:50 AM, Nick Hoffman <[EMAIL PROTECTED]> wrote: > On 2008-11-06, at 09:36, Ramon Tayag wrote: >> >> How do you test that your controller fet

Re: [rspec-users] Caboosers drop RSpec

2008-11-06 Thread Matt Wynne
On 6 Nov 2008, at 00:18, Pat Maddox wrote: Chuck Norris protects my computer from meteors and all other catastrophes. I don't need no stinkin' time machine. Chuck Norris can travel through time. Chuck Norris invented time. ___ rspec-users mailing lis

Re: [rspec-users] Testing variables in controllers?

2008-11-06 Thread Nick Hoffman
On 2008-11-06, at 09:36, Ramon Tayag wrote: How do you test that your controller fetched the right records? I have an action that returns a different set of records based on whether or not the current_user is the "owner" of the profile being viewed. Code is here http://pastie.org/308685. "cont

Re: [rspec-users] how to avoid tests removing data that my migrations put in?

2008-11-06 Thread Pat Maddox
Oh, I guess it makes sense that it wouldn't work there. The stuff in test.rb is run as part of the initializer block, meaning that Rails hasn't been set up yet there. I would just stick it all in spec_helper.rb. That's what I do and was my initial instinct, because it keeps all the test setup in

Re: [rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)

2008-11-06 Thread Mark Wilden
On Thu, Nov 6, 2008 at 7:31 AM, Matt Wynne <[EMAIL PROTECTED]> wrote: > If you want to speed things up, just run spec spec. That will work fine > unless you have pending migrations that affect your specs. Or if you have migrations that were applied to the dev db, but you haven't run db:test:pre

Re: [rspec-users] Specing based on user roles

2008-11-06 Thread Mark Wilden
Mark Wilden to rspec-users show details 7:46 AM (0 minutes ago) Reply - Show quoted text - On Thu, Nov 6, 2008 at 7:02 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: > On my website each user can have the following roles: > > 1) Not logged in > > 2) Logged in > - active > - administrator > - sy

Re: [rspec-users] Testing variables in controllers?

2008-11-06 Thread Matt Wynne
woah! You're exposing way too much of your model here, IMO. That is forcing you to do all that noisy mocking setup in your before block. Can you make a method on your user object like User#valid_submissions and have that return the correct submissions? How do you know whether the user is

Re: [rspec-users] Specing based on user roles

2008-11-06 Thread David Chelimsky
On Thu, Nov 6, 2008 at 10:02 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: > On my website each user can have the following roles: > > 1) Not logged in > > 2) Logged in > - active > - administrator > - sysadministrator > > > > How would you write DRY specs to test each action of a controller? >

Re: [rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)

2008-11-06 Thread Mark Wilden
On Thu, Nov 6, 2008 at 4:01 AM, Hongli Lai <[EMAIL PROTECTED]> wrote: > >> > > 'spec' depends on 'db:test:prepare'. 'db:test:prepare' runs any pending > migrations on your development database, and copies the schema structure to > the test database. This is to keep the development database's stru

Re: [rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)

2008-11-06 Thread Matt Wynne
If you want to speed things up, just run spec spec. That will work fine unless you have pending migrations that affect your specs. On 6 Nov 2008, at 12:01, Hongli Lai wrote: Greg Hauptmann wrote: anyone able to explain logic behind "rake spec" startup? i.e. the below steps & why things occur

Re: [rspec-users] Parsing Variables from the RakeFile to spec_helper

2008-11-06 Thread Mark Wilden
On Thu, Nov 6, 2008 at 5:59 AM, Togetherne Togetherne <[EMAIL PROTECTED]>wrote: > If i create a seperate rake task for each how would i chain them togethr > to run 1 after eachother? > Make a dependency chain. task3 depends on task2 which depends on task1. ///ark ___

Re: [rspec-users] Specing based on user roles

2008-11-06 Thread Mark Wilden
On Thu, Nov 6, 2008 at 7:02 AM, Fernando Perez <[EMAIL PROTECTED]> wrote: > On my website each user can have the following roles: > > 1) Not logged in > > 2) Logged in > - active > - administrator > - sysadministrator > > > > How would you write DRY specs to test each action of a controller? >

Re: [rspec-users] Testing variables in controllers?

2008-11-06 Thread Fernando Perez
Ramon Tayag wrote: > How do you test that your controller fetched the right records? > > I have an action that returns a different set of records based on > whether or not the current_user is the "owner" of the profile being > viewed. > > Code is here http://pastie.org/308685. > > "controller.su

[rspec-users] Testing variables in controllers?

2008-11-06 Thread Ramon Tayag
How do you test that your controller fetched the right records? I have an action that returns a different set of records based on whether or not the current_user is the "owner" of the profile being viewed. Code is here http://pastie.org/308685. "controller.submissions.size.should == 1" makes sen

[rspec-users] Specing based on user roles

2008-11-06 Thread Fernando Perez
On my website each user can have the following roles: 1) Not logged in 2) Logged in - active - administrator - sysadministrator How would you write DRY specs to test each action of a controller? Currently I am doing somethings that looks like: -- describe 'a non admin is signed in', :share

Re: [rspec-users] Parsing Variables from the RakeFile to spec_helper

2008-11-06 Thread Togetherne Togetherne
David Chelimsky wrote: > Why not create different tasks? There's a few ways you can handle that > and keep control from the command line. Thanks for the reply, i have managed i think to get half way there!!: @environment = ["*iehta", "*chrome"] @environment.each {|browse| desc("Run all tests in

Re: [rspec-users] Parsing Variables from the RakeFile to spec_helper

2008-11-06 Thread David Chelimsky
On Thu, Nov 6, 2008 at 4:52 AM, Togetherne Togetherne <[EMAIL PROTECTED]> wrote: > Is this possible, i basically want to create a loop in my Rakefile which > updates a variable in my spec file with every run the variable is > something like: > > browser = ENV['SELENIUM_RC_BROWSER'] || "*chrome" >

Re: [rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)

2008-11-06 Thread Hongli Lai
Greg Hauptmann wrote: anyone able to explain logic behind "rake spec" startup? i.e. the below steps & why things occur when they do Macintosh-2:myequity greg$ rake spec --trace (in /Users/greg/source/myequity) ** Invoke spec (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_

Re: [rspec-users] When is spec_helper.rb actually executed?

2008-11-06 Thread Greg Hauptmann
can someone advise how best to handle the situation where I want to keep (i.e. not have deleted) my configuration intact? Perhaps seed it in environment/test.rb - but how do I get a normal rails line of code to run in the "test.rb" file (i.e. only for when starting up in test mode)? I get "ActiveRe

[rspec-users] Parsing Variables from the RakeFile to spec_helper

2008-11-06 Thread Togetherne Togetherne
Is this possible, i basically want to create a loop in my Rakefile which updates a variable in my spec file with every run the variable is something like: browser = ENV['SELENIUM_RC_BROWSER'] || "*chrome" in my spec_helper i have: def create_selenium_driver remote_control_server = ENV[

Re: [rspec-users] Caboosers drop RSpec

2008-11-06 Thread Pat Maddox
"Mark Wilden" <[EMAIL PROTECTED]> writes: > On Wed, Nov 5, 2008 at 12:39 PM, Stephen Eley <[EMAIL PROTECTED]> wrote: > > My point is that it did not take me days to recover from all this > screwiness. I was using Time Machine. I booted from the Leopard DVD, > said "Make it Wednesday

[rspec-users] anyone able to explain logic behind "rake spec" startup (e.g. db:test:prepare => abort_if_pending_migration => invoke environment => etc etc)

2008-11-06 Thread Greg Hauptmann
anyone able to explain logic behind "rake spec" startup? i.e. the below steps & why things occur when they do Macintosh-2:myequity greg$ rake spec --trace (in /Users/greg/source/myequity) ** Invoke spec (first_time) ** Invoke db:test:prepare (first_time) ** Invoke db:abort_if_pending_migrations (f