Sha256: 3f821350e5981ee26bc5887a2b5e8c4c6b738aab2f4161bf847b55d42aaf2135

Contents?: true

Size: 680 Bytes

Versions: 5

Compression:

Stored size: 680 Bytes

Contents

require 'pears/testing/subject'

module Pears
  module Testing
    def self.prepend_subject subject_name, *address, is:
      subject = find_subject!(subject_name)
      subject.prepend *address, is: is
      begin
        yield
      ensure
        subject.shift
      end
    end

    def self.find_subject!(name)
      Pears.subjects
          .find { |subject| subject.name.to_sym == name.to_sym }.tap do |sub|
        unless sub.present?
          raise SubjectNotfound.new(
            message: "No subject with the name #{subject_name} exists."
          )
        end
      end
    end
  end
end

module Pears
  class Subject
    include Pears::Testing::Subject
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pears-0.3.5 lib/pears/testing.rb
pears-0.3.4 lib/pears/testing.rb
pears-0.3.2 lib/pears/testing.rb
pears-0.3.1 lib/pears/testing.rb
pears-0.3.0 lib/pears/testing.rb