Sha256: b5aa72899636b855fa62842bb73cd545fb8b65f152f08818837ec34b7225269e

Contents?: true

Size: 1.72 KB

Versions: 1

Compression:

Stored size: 1.72 KB

Contents

require 'devtools/spec_helper'

require 'concord' # makes spec setup easier

module Spec

  def self.response_data
    :data
  end

  class Observer
    def self.call(response)
    end
  end

  class Action
    class Success
      def self.call(request)
        request.success(Spec.response_data)
      end
    end

    class Failure
      def self.call(request)
        request.error(Spec.response_data)
      end
    end
  end

  class Processor
    include Concord::Public.new(:env, :handler)
  end

  class Presenter
    include Concord.new(:data)
  end

  module Handler

    class Evaluator
      class Result

        include Concord::Public.new(:output)

        class Success < self
          def success?
            true
          end
        end

        class Failure < self
          def success?
            false
          end
        end
      end

      def self.call(data)
        new.call(data)
      end

      def call(data)
        if data == :success
          Result::Success.new(data)
        else
          Result::Failure.new(:failure)
        end
      end
    end

    class Pivot
      def call(request)
        request.success(request.input)
      end
    end

  end

  FAKE_HANDLER   = Object.new
  FAKE_ENV       = Object.new
  FAKE_PROCESSOR = Processor.new(FAKE_ENV, FAKE_HANDLER)

end

if ENV['COVERAGE'] == 'true'
  require 'simplecov'
  require 'coveralls'

  SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
    SimpleCov::Formatter::HTMLFormatter,
    Coveralls::SimpleCov::Formatter
  ]

  SimpleCov.start do
    command_name     'spec:unit'
    add_filter       'config'
    add_filter       'spec'
    minimum_coverage 100
  end
end

require 'substation'

include Substation

RSpec.configure do |config|
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
substation-0.0.10.beta2 spec/spec_helper.rb