On Dec 7, 2011, at 10:03 AM, Bradley wrote:
> I'm trying to get a new spec task defined that is 'fast': that is, it skips
> all :type => :integration tests and any tests that have :slow => true set.
>
> We're using spec/integration instead of spec/requests, but I thought I read
> somewhere that they're equivalent, ie that they would both be automagically
> tagged with :type => :integration and :type => :request. (I personally find
> 'integration' far more intuitive than 'request' so that's what we've chosen
> to use.)
See
https://github.com/rspec/rspec-rails/blob/master/lib/rspec/rails/example.rb#L29-31
Specs in spec/request or spec/integration get assigned :type => :request.
We added support for implicit treatment of files in spec/integration the same
as spec/request, but assigning both types is problematic.
> First question: Is this true? Does rspec automagically tag my spec/requests
> and spec/integration with the proper type. If so, is this only true when
> using `rake`, or is it the same with using `rspec`
>
> Next: I've written a task like so:
>
> desc "Run all but slow (including integration) specs"
> RSpec::Core::RakeTask.new(:fast => 'db:test:prepare') do |t|
> t.rspec_opts = '--tag ~slow --tag ~type:request --tag ~type:integration'
> end
Keep the specs in spec/integration if you like, but get rid of
~type:integration (~type:request covers you).
>
> Oddly enough, when the tests run, they say
>
> Run filtered excluding {:slow=>true, :type=>"integration"}
>
> So second question: Is it not possible to filter out multiple tags of a type
> (ie --tag ~type:request --tag ~type:integration)
No. You can only attach one value to each key. I'm open to enhancing that in
the future, but that's how it works now.
> Next, it appears that when I use :type => :integration, nothing gets
> filtered, but when I use :type => :request it does.
Right - :type => :integration doesn't mean anything to rspec. :type => :request
does.
> So third question: What make :request so special such that :integration does
> not work the same way.
Integration doesn't mean anything precise. There is an unfortunate convention
in the Rails community, that it means something closer to end-to-end than
functional, but this is backwards from definitions that existed prior to rails:
integration meant two or more non-trivial components (meaning that Rails unit
tests are integration tests) and function tests meant functionality as a user
sees it.
The word "request" came out of the Merb project, and it made perfect sense to
me when I saw it, so I incorporated it into rspec-rails-2. I still think it's a
more precise word than integration, but as time passes I think "scenario" might
be even better, since it really lives in the same space as a Cucumber feature.
> Any help on these matters is greatly appreciated!
HTH,
David
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users