Sha256: 579ae87751fafcc58f6f67d4f6c70cd861be263ce4391a981bb29c87646e72ea

Contents?: true

Size: 1.32 KB

Versions: 10

Compression:

Stored size: 1.32 KB

Contents

require 'muack/test'

describe Muack::Coat do
  after do
    Muack.verify.should.eq true
    Muack::EnsureReset.call
  end

  would 'wear out' do
    coat(Str).to_s{ 'Coat' }
    Str.to_s.should.eq 'Coat'
    Str.to_s.should.eq 'Moo'
  end

  would 'wear out 2 times' do
    coat(Str).to_s{ 'Coat' }.times(2)
    2.times{ Str.to_s.should.eq 'Coat' }
    Str.to_s.should.eq 'Moo'
  end

  would 'call the original method' do
    coat(Str).to_s{ Str.to_s.reverse }
    Str.to_s.should.eq 'ooM'
    Str.to_s.should.eq 'Moo'
  end

  would 'raise Expected error if coated method is not called' do
    coat(Obj).say{ 'nnf' }
    e = should.raise(Muack::Expected){ Muack.verify }
    e.expected      .should.eq 'obj.say()'
    e.expected_times.should.eq 1
    e.actual_times  .should.eq 0
    e.message       .should.eq "\nExpected: obj.say()\n  " \
                               "called 1 times\n but was 0 times."
  end

  would 'raise Expected error if coated method is not called' do
    coat(Obj).say{ 'nnf' }.times(2)
    Obj.say.should.eq 'nnf'
    e = should.raise(Muack::Expected){ Muack.verify }
    e.expected      .should.eq 'obj.say()'
    e.expected_times.should.eq 2
    e.actual_times  .should.eq 1
    e.message       .should.eq "\nExpected: obj.say()\n  " \
                               "called 2 times\n but was 1 times."
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
muack-1.7.0 test/test_coat.rb
muack-1.6.0 test/test_coat.rb
muack-1.5.1 test/test_coat.rb
muack-1.5.0 test/test_coat.rb
muack-1.4.0 test/test_coat.rb
muack-1.3.2 test/test_coat.rb
muack-1.3.1 test/test_coat.rb
muack-1.3.0 test/test_coat.rb
muack-1.2.0 test/test_coat.rb
muack-1.1.2 test/test_coat.rb