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.
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?
require ‘user’
context User do
…
describe “(adding assigned role)” do
…
end
end
–
God Bless,
Joe O.
agilejoe.lostechies.com
“How do you benefit if you gain the whole world but lose your soul in
the
process?” Mark 8:36