[rspec-users] unless filter

Myron Marston myron.marston at gmail.com
Sun Mar 13 20:16:48 EDT 2011


On Mar 11, 1:17 pm, Justin Ko <jko... at gmail.com> wrote:
> On Thu, Mar 10, 2011 at 2:32 AM, Shamaoke <shama... at hotmail.com> wrote:
> > Hi.
>
> > Why doesn't the following filter work?
>
> > ~~~
> > # encoding: utf-8
> > # ./example_spec.rb
>
> > RSpec.configure do |config|
> >  config.filter = {
> >    unless: :condition_acceptable
> >  }
> > end
>
> > describe 'some code' do
> >  it 'does one', if: :condition_acceptable do
> >  end
>
> >  it 'does two', unless: :condition_acceptable do
> >  end
> > end
> > ~~~
>
> > ~~~
> > $ rspec example_spec.rb
> > No examples were matched # instead of 'some code does two'
> > ~~~
>
> > Thanks.
>
> > Debian GNU/Linux 5.0.7;
> > Ruby 1.9.2;
> > RSpec 2.5.0.
> > _______________________________________________
> > rspec-users mailing list
> > rspec-us... at rubyforge.org
> >http://rubyforge.org/mailman/listinfo/rspec-users
>
> If :condition_acceptable evaluates to false, your example will run. If you
> are looking to "match" key/values, don't use :if or :unless
>
> _______________________________________________
> rspec-users mailing list
> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users

There are built-in `:if` and `:unless` filters.  You probably don't
want to override them.  They work how you would normally expect.

http://relishapp.com/rspec/rspec-core/v/2-5/dir/filtering/implicit-filters

HTH,
Myron


More information about the rspec-users mailing list