Reputation: 4487
I am new to rspec
. Going through tutorials, where I am stuck in beginning of it.
When I was working with WATIR
, cucumber
framework I never saw describe
and it
.
So whats the difference? What to use when?
Upvotes: 2
Views: 6852
Reputation: 43825
Describe is used to explain what is being worked on. Typically you're going to describe a class and it's going to surround all of the it
calls. it
is the test case(s) that is/are executed within the describe
block:
describe Foo do
it "will return true" do
expect(Foo.bar).to eq(true)
end
it "will return false" do
expect(Foo.baz).to eq(false)
end
end
# When run, rspec output is:
Foo
will return true
will return false
In the above case, the it
method is describing how bar
and baz
will function on the Foo
class. A good read is the rspec documentation on this.
Upvotes: 5