Sha256: 63cb86b0fd5ac9eaa721f9055c8276e78b4c0484beac4b38cfd14959addceef5

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require 'spec_helper'
require 'windcharger'

describe "readme" do
  describe "example 1" do
    before do
      class MyTransformer
        extend Windcharger::Attributes

        attribute
        def foo; end

        attribute
        def bar; end

        def not_an_attribute; end
      end
    end

    after do
      Object.send :remove_const, :MyTransformer
    end

    it "works" do
      expect(MyTransformer.attributes).to eq [:foo, :bar]
    end
  end

  describe "example 1" do
    before do
      class MyTransformer
        extend Windcharger::Attributes
        include Windcharger::HashTransformer

        attribute
        def foo
          :the_foo
        end

        attribute
        def bar
          :walked_into_a_bar
        end

        def qux
          1
        end

        attribute :qax, :qux

        def qax
          2
        end

        def not_an_attribute
          42
        end
      end
    end

    after do
      Object.send :remove_const, :MyTransformer
    end

    it "works" do
      my_transformer = MyTransformer.new
      expect(my_transformer.transform).to eq({
        :foo => :the_foo,
        :bar => :walked_into_a_bar,
        :qax => 2,
        :qux => 1,
      })
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
windcharger-0.7.0 spec/readme_spec.rb
windcharger-0.6.0 spec/readme_spec.rb
windcharger-0.5.0 spec/readme_spec.rb
windcharger-0.4.0 spec/readme_spec.rb