[ rspec ] describe v.s. context

“describe” : wrap a set of tests against one functionality

“context” : wrap a set of tests against one functionality under the same state

 

describe "launch the rocket" do
before(:each) do
#prepare a rocket for all of the tests
@rocket = Rocket.new
end

context "all ready" do
before(:each) do
#under the state of ready
@rocket.ready = true
end

it "launch the rocket" do
@rocket.launch().should be_true
end
end

context "not ready" do
before(:each) do
#under the state of NOT ready
@rocket.ready = false
end

it "does not launch the rocket" do
@rocket.launch().should be_false
end
end
end

ref : http://lmws.net/describe-vs-context-in-rspec

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s