Sha256: 2546cbabcfa50f8bf429efe8c47ed86f39f88657a4a87453c710621adff208ef

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

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

1 entries across 1 versions & 1 rubygems

Version Path
windcharger-0.3.0 spec/readme_spec.rb