Sha256: ea67ff7a1da21d5b54252f0312a4f5024cab2f3df081defe7bd79479ed8245e1

Contents?: true

Size: 856 Bytes

Versions: 2

Compression:

Stored size: 856 Bytes

Contents

require 'spec_helper'
require 'pact/shared/dsl'

module Pact
  describe DSL do

    class TestDSL
      extend DSL
      attr_accessor :thing, :blah, :finally

      dsl do
        def with_thing thing
          self.thing = thing
        end
        def with_blah blah
          self.blah = blah
        end
      end

      def finalize
        @finally = 'yay'
      end
    end

    describe "build" do
       it "should support calling other variables and methods in scope" do
          def my_method
             'LA LA LA'
          end

          my_local_var = 123

          test = TestDSL.build do
            with_thing my_method
            with_blah my_local_var
          end

          expect(test.thing).to eq my_method
          expect(test.blah).to eq my_local_var
          expect(test.finally).to eq 'yay'
       end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact-1.0.12 spec/lib/pact/shared/dsl_spec.rb
pact-1.0.11 spec/lib/pact/shared/dsl_spec.rb