How to create a subject helper method in Rspec2

Posted by Hedgehog on Stack Overflow See other posts from Stack Overflow or by Hedgehog
Published on 2012-12-19T22:45:08Z Indexed on 2012/12/20 11:03 UTC
Read the original article Hit count: 206

Filed under:
|

In rpsec 2.12 I expected this helper method definition to work:

module X
private
  def build_them(type)
    puts 'Catching the star'
  end  
end
context 'public/private instance methods' do
  subject{ Class.new { extend(::X) } }
  def subject.build(type)
    puts "Throwing a star"
    build_them(type)
  end
  it{ should respond_to :build}
end

The actual result is a failed spec:

expected #<Class:0x00000002ea5f90> to respond to :build

I expected the example to pass

Any suggestions on how to do this correctly?

© Stack Overflow or respective owner

Related posts about ruby

Related posts about rspec2