[Rspec-devel] What is a context?

Brian Takita brian.takita at gmail.com
Sun Jul 16 14:33:01 EDT 2006

> context "new session" do
>   setup do
>   end
>   scenario "new user registration" do
>     step "user navigates to registration page" do
>     end
>     step "user submits registration form" do
>     end
>   end
> end

Superficially, this looks more like a test rathern than a specification.

class TestSession < Test::Unit::TestCase
  def test_new_user_registration__user_navigates_to_registration_page

  def test_new_user_registration__user_submits_registration_form

Your proposed syntax is more elegant that expressing it with the should
context "new session with new user registration" do
  setup do
  specify "should allow user to navigate to registration page" do
  specify "should allow user to submit registration form after navigating to
registration page" do

Some people on the list have requested nested contexts and we've been
> resistant because we want to encourage clarity in specs. However,
> perhaps events could be the intermediate structure that we're looking
> for.

The programmer in me really want's the ability to nest the context. I
probably won't use it much, and it would probably make it less readable, it
makes the DSL more "elegant".

Nesting context's are also a very generic solution, which means it
communicates less than more specialized language.
context > scenerio > step communicates a use case better than context >
context > specify.

I just wonder if we want to have the nested contexts as a baseline generic
language structure that would serve those edge cases where the more
specialized language structures do not apply.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-devel/attachments/20060716/c92ec502/attachment.html 

More information about the Rspec-devel mailing list