[rspec-users] RSpec 2 Ruby 1.8.6 support (was Evaluating shared example customisation block before shared block)

2010-08-02 Thread Ashley Moran

On Aug 01, 2010, at 11:52 pm, David Chelimsky wrote:

> re: 1.8.6, we've got a home-grown implementation of instance_exec that runs 
> in 1.8.6 (although I just discovered that it's broken - fix coming shortly). 
> I could
> 
> a) add such a thing for module_exec as well, though I haven't quite figured 
> out how that works yet. 
> b) only support parameterized shared groups in ruby 1.8.7 or better
> c). the most drastic option, would be to drop support for 1.8.6 entirely, but 
> I don't think that's really feasible yet.

Hmmm.  If you're working on a Rails project with RSpec 2 (which I'm not, but 
I'm guessing that will be a very common case), you need 1.8.7 anyway, as Rails 
3 won't run on anything less.  If you're not using Rails, I can't imagine 
anyone starting a new project on 1.8.6 now.  (All my new stuff is on 1.9.2.)

Is 1.8.6 support in RSpec 2 *really* necessary?  Any thoughts from anyone?

Cheers
Ash

-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran

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


Re: [rspec-users] RSpec 2 Ruby 1.8.6 support (was Evaluating shared example customisation block before shared block)

2010-08-02 Thread David Chelimsky

On Aug 2, 2010, at 4:49 AM, Ashley Moran wrote:

> 
> On Aug 01, 2010, at 11:52 pm, David Chelimsky wrote:
> 
>> re: 1.8.6, we've got a home-grown implementation of instance_exec that runs 
>> in 1.8.6 (although I just discovered that it's broken - fix coming shortly). 
>> I could
>> 
>> a) add such a thing for module_exec as well, though I haven't quite figured 
>> out how that works yet. 
>> b) only support parameterized shared groups in ruby 1.8.7 or better
>> c). the most drastic option, would be to drop support for 1.8.6 entirely, 
>> but I don't think that's really feasible yet.
> 
> Hmmm.  If you're working on a Rails project with RSpec 2 (which I'm not, but 
> I'm guessing that will be a very common case), you need 1.8.7 anyway, as 
> Rails 3 won't run on anything less.  If you're not using Rails, I can't 
> imagine anyone starting a new project on 1.8.6 now.  (All my new stuff is on 
> 1.9.2.)

But what about people who are, for what ever reasons, stuck with Ruby 1.8.6 and 
want to upgrade? Also, there are a few rspec-2 + rails-2 efforts in the works, 
and there will be a solution for this sometime this fall.

We need to support 1.8.6.

> 
> Is 1.8.6 support in RSpec 2 *really* necessary?  Any thoughts from anyone?
> 
> Cheers
> Ash
> 
> -- 
> http://www.patchspace.co.uk/
> http://www.linkedin.com/in/ashleymoran
> 
> ___
> 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] migration question

2010-08-02 Thread rogerdpack
Got this:

no such file to load -- spec/rake/spectask

anybody know off hand what the equivalent is for rspec2?
-r
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users


Re: [rspec-users] RSpec 2 Ruby 1.8.6 support (was Evaluating shared example customisation block before shared block)

2010-08-02 Thread Ashley Moran

On 2 Aug 2010, at 1:08 PM, David Chelimsky wrote:

> But what about people who are, for what ever reasons, stuck with Ruby 1.8.6 
> and want to upgrade? Also, there are a few rspec-2 + rails-2 efforts in the 
> works, and there will be a solution for this sometime this fall.
> 
> We need to support 1.8.6.

Ah fair enough. I didn't imagine there were many people stuck in that situation 
- I thought 1.8.6 was largely obsolete now.  I also didn't know there were any 
RSpec-2/Rails-2 solutions in progress, I thought that was going to be 
unsupported.

-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran



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


Re: [rspec-users] Evaluating shared example customisation block before shared block

2010-08-02 Thread David Chelimsky
On Aug 1, 2010, at 10:08 PM, Myron Marston wrote:

> OK, I tried to implement #module_exec on ruby 1.8.6, and here's what I
> came up with:
> 
> http://github.com/myronmarston/rspec-core/commit/364f20ebd5b7d9612227cb6e86a6e8c8c2e9931e
> 
> It works (at least in the sense that it allows the specs and features
> I added in the previous commits in that branch to pass on ruby 1.8.6),
> but I don't think it's correct.  

If we're not exposing this as an API, and we're only using it in order to 
support this feature in RSpec when running Ruby 1.8.6, and it solves our 
problem, then I think it's correct as it needs to be.

> It just calls #instance_exec, but
> instance_exec and module_exec are not the same (at least as I
> understand them...).  However, I based that implementation on rubinius
> 1.0.1's:
> 
> http://github.com/evanphx/rubinius/blob/release-1.0.1/kernel/common/module.rb#L438-441
> 
> Backports (a library that implements features of later versions of
> ruby in 1.8.6) implements it in a similar fashion:
> 
> http://github.com/marcandre/backports/blob/v1.18.1/lib/backports/1.8.7/module.rb
> 
> Unfortunately, rubyspec doesn't provide much help in defining how
> module_exec should work:
> 
> http://github.com/rubyspec/rubyspec/blob/master/core/module/module_exec_spec.rb
> 
> I'd need some concrete examples demonstrating how module_exec should
> work (as compared to instance_exec) to implement it correctly.  My
> understanding is that they are identical except in regards to method
> definitions--def's within an instance_exec define methods directly on
> the Module object instance, whereas def's within a module_exec define
> instance methods in the module (i.e. methods that will be added to any
> class that includes the module).
> 
> One side issue I discovered is that instance_exec is implemented in
> rspec-expectations, but not rspec-core (which, incidentally, is why I
> linked to the cucumber implementation; I grepped in rspec-core and
> couldn't find it).  instance_exec is already used in rspec-core:
> 
> http://github.com/rspec/rspec-core/blob/v2.0.0.beta.19/lib/rspec/core/example_group.rb#L179
> 
> It needs to be implemented in rspec-core if you want rspec-core to be
> able to be used on 1.8.6 without rspec-expectations.

Done: 
http://github.com/rspec/rspec-core/commit/7d492bdc3657ca9472368b50f3f3f6635aca7fe0

> 
> Myron

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


Re: [rspec-users] Evaluating shared example customisation block before shared block

2010-08-02 Thread Ashley Moran

On 2 Aug 2010, at 2:04 AM, Myron Marston wrote:

> I actually find the use of this to be a bit confusing:
> 
> [:foo, :bar].each do |arg|
>  it_should_behave_like "Something", arg do |a|
># The value of the param is already bound to arg and now it's
> bound to a, too.
>  end
> end
> 
> I suppose it may be useful in some situations, so I'm fine with it as
> long as the implementation allows you to skip the `|a|`:
> 
> [:foo, :bar].each do |arg|
>  it_should_behave_like "Something", arg do
># no need to declare the |a| parameter since we already have it in
> arg.
># I find this to be less confusing.
>  end
> end


Agreed - requiring the block parameter to be declared in the host group is 
putting the onus back on the user, not the author, of the shared examples.  I 
think we need a way to implement the second version.

Ash

-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran



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


Re: [rspec-users] Evaluating shared example customisation block before shared block

2010-08-02 Thread Ashley Moran

On 2 Aug 2010, at 4:08 AM, Myron Marston wrote:

> Backports (a library that implements features of later versions of
> ruby in 1.8.6) implements it in a similar fashion:
> 
> http://github.com/marcandre/backports/blob/v1.18.1/lib/backports/1.8.7/module.rb

Conceivably, RSpec 2 could depend on Backports under Ruby 1.8.6.  It's not my 
opinion that it should (I don't have one), but I'm interested to know the 
implications.

Would that solve any design problems inside RSpec?

Would that cause any problems for users?

Would the problems solved outweigh the problems used?

Cheers
Ash

-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran



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


Re: [rspec-users] migration question

2010-08-02 Thread David Chelimsky

On Aug 2, 2010, at 8:09 AM, David Chelimsky wrote:

> 
> On Aug 2, 2010, at 7:46 AM, rogerdpack wrote:
> 
>> Got this:
>> 
>> no such file to load -- spec/rake/spectask
>> 
>> anybody know off hand what the equivalent is for rspec2?
> 
> rspec/core/rake_task
> 
> I'll add that to Upgrade.markdown

http://github.com/rspec/rspec-core/blob/master/Upgrade.markdown

> 
>> -r
>> ___
>> 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] Evaluating shared example customisation block before shared block

2010-08-02 Thread Ashley Moran

On 1 Aug 2010, at 11:52 PM, David Chelimsky wrote:

> re: order of evaluation of blocks, I think I'm inclined to go one way one 
> minute, and another the next. Somebody convince me of one or the other.

One thing that may help clear this up is: can anyone offer a concrete example 
of where overriding a shared example group helper method would be useful (and 
better than an alternative design)?

My gut feeling is that, as David suggested, being able to override these is 
creating a class hierarchy of example groups.  It feels to me unnervingly like 
overriding private methods.  I wait to be proved wrong though, I just can't 
think of an example myself of wanting to do this.

Cheers
Ash

-- 
http://www.patchspace.co.uk/
http://www.linkedin.com/in/ashleymoran



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


Re: [rspec-users] Newbie : How to spec params hash amendment

2010-08-02 Thread Elliot Winkler

 On 7/30/10 5:53 AM, Martin Hawkins wrote:

I have no idea how to approach 'rspec'ing the creation of the
params[:user][:password] and :password_confirmation or the
random_password method and would very much appreciate it if somebody
could spare the time to suggest what I should be doing.
You could stub the random_password method with some value, then perform 
the create action, then confirm that the @user variable has that value 
for password and password_confirmation. (I forget if instance variables 
are accessible in a controller test even after a redirect, so I guess 
you'll find out.)


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


Re: [rspec-users] migration question

2010-08-02 Thread David Chelimsky

On Aug 2, 2010, at 7:46 AM, rogerdpack wrote:

> Got this:
> 
> no such file to load -- spec/rake/spectask
> 
> anybody know off hand what the equivalent is for rspec2?

rspec/core/rake_task

I'll add that to Upgrade.markdown

> -r
> ___
> 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] Specifying which spec types helper modules get included into in the RSpec.configure block

2010-08-02 Thread S Bennett
Hi folks,

Using Rails 3.0.0.rc & RSpec 2.0.0.beta.19

I'm trying to specify what type of specs helper modules get included
into such as below:

config.include Devise::TestHelpers, :type => :controller

When I run the controller specs I get undefined method 'sign_in' which
tells me that the helpers aren't getting included.

If I remove the :type => :controller hash from the statement, the
module is included ok (into all spec types) and the specs pass.

Am I doing something wrong or has the syntax for specifying which spec
types the modules get included into changed?

Thanks

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


[rspec-users] Controller spec, integrate views, mocking helper method

2010-08-02 Thread LesNightingill
I need to use integrate views to test some particular features. In
ApplicationHelper I have:

module ApplicationHelper
 def current_user_permitted?
   # some logic that returns true/false
 end
end

I'm testing MyController using Rspec/flexmock...

describe MyController do
  integrate_views
  before(:each) do
  # how can I mock the 'current_user_permitted?' method here ?
  get :index
  end

 it "should display blah blah" do
  response.should have_tag('div#foo') do
   with_tag('div#bar',{:html => (/blah blah/)} )
  end
 end
end

I've found that I can make the test pass by mocking the
current_user_permitted? like this (BOTH mocks required in order to
pass!):
 
flexmock(ActionView::Base).new_instances.should_receive("current_user_permitted?").and_return(true)
flexmock(controller, 'current_user_permitted?' => true)

but this (2 mocks) just doesn't seem right, what is the right way?

thanks in advance for any insight you can offer

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


Re: [rspec-users] migration question

2010-08-02 Thread Myron Marston
This may be useful for folks migrating...

I recently updated one of my projects to RSpec 2.  Here's the commit
with all the changes:

http://github.com/myronmarston/vcr/commit/f05cc59abc16b711e345bab2994ad2ebfdce7170

Summary:

- Updated rakefile so it defines new spec tasks
- Migrated simple_matcher to RSpec::Matchers.define
- Removed spec.opts
- Require 'rspec' rather than 'spec'
- RSpec.configure rather than Spec::Runner.configure


On Aug 2, 6:09 am, David Chelimsky  wrote:
> On Aug 2, 2010, at 7:46 AM, rogerdpack wrote:
>
> > Got this:
>
> > no such file to load -- spec/rake/spectask
>
> > anybody know off hand what the equivalent is for rspec2?
>
> rspec/core/rake_task
>
> I'll add that to Upgrade.markdown
>
> > -r
> > ___
> > rspec-users mailing list
> > rspec-us...@rubyforge.org
> >http://rubyforge.org/mailman/listinfo/rspec-users
>
> ___
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
___
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users