Skip to content

Instantly share code, notes, and snippets.

@smtlaissezfaire
Created March 11, 2010 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smtlaissezfaire/328919 to your computer and use it in GitHub Desktop.
Save smtlaissezfaire/328919 to your computer and use it in GitHub Desktop.
module Spec
module Example
class ExampleGroupFactory
# Used to support spec/unit and spec/integration
def self.determine_superclass(opts)
spec_path = opts[:spec_path].to_s.gsub("/spec/unit", "/spec")
id = if opts[:type]
opts[:type]
elsif spec_path =~ /controller/ || spec_path =~ /spec\/integration\/routing_spec/
:controller
elsif spec_path =~ /spec\/integration/
:model
elsif spec_path =~ /spec(\\|\/)(#{@example_group_types.keys.join('|')})/
$2 == '' ? nil : $2.to_sym
end
get(id)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment