UWE-Ruby/week-03 — Issue #6: Does subject() have to return the type that is listed after "describe" keyword in an RSpec test?
Author: seungkoh
Created: 2011-10-21 08:38:07+00:00
State: open

In our homework, I noticed code like:

describe Villain
...
subject { Villian.new "Joker", batman }
...
end

Is it common convention for the block to contain a Villain in this case? I tried running the following test, and it didn't break, but I'm wondering if this example is considered breaking a standard:

Villain = Struct.new :name, :nemesis

describe Villain do
subject { [1,2,3] }
it "should be 3 items" do
subject.length.should eq 3
end
end