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.
On Thu, Mar 10, 2011 at 2:32 AM, Shamaoke [email protected] wrote:
unless: :condition_acceptable
RSpec 2.5.0.
_______________________________________________
rspec-users mailing list
[email protected]
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
On Mar 11, 1:17pm, Justin Ko [email protected] wrote:
config.filter = {
end
Ruby 1.9.2;
rspec-users mailing list
[email protected]://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
Thanks for the clarification. I was led astray by the example from the
RSpec Book where the network dependent code was described*. In that
example the default if filter was overriden using the Proc object and
it returned true or false depending on the network condition. Now I
understand that code could be changed like the following:
class Network
def self.available
true # or false depending on the network condition
end
end
describe 'some network dependent code' do
it 'does one', :if => Network.available do # works if the network is
available only
end
it 'does two' do
end
end
- The RSpec Book, chp. 16, p. 238.
On Mar 15, 2011, at 4:49 AM, Shamaoke wrote:
it 'does one', if: :condition_acceptable do
http://relishapp.com/rspec/rspec-core/v/2-5/dir/filtering/implicit-fi…
HTH,
Myron
end
________
* The RSpec Book, chp. 16, p. 238.
Unfortunately, :if and :unless were added as special cases after
rspec-2.0 and The RSpec Book were released
Cheers,
David