Sha256: 208dcb3b2aa8e9eb9beb0b773e219ae59055cc9a801d41fc715e55b719a23b33
Contents?: true
Size: 1018 Bytes
Versions: 3
Compression:
Stored size: 1018 Bytes
Contents
module Zebra module ShouldaSupport def self.included(klass) klass.class_eval do attr_accessor :expects alias_method :build_without_expects, :build alias_method :build, :build_with_expects end end def expect(&block) self.expects ||= [] self.expects << block end def create_test_from_expect(&block) test_name = expect_test_name(full_name, &block) if test_unit_class.instance_methods.include?(test_name.to_s) warn " * WARNING: '#{test_name}' is already defined" end context = self test_unit_class.send(:define_method, test_name) do begin context.run_parent_setup_blocks(self) context.run_current_setup_blocks(self) block.bind(self).call ensure context.run_all_teardown_blocks(self) end end end def build_with_expects (expects || []).each { |e| create_test_from_expect(&e) } build_without_expects end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
giraffesoft-zebra-0.2.0 | lib/zebra/shoulda.rb |
joshng-zebra-0.1.1 | lib/zebra/shoulda.rb |
joshng-zebra-0.1.2 | lib/zebra/shoulda.rb |