On Sun, Feb 24, 2008 at 5:29 AM, Joe Ocampo <[EMAIL PROTECTED]> wrote: > Background just started programming in Ruby literally 12 hours ago and have > a question regarding context and describe methods. Reading the RDoc it > indicated that "context" is an alias for "describe". So I decided to try to > the following syntax seeing this is how I would approach it in C# with > NBehave. > require 'user' > > describe User do > > before(:each) do > @user = User.new > end > > context "(adding assigned role)" do > before(:each) do > @user.assign_role("Manager") > end > > specify "should be in any roles assigned to it" do > @user.should be_in_role("Manager") > end > > specify "should not be in any role not assigned to it" do > @user.should_not be_in_role("unassigned role") > end > end > > context "(adding assigned group)" do > > end > end > > I thought I could use the "describe" method to indicate the Type that the > specifications where going to be concerning. I then would place the type > into a behavioral context to assert the intended behavior against that > context.
At first glance, that is really cool. We've also batted around some other names like #facet or #behaviour. > This combination resulted in User never being instantiated for the internal > context. (nil:NilClass). However! If I flip the "context" and > "description" it works. Am I doing something wrong? No you're not doing something wrong - there are two different places where describe is defined. One in main (the outermost layer) and one inside an ExampleGroup. The one in the example group isn't aliased. So to solve that for the short term in your own code you can do this in your spec_helper.rb file: module Spec::Example::ExampleGroupMethods alias :context :describe end In terms of getting that into RSpec, why don't you enter a feature request at http://rspec.lighthouseapp.com and we can discuss the merits of this there. As I said, I like it at first glance, but I want to think about it and get other opinions before just adding it (as context is only there for backwards compatibility right now). Thanks, David > > require 'user' > > context User do > ... > describe "(adding assigned role)" do > ... > end > end > > -- > God Bless, > > Joe Ocampo > agilejoe.lostechies.com > > "How do you benefit if you gain the whole world but lose your soul in the > process?" Mark 8:36 > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users