[rspec-users] Aspects in RSpec 1.0.5

David Chelimsky dchelimsky at gmail.com
Wed Jun 27 11:57:59 EDT 2007


On 6/27/07, Ashley Moran <work at ashleymoran.me.uk> wrote:
> Forgot post this when I did it...
>
> For anyone else that used the "aspect" method of the rspec-ext gem,
> here's a New World version of the code to drop into spec_helper.rb.
> (I'm assuming rspec-ext hasn't been updated since I did this a week
> or two ago)
>
>    module Spec
>      module DSL
>
>        module BehaviourEval
>          module ModuleMethods
>            def aspect(name,&block)
>              Behaviour.aspect << name.to_s
>              yield
>              Behaviour.aspect.pop
>            end
>          end
>        end
>
>        class Behaviour
>          @@aspect = []
>          def self.aspect
>            @@aspect
>          end
>          def self.aspect=(new_aspect)
>            @@aspect = new_aspect
>          end
>          alias :original_initialize :initialize
>          def initialize(*args,&context_block)
>            result = original_initialize(*args, &context_block)
>            @name = "(#{self.class.aspect.join("/")}) #{@name}" unless
> self.class.aspect.empty?
>            result
>          end
>        end
>
>      end
>    end
>
> Ashley

There's an RFE for this in the tracker - wanna contribute this as a
patch? If you do, please use "facet" instead of "aspect".

http://rubyforge.org/tracker/?func=detail&group_id=797&aid=8654&atid=3152

Cheers,
David

>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list