UseCase "Group examples"

From SMW CindyKate by dataspects
Component 415887
Jump to navigation Jump to search
[edit]
Keywords/Contexts

Rspec

Annotations
{{#compound_query:Component 415887Property "-Has subobject" has a restricted application area and cannot be used as annotation property by a user.UseCaseMotivation;?HasDirection;?IsMotivating;?IsMotivatedBy;?HasReasoning
Property "-Has subobject" has a restricted application area and cannot be used as annotation property by a user.UseCase "Group examples";?HasDirection;?IsMotivating;?IsMotivatedBy;?HasReasoning Property "-Has subobject" has a restricted application area and cannot be used as annotation property by a user.UseCase "Group examples";?HasDirection;?IsMotivating;?IsMotivatedBy;?HasReasoning
name=MotivationsDeclaredOnThisPageResultItem|link=none}}
Motivations
Lua error in Module:Motivations at line 23: attempt to concatenate field 'hasReasoning' (a nil value).
[edit]

Content

Group by initial state/context

context()
  before(:each|:all) do 
    # :each re-creates context before each example
    # :all could be useful for sharing instance variables for e.g. opening a network connection
    ...
  end
end

An alternative for setting up instance variables is subject()

Explicit

describe ... do
  subject {}
  specify|it|example { subject.should be_happy }
end 

Delegated

describe ... do
  subject {}
  specify|it|example { should be_happy }
end 

Implicit

describe User do
  specify|it|example { should be_happy }
end 
context()
  after(:each|:all) do
    # runs even if an example fails, good for restoring global state
  end
  it() do
    ...
  end
end
context()
  around(:each) do
    # support APIs that require a block
  end
  it() do
    ...
  end
end