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.<br>
require 'user'<br><br>describe User do<br><br> before(:each) do<br> @user = User.new<br> end<br><br> context "(adding assigned role)" do<br> before(:each) do<br> @user.assign_role("Manager")<br>
end<br><br> specify "should be in any roles assigned to it" do<br> @user.should be_in_role("Manager")<br> end<br> <br> specify "should not be in any role not assigned to it" do <br>
@user.should_not be_in_role("unassigned role")<br> end<br> end <br> <br> context "(adding assigned group)" do<br><br> end <br>end<br><br>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.<br>
<br>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?<br>
<br>require 'user'<br><br>context User do<br>...<br> describe "(adding assigned role)" do<br> ...<br> end <br>end<br><br>-- <br>God Bless,<br><br>Joe Ocampo<br><a href="http://agilejoe.lostechies.com">agilejoe.lostechies.com</a><br>
<br>"How do you benefit if you gain the whole world but lose your soul in the process?" Mark 8:36<br><br>