Why don't you use let: describe MyClass do # Will set subject to an instance of MyClass context '#parse_input' do let(:input) { subject.parse_input } # calling input in your specs will now return the result of parse_input
it 'is a hash' do input.should be_a(Hash) # This evaluates let(:input) end end end Hope that helps. Andrew On Thursday 05 January 2012 at 11:26 AM, m wrote: > The symbol "subject" by default is an instance of the described class. > In some method testing I often want to set the subject to be a method > call to the instance, for example "city.parse_input()". > > I tried to do > > describe '#parse_input' do > subject{ subject.parse_input() } #returns hash > ... > end > > but I can't. > > I want to ask where did I get the semantic of this subject command > wrong which prevent me from doing this. Thanks. > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org (mailto:rspec-users@rubyforge.org) > http://rubyforge.org/mailman/listinfo/rspec-users > >
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users