Hi Myron,
thanks for your response, somehow not very helpful.
This does not seam to be the best solution, as these files
are under the directory spec/dummy/spec ( i.e a rails app called dummy
using rspec ),
I would have to add a tag to any group example that I do not want rspec to
run.
I believe this seams a bit redundant!?
The implementation I have in mind is to tell rspec not to require any file
that matches
the path exception added.
Rspec::Core::Configuration#gather_directories returns the files that match
a pattern
and sorts them.
My ideas is to add four more methods, and modify gather_directories to be
like:
def initialize
@path_exceptions = false
end
attr_reader :path_exceptions
def gather_directories(path)
stripped = "{#{pattern.gsub(/\s*,\s*/, ',')}}"
files = pattern =~ /^#{Regexp.escape path}/ ? Dir[stripped] :
Dir["#{path}/#{stripped}"]
except_for!(files)
end
def except_for!(files)
files = files.select { |file| file !~ path_exceptions } if path_exceptions
files.sort
end
def add_exception = path
@path_exceptions = path
end
alias :add_exceptions :add_exception
And you would add exceptions like so:
RSpec.configure do |c|
c.add_exception = /dummy/
# OR
c.add_exceptions = /dummy|app|test|sinatra/
end
In order not to use another loop in this minor implementation,
we would require users to follow that convention to specify more
than one path as an exception. ( i.e dummy|test|this, Ruby Regexp OR )
I got it working here, but as you Myron Marston does not seem to like this
implementation I would not even bother to open up a PR.
It's a minimal complexity added.
AFAIK anything has to start from somewhere, so here I am proposing this
feature.
I am looking forward to hearing from you all.
With regards,
Nalesso Antonio
On Thursday, 14 November 2013 17:25:27 UTC, Myron Marston wrote:
>
> In my opinion, this adds complexity for what is very much a niche use
> case. As far as I know, you're the first user to ever report an issue like
> this :). Also, you can already achieve this using a snippet like this:
>
> RSpec.configure do |c|
> c.filter_run_excluding :example_group => lambda { |metadata|
> metadata[:file_path].include?('dummy')
> }
> end
>
> On Thursday, November 14, 2013 8:44:31 AM UTC-8, [email protected] wrote:
>>
>> Seams reasonable, but the devil is in the details. Go ahead and submit a
>> PR and see what the team thinks.
>>
>> Cheers,
>> David
>>
>> Sent from my iPhone
>>
>> On Nov 14, 2013, at 11:06 AM, Nalesso Moreira <[email protected]> wrote:
>>
>> Hi David,
>> Thanks for your response.
>>
>> Do you think rspec-core should provide an options like this?
>> I am going to submit a PR on github with this feature implemented.
>>
>> With regards,
>> Nalesso Antonio
>>
>> On Wednesday, 13 November 2013 11:24:01 UTC, [email protected] wrote:
>>>
>>> There's currently no exception feature, but rspec loads all files
>>> matching the glob pattern "spec/**/*_spec.rb" by default (run "rspec
>>> --help" to see the command line options). This can be overridden on the
>>> command line or in .rspec (or ~/.rspec). So given:
>>>
>>> $ ls spec
>>> dummy foo bar
>>> $ rspec --pattern "spec/{foo,bar}/**/*_spec.rb"
>>>
>>> Depending on your shell and your glob fu, there might be a way to
>>> exclude the spec/dummy directory using a negation, but I haven't figured
>>> out how to do that yet.
>>>
>>> HTH,
>>> David
>>>
>>>
>>>
>>>
>>> On Tue, Nov 12, 2013 at 11:24 PM, Nalesso Moreira <[email protected]>wrote:
>>>
>>>> Hi there,
>>>> My test suite is failing because rspec is loading the tests of a rails
>>>> dummy
>>>> app located in spec/dummy/spec/**/*.rb.
>>>>
>>>> Here is a better explanation:
>>>>
>>>> Given a dir spec
>>>> And I have a rails app in spec/dummy
>>>> When I run rspec command
>>>> Then rspec should not load tests in spec/dummy/spec/**/*.rb
>>>> And all my tests mustt pass
>>>>
>>>> Does anybody know how I could sort of add_exception like autotest
>>>> does not to fetch/load this particular dir?
>>>>
>>>> With regards,
>>>> Nalesso Moreira
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "rspec" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To post to this group, send email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/rspec/0a23b642-d0df-4493-9f53-d78752989e5a%40googlegroups.com
>>>> .
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>
>>> --
>> You received this message because you are subscribed to the Google Groups
>> "rspec" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/rspec/f56c2425-3f06-4f04-af99-e2eae02e5aad%40googlegroups.com
>> .
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
--
You received this message because you are subscribed to the Google Groups
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/rspec/599385e7-fd1c-4323-b1b7-7d9761eca641%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.