Sha256: e7f5edd408d6799538a7194257366095b4270499e215f99646d22b712950676c

Contents?: true

Size: 594 Bytes

Versions: 13

Compression:

Stored size: 594 Bytes

Contents

require "test_helper"


class OperationContractTest < MiniTest::Spec

  class Operation < Trailblazer::Operation
    contract do
      property :id
      property :title
      property :length
    end

    def process(params)
      @model = Struct.new(:id, :title, :length).new

      contract.id = 1
      validate(params) do
        contract.length = 3
      end
    end
  end

  # allow using #contract before #validate.
  it do
    op = Operation.(title: "Beethoven")
    op.contract.id.must_equal 1
    op.contract.title.must_equal "Beethoven"
    op.contract.length.must_equal 3
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
trailblazer-1.1.2 test/operation/contract_test.rb
trailblazer-1.1.1 test/operation/contract_test.rb
trailblazer-1.1.0 test/operation/contract_test.rb
trailblazer-1.1.0.rc1 test/operation/contract_test.rb
trailblazer-1.0.4 test/operation/contract_test.rb
trailblazer-1.0.3 test/operation/contract_test.rb
trailblazer-1.0.2 test/operation/contract_test.rb
trailblazer-1.0.1 test/operation/contract_test.rb
trailblazer-1.0.0 test/operation/contract_test.rb
trailblazer-1.0.0.rc2 test/operation/contract_test.rb
trailblazer-1.0.0.rc1 test/operation/contract_test.rb
trailblazer-0.3.3 test/operation/contract_test.rb
trailblazer-0.3.2 test/operation/contract_test.rb