Re: [rspec-users] Standardize environment between specs containing class defs

2007-09-21 Thread aslak hellesoy
You can have a global after block in your spec_helper.rb that
undefines all such constants. Then you just have to remember to add
these constants to some global array whenever you define them.

a

On 9/21/07, Matt Margolis [EMAIL PROTECTED] wrote:
 I have some specs that involve the use of eval and class definitions to
 test code generation.  I want to always start with a clean slate so none
 of my tests fail or succeed incorrectly due to artifacts left over from
 previous specs.

 Example of my situation
   Spec 1 defines
 class Fish
 class Cod  Fish
   Spec 2 defines
 class Animal
 class Cod  Animal

 In this situation the second spec will fail since Cod was previously
 defined to be a subclass of Fish and you can not change the superclass
 of a subclass in ruby without causing an exception.

 I want the resetting to be as automatic as possible since calling
 remove_constant on every class my code defines after each spec is a real
 pain since this situation is going to crop up in lots of different specs
 and describe blocks.

 Thank you,
 Matt Margolis
 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


[rspec-users] TextMate Bundle and exception when switching to alternate file.

2007-09-21 Thread Trevor Squires
Hey,

sorry if this is something better suited to another list.

I've encountered a strange problem with the RSpec.tmbundle in trunk -
namely that it was raising an exception when pressing
ctrl-shift-downarrow (switch between spec and source - Alternate
File).

I tracked down the issue to be handling of the file_type in
switch_command.rb#content_for() - the code expected the type string to
be just 'spec' when it can be 'view spec' or 'model spec' etc.

Unfortunately I don't know whether this is just an issue with my local
textmate install or if it is, in fact, a bug.

Here is a diff showing how I solved the problem for myself - if it's
valid across-the-board it would be great if it could be applied to
trunk.

Index: RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb
===
--- RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb  (revision 2607)
+++ RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb  (working copy)
@@ -63,7 +63,7 @@

   def content_for(file_type, relative_path)
 case file_type
-  when 'spec' then
+  when /spec$/ then
 spec(relative_path)
   else
 klass(relative_path)

Thanks for your attention,
Trevor

-- 
--
Trevor Squires
http://somethinglearned.com
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] RSpec view spec writing problem (unable to generate url_for in RESTful resource link_to)

2007-09-21 Thread Lance Carlson
BTW I also tried this:

template.stub!(:edit_label_url).and_return('')

but the same error continues to persist

On 9/21/07, Lance Carlson [EMAIL PROTECTED] wrote:
 BTW I know this is old, but did you know you can do this?

 iink_to a.name, [EMAIL PROTECTED], @project],,{:class=show,:title=Show
  actor details} ?

 I'm having trouble mocking this my view specs right now as it is
 giving me errors, but it works fine in rails edge. I will report on my
 discoveries if anyone has figured out how to deal with this new way to
 call polymorphic path helpers. any takers? My error is as follows:


 1)
 ActionView::TemplateError in 'Label Page should have a link to add a new 
 artist'
 edit_label_url failed to generate from {:action=edit,
 :controller=labels, :id=#Label:0x..fdb3c5798
 @name=Label_1000}, expected: {:controller=labels,
 :action=edit}, diff: {:id=#Label:0x..fdb3c5798
 @name=Label_1000}
 On line #3 of app/views/labels/show.rhtml

 3: %= link_to 'Edit', [ @label, :edit ] %br /

 On 9/10/07, Scott Sehlhorst [EMAIL PROTECTED] wrote:
  Thanks very much.  I feel like a bit of a fool, now, for the odd error.
 
  Changing from:
%=
  link_to(a.name,actor_path(@customer,@project),{:class=show,:title=Show
  actor details}) -%
  To
%=
  link_to(a.name,actor_path(@customer,@project,a),{:class=show,:title=Show
  actor details}) -%
 
  Caused everything to work like a champ.  And uncovered an interesting bug.
  When not specifying the actor 'a', the link is generated (in the page), but
  with id=1.  No idea if/when I would have caught that.
 
  Thanks again David, and all the RSpec'ers out there.
 
  Also, thanks for the multi-nesting pointer.
 
  Scott
 
 
 
  On 9/10/07, David Chelimsky [EMAIL PROTECTED] wrote:
   On 9/10/07, Scott Sehlhorst  [EMAIL PROTECTED] wrote:
Thanks, first, to everyone who's asked and answered questions on this
  list,
and to the creators of RSpec - it is all very helpful.  I've searched
  the
mailing list, and had a couple 2hr googling sessions that didn't help me
find an answer.
   
I've run into a problem getting my first non-trivial view spec to run.
  I
get an error when trying to generate a link_to() to another resource.
  Here
is an overview of the situation, then the code:
   
   
I'm using a restful design
I'm using nested (multiply nested) resources
I am trying to test a show.rhtml view, that includes links (link_to) to
resources managed by another controller
The use_case model has a many-to-may through relationship with actors,
  and
I'm displaying links to the associated actors on the use_case page
I can't get the links to generate when running rspec (but it works great
  in
the app)
I am in the early stages of the project, and want to move forward BDD,
  but I
have some existing code that I need to test before I can start moving
forward again.
My theories:  I need to stub the controller (for the other resource), or
  I
need to stub something else.
   
Here's the command I'm running to drive RSpec
   
 ruby script/spec -f s spec/views
   
Here's the error that I get
   
 1)
ActionView::TemplateError in 'UseCase showing a use case should display
  the
use case identifier'
 actor_url failed to generate from {:customer_id=1,
:controller=actors, :action=show, :project_id=1}, expecte
d: {:controller=actors, :action=show}, diff: {:customer_id=1,
:project_id=1}
On line #22 of app/views/use_cases/show.rhtml
   
19:   ul
 20: % @primary_actors.each do |a| %
21: li
 22:   %=
   
  link_to(a.name,actor_path(@customer,@project),{:class=show,:title=Show
actor details}) -%
23:   %= link_to(Remove
   
  assignment,participation_path(@customer,@project,@use_case.participations.find_by
_actor_id(a)),{:class=delete,:title=Remove the
assignment of this actor to this use case, :confirm = 'Are you sur
e you want to remove this assignment?', :method = :delete})-%
 24: /li
25: % end %
   
   
   
  #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1273:in
`raise_named_route_error'
   
   
  #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/routing.rb:1245:in
`generate'
   
   
  #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:104:in
`rewrite_path'
   
   
  #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb:69:in
`rewrite'
   
   
  #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_controller/base.rb:522:in
`url_for'
   
   
  #{RAILS_ROOT}/vendor/rails/actionpack/lib/action_view/helpers/url_helper.rb:27:in
`url_for'
 (eval):19:in `actor_path'
#{RAILS_ROOT}/app/views/use_cases/show.rhtml:22:in
`_run_rhtml_47app47views47use_cases47show46rhtml'
#{RAILS_ROOT}/app/views/use_cases/show.rhtml:20:in

Re: [rspec-users] given_it

2007-09-21 Thread David Chelimsky
Have you seen shared behaviours?

On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
 Hello,

 Just decided to check whether I am doing something that makes sense
 or not. I was thinking about how cool would it be to re-use examples
 (just like we reuse story scenarios with GivenScenario). I was not
 sure if this possibility already exists in rspec (and, honestly, was
 lazy to check), so I have created this helper:

 def given_it(name)
example_definition = behaviour.example_definitions.find{|i|
 i.description == name }
instance_eval(example_definition.example_block)
 end

 so it is possible to write things like

 it should do something after another action do
given_it should successfully do another action
do_something.should be_fine
 end

 Is there anything already in rspec that allows me to do the same
 stuff? Or was it a bad idea at all?

 Yurii.
 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] TextMate Bundle and exception when switching to alternate file.

2007-09-21 Thread David Chelimsky
Please submit this to the tracker as a patch.

http://rubyforge.org/tracker/index.php?group_id=797

Thanks,
David

On 9/21/07, Trevor Squires [EMAIL PROTECTED] wrote:
 Hey,

 sorry if this is something better suited to another list.

 I've encountered a strange problem with the RSpec.tmbundle in trunk -
 namely that it was raising an exception when pressing
 ctrl-shift-downarrow (switch between spec and source - Alternate
 File).

 I tracked down the issue to be handling of the file_type in
 switch_command.rb#content_for() - the code expected the type string to
 be just 'spec' when it can be 'view spec' or 'model spec' etc.

 Unfortunately I don't know whether this is just an issue with my local
 textmate install or if it is, in fact, a bug.

 Here is a diff showing how I solved the problem for myself - if it's
 valid across-the-board it would be great if it could be applied to
 trunk.

 Index: RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb
 ===
 --- RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb  (revision 
 2607)
 +++ RSpec.tmbundle/Support/lib/spec/mate/switch_command.rb  (working copy)
 @@ -63,7 +63,7 @@

def content_for(file_type, relative_path)
  case file_type
 -  when 'spec' then
 +  when /spec$/ then
  spec(relative_path)
else
  klass(relative_path)

 Thanks for your attention,
 Trevor

 --
 --
 Trevor Squires
 http://somethinglearned.com
 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] given_it

2007-09-21 Thread David Chelimsky
On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
 Sure! But they are not the same stuff. What I was looking for is

 it should do #1 do
   ...
 end
 it should do X after #1 do
   given_it should do #1
   should do_x
 end
 it should do Y after #1 do
   given_it should do #1
   should do_y
 end
 it should do Z after #1 Y do
   given_it should do Y after #1
   should do_z
 end

Sorry mate - that just seems like endless confusion - the examples
should never rely on each other that way - different animal from
scenarios that involve steps.


 Or am I missing somethiing?


 On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote:

  Have you seen shared behaviours?
 
  On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
  Hello,
 
  Just decided to check whether I am doing something that makes sense
  or not. I was thinking about how cool would it be to re-use examples
  (just like we reuse story scenarios with GivenScenario). I was not
  sure if this possibility already exists in rspec (and, honestly, was
  lazy to check), so I have created this helper:
 
  def given_it(name)
 example_definition = behaviour.example_definitions.find{|i|
  i.description == name }
 instance_eval(example_definition.example_block)
  end
 
  so it is possible to write things like
 
  it should do something after another action do
 given_it should successfully do another action
 do_something.should be_fine
  end
 
  Is there anything already in rspec that allows me to do the same
  stuff? Or was it a bad idea at all?
 
  Yurii.
  ___
  rspec-users mailing list
  rspec-users@rubyforge.org
  http://rubyforge.org/mailman/listinfo/rspec-users
 
  ___
  rspec-users mailing list
  rspec-users@rubyforge.org
  http://rubyforge.org/mailman/listinfo/rspec-users

 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] given_it

2007-09-21 Thread Yurii Rashkovskii

 Sure! But they are not the same stuff. What I was looking for is

 it should do #1 do
   ...
 end
 it should do X after #1 do
   given_it should do #1
   should do_x
 end
 it should do Y after #1 do
   given_it should do #1
   should do_y
 end
 it should do Z after #1 Y do
   given_it should do Y after #1
   should do_z
 end

 Sorry mate - that just seems like endless confusion - the examples
 should never rely on each other that way - different animal from
 scenarios that involve steps.

I agree that they should not rely on each other _indirectly_. But why  
they should not _reuse_ each other? I find it very useful for  
testing, say, different aspects of, say, controller's behavior. I  
simply do not want to put all checks into one example, like it should  
do this, this and this and in result we should have this, this and  
that. How do you propose to test different aspects of single actions  
in a nice way?
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] given_it

2007-09-21 Thread lancecarlson
This concept violates oo if you want to test whether or not r method calls 
another method you would do that in the test and label it occordingly. What you 
are defining is such a narrow use case I think it would be abused
Sent via BlackBerry from T-Mobile

-Original Message-
From: David Chelimsky [EMAIL PROTECTED]

Date: Fri, 21 Sep 2007 22:03:30 
To:rspec-users rspec-users@rubyforge.org
Subject: Re: [rspec-users] given_it


On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
 Sure! But they are not the same stuff. What I was looking for is

 it should do #1 do
   ...
 end
 it should do X after #1 do
   given_it should do #1
   should do_x
 end
 it should do Y after #1 do
   given_it should do #1
   should do_y
 end
 it should do Z after #1 Y do
   given_it should do Y after #1
   should do_z
 end

Sorry mate - that just seems like endless confusion - the examples
should never rely on each other that way - different animal from
scenarios that involve steps.


 Or am I missing somethiing?


 On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote:

  Have you seen shared behaviours?
 
  On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
  Hello,
 
  Just decided to check whether I am doing something that makes sense
  or not. I was thinking about how cool would it be to re-use examples
  (just like we reuse story scenarios with GivenScenario). I was not
  sure if this possibility already exists in rspec (and, honestly, was
  lazy to check), so I have created this helper:
 
  def given_it(name)
 example_definition = behaviour.example_definitions.find{|i|
  i.description == name }
 instance_eval(example_definition.example_block)
  end
 
  so it is possible to write things like
 
  it should do something after another action do
 given_it should successfully do another action
 do_something.should be_fine
  end
 
  Is there anything already in rspec that allows me to do the same
  stuff? Or was it a bad idea at all?
 
  Yurii.
  ___
  rspec-users mailing list
  rspec-users@rubyforge.org
  http://rubyforge.org/mailman/listinfo/rspec-users
 
  ___
  rspec-users mailing list
  rspec-users@rubyforge.org
  http://rubyforge.org/mailman/listinfo/rspec-users

 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] given_it

2007-09-21 Thread lancecarlson
If you want to reuse stuff in your tests put those test methods in a separate 
module and include them into you specs
Sent via BlackBerry from T-Mobile

-Original Message-
From: Yurii Rashkovskii [EMAIL PROTECTED]

Date: Fri, 21 Sep 2007 23:12:50 
To:rspec-users rspec-users@rubyforge.org
Subject: Re: [rspec-users] given_it



 Sure! But they are not the same stuff. What I was looking for is

 it should do #1 do
   ...
 end
 it should do X after #1 do
   given_it should do #1
   should do_x
 end
 it should do Y after #1 do
   given_it should do #1
   should do_y
 end
 it should do Z after #1 Y do
   given_it should do Y after #1
   should do_z
 end

 Sorry mate - that just seems like endless confusion - the examples
 should never rely on each other that way - different animal from
 scenarios that involve steps.

I agree that they should not rely on each other _indirectly_. But why  
they should not _reuse_ each other? I find it very useful for  
testing, say, different aspects of, say, controller's behavior. I  
simply do not want to put all checks into one example, like it should  
do this, this and this and in result we should have this, this and  
that. How do you propose to test different aspects of single actions  
in a nice way?
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] given_it

2007-09-21 Thread Yurii Rashkovskii
Then I will have tens of methods that in fact has nothing really  
different from reused examples

On Sep 21, 2007, at 11:14 PM, [EMAIL PROTECTED] wrote:

 If you want to reuse stuff in your tests put those test methods in  
 a separate module and include them into you specs
 Sent via BlackBerry from T-Mobile

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] given_it

2007-09-21 Thread Yurii Rashkovskii
Ok, let me try to explain. I have some controllers that are doing  
some kind of main action and some additional ones. These actions  
are belong to different aspects of logic and thus
I'd prefer to test them separately to have clean and nice code that  
can be easily modified.

Then, what's better to read?

it should do main action do
   do_main_action
end

it should set some value in session if there was no another specific  
value in session before do
   session[:a] = 1
   do_main_action
   session[:b].should == b
end

def do_main_action
   post :create, ...
end

or

it should do main action do
   post :create, ...
end

it should set some value in session if there was no another specific  
value in session before do
   session[:a] = 1
   given_it should do main action
   session[:b].should == b
end

I personally like second one.

P.S. Examples above are surely artificial.



On Sep 21, 2007, at 11:11 PM, [EMAIL PROTECTED] wrote:

 This concept violates oo if you want to test whether or not r  
 method calls another method you would do that in the test and label  
 it occordingly. What you are defining is such a narrow use case I  
 think it would be abused
 Sent via BlackBerry from T-Mobile

 -Original Message-
 From: David Chelimsky [EMAIL PROTECTED]

 Date: Fri, 21 Sep 2007 22:03:30
 To:rspec-users rspec-users@rubyforge.org
 Subject: Re: [rspec-users] given_it


 On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
 Sure! But they are not the same stuff. What I was looking for is

 it should do #1 do
   ...
 end
 it should do X after #1 do
   given_it should do #1
   should do_x
 end
 it should do Y after #1 do
   given_it should do #1
   should do_y
 end
 it should do Z after #1 Y do
   given_it should do Y after #1
   should do_z
 end

 Sorry mate - that just seems like endless confusion - the examples
 should never rely on each other that way - different animal from
 scenarios that involve steps.


 Or am I missing somethiing?


 On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote:

 Have you seen shared behaviours?

 On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
 Hello,

 Just decided to check whether I am doing something that makes sense
 or not. I was thinking about how cool would it be to re-use  
 examples
 (just like we reuse story scenarios with GivenScenario). I was not
 sure if this possibility already exists in rspec (and, honestly,  
 was
 lazy to check), so I have created this helper:

 def given_it(name)
example_definition = behaviour.example_definitions.find{|i|
 i.description == name }
instance_eval(example_definition.example_block)
 end

 so it is possible to write things like

 it should do something after another action do
given_it should successfully do another action
do_something.should be_fine
 end

 Is there anything already in rspec that allows me to do the same
 stuff? Or was it a bad idea at all?

 Yurii.
 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users
 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] given_it

2007-09-21 Thread David Chelimsky
On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
 Then I will have tens of methods that in fact has nothing really
 different from reused examples

But, as methods, they are more clearly differentiated for reuse.

The problem is that if I reuse an example, and then decide to change
that example, I may accidentally change the meaning of other examples.
This is possible w/ helper methods too, but I think it is less likely.

You can keep pursuing this if you like, but I can tell you right now
that it is very likely not going to happen. We already have a few
different ways to deal w/ reuse and this one seems more confusing to
me than helpful.

FWIW,
David


 On Sep 21, 2007, at 11:14 PM, [EMAIL PROTECTED] wrote:

  If you want to reuse stuff in your tests put those test methods in
  a separate module and include them into you specs
  Sent via BlackBerry from T-Mobile
 
 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] given_it

2007-09-21 Thread Dan North

I have to agree with David. (It's in the contract ;)

Scenarios are reusable as steps in order to chain multiple scenarios 
together (to describe the various coarse-grained stages of a workflow, 
state machine or wizard, for example).


At an example level it is just confusing. I've noticed that if I find 
myself wanting to do that, it's an indication that the objects are too 
tightly coupled or dependent on one another. There is usually a cleaner 
abstraction in there waiting to be discovered that will mean you don't 
need to chain examples in this way.


fwiw GivenScenario was introduced into JBehave to work around the 
constraint that scenarios were only allowed to be of the form 
Given/When/Then in the early days. Then we relaxed scenarios to allow 
mixing up steps in any order (given.. when.. then.. when.. then..) which 
made them read much more naturally. GivenScenarios aren't used much now 
other than in the specific situations I described above (state machines, 
etc).


Cheers,
Dan

David Chelimsky wrote:

On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
  

Sure! But they are not the same stuff. What I was looking for is

it should do #1 do
  ...
end
it should do X after #1 do
  given_it should do #1
  should do_x
end
it should do Y after #1 do
  given_it should do #1
  should do_y
end
it should do Z after #1 Y do
  given_it should do Y after #1
  should do_z
end



Sorry mate - that just seems like endless confusion - the examples
should never rely on each other that way - different animal from
scenarios that involve steps.

  

Or am I missing somethiing?


On Sep 21, 2007, at 10:49 PM, David Chelimsky wrote:



Have you seen shared behaviours?

On 9/21/07, Yurii Rashkovskii [EMAIL PROTECTED] wrote:
  

Hello,

Just decided to check whether I am doing something that makes sense
or not. I was thinking about how cool would it be to re-use examples
(just like we reuse story scenarios with GivenScenario). I was not
sure if this possibility already exists in rspec (and, honestly, was
lazy to check), so I have created this helper:

def given_it(name)
   example_definition = behaviour.example_definitions.find{|i|
i.description == name }
   instance_eval(example_definition.example_block)
end

so it is possible to write things like

it should do something after another action do
   given_it should successfully do another action
   do_something.should be_fine
end

Is there anything already in rspec that allows me to do the same
stuff? Or was it a bad idea at all?

Yurii.
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users



___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
  

___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users



___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
  


___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] TextMate Bundle and exception when switching to alternate file.

2007-09-21 Thread Scott Taylor

 sorry if this is something better suited to another list.

 I've encountered a strange problem with the RSpec.tmbundle in trunk -
 namely that it was raising an exception when pressing
 ctrl-shift-downarrow (switch between spec and source - Alternate
 File).

 I tracked down the issue to be handling of the file_type in
 switch_command.rb#content_for() - the code expected the type  
 string to
 be just 'spec' when it can be 'view spec' or 'model spec' etc.

 Unfortunately I don't know whether this is just an issue with my  
 local
 textmate install or if it is, in fact, a bug.

Nope - it's a bug.  I've experienced the same thing too.

Scott
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] Getting Started with Story Runner

2007-09-21 Thread Andrew WC Brown
I'm trying to generate stories based on Dan North's example.
I'm not sure how to do this.

require File.join(File.dirname(__FILE__), helper)

Story Account Holder withdraws cash, %{
  As an Account Holder
  I want to withdraw cash from an ATM
  So that I can get money when the bank is closed
}, :type = RailsStory do

Scenario Account has sufficient funds do

  Given the account balance is $, 100 do |amount|
@account = Account.new(:balance = 100)
  end
   And the card is valid do
@account.should_not have.error_on(:balance)
   end
   And the machine contains enough money do
@account.sufficient_funds?
   end
  When the Account Holder requests $, 20 do |amount|
@account.withdraw(amount)
  end
  Then the ATM should dispense $, 20 do |amount|
post /account/show, :account = {:amount = amount} #show the receipt
  end
   And the account balance should be $, 80 do
@account.balance.should be_eql(80)
   end
   And the card should be returned do
post account/index
   end
end
Scenario Account has insufficient funds do; end
Scenario Card has been disabled do; end
Scenario The ATM has insufficient funds do; end

end
Scenario: Account has sufficient funds

  Given the account balance is $ 100
F
Scenario: Account has insufficient funds
.
Scenario: Card has been disabled
.
Scenario: The ATM has insufficient funds
.



4 scenarios: 3 succeeded, 1 failed, 0 pending


FAILURES:
  1) Account Holder withdraws cash (Account has sufficient funds) FAILED
  NameError: uninitialized constant Account
  
/usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_support/dependencies.rb:266:in
`load_missing_constant'


When a failure occurs in a story does it always print out a heapstack or is
my code incorrect?



On 9/21/07, Evan David Light [EMAIL PROTECTED] wrote:

 There are also a couple of examples buried in the trunk
 under examples/story/game-of-life/behaviour/stories
 On Sep 20, 2007, at 10:13 AM, Andrew WC Brown wrote:

 I'm guessing their isn't a generator for stories yet?

 ./script/generate story add_person

 On 9/20/07, James Hughes  [EMAIL PROTECTED] wrote:
 
  On 9/20/07, Ben Mabey  [EMAIL PROTECTED] wrote:
   Andrew WC Brown wrote:
I haven't found any How To's to use story runner and I'm not sure
  how
to get started.
Should I be looking for resources on how to use rbehave?
How do I generate my first Story?
   
  
   
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
   Pat wrote up an awesome tutorial/example:
  
  
  http://evang.eli.st/blog/2007/9/1/user-stories-with-rspec-s-story-runner
  
   That should get you started.
  
 
  This pastie may be of use as well:
 
  http://pastie.caboo.se/92472
 
  James
  ___
  rspec-users mailing list
  rspec-users@rubyforge.org
  http://rubyforge.org/mailman/listinfo/rspec-users
 
 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users



 ___
 rspec-users mailing list
 rspec-users@rubyforge.org
 http://rubyforge.org/mailman/listinfo/rspec-users




-- 
Monsterbox Productions
putting small businesses on-line

1319 Victoria Avenue East
Thunder Bay, Ontario P7C 1C3
Canada

Andrew WC Brown
web-developer and owner
[EMAIL PROTECTED]
P: 807-626-9009
F: 807-624-2705
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Re: [rspec-users] TextMate Bundle and exception when switching to alternate file.

2007-09-21 Thread Trevor Squires
Yeah, I've filed a patch for it - #14140

Regards,
Trevor

On 9/21/07, Scott Taylor [EMAIL PROTECTED] wrote:

 Nope - it's a bug.  I've experienced the same thing too.

 Scott

-- 
--
Trevor Squires
http://somethinglearned.com
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users