Sha256: 81b6128ad72f864c711426b23318f64e7db5033bf1b882ccf2bb04c2e558d9ee

Contents?: true

Size: 1.03 KB

Versions: 33

Compression:

Stored size: 1.03 KB

Contents

require 'test_helper'

class PassOptionsTest < BaseTest
  let (:format) { :hash }
  let (:song) { Struct.new(:title).new("Revolution") }
  let (:prepared) { representer.prepare song }

  describe "module" do
    representer! do
      property :title, :pass_options => true,
        :as => lambda { |args| [args.binding.name, args.user_options, args.represented, args.decorator]  }
    end

    it { render(prepared, :volume => 1).must_equal_document({["title", {:volume=>1}, prepared, prepared] => "Revolution"}) }
    # it { parse(prepared, {"args" => "Wie Es Geht"}).name.must_equal "Wie Es Geht" }
  end

  describe "decorator" do
    representer!(:decorator => true) do
      property :title, :pass_options => true,
        :as => lambda { |args| [args.binding.name, args.user_options, args.represented, args.decorator]  }
    end

    it { render(prepared, :volume => 1).must_equal_document({["title", {:volume=>1}, song, prepared] => "Revolution"}) }
    # it { parse(prepared, {"args" => "Wie Es Geht"}).name.must_equal "Wie Es Geht" }
  end
end

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
representable-2.4.1 test-with-deprecations/pass_options_test.rb
representable-2.4.0 test-with-deprecations/pass_options_test.rb
representable-2.4.0.rc5 test-with-deprecations/pass_options_test.rb
representable-2.4.0.rc4 test-with-deprecations/pass_options_test.rb
representable-2.4.0.rc3 test/pass_options_test.rb
representable-2.4.0.rc2 test/pass_options_test.rb
representable-2.4.0.rc1 test/pass_options_test.rb
representable-2.3.0 test/pass_options_test.rb
representable-2.2.3 test/pass_options_test.rb
representable-2.2.2 test/pass_options_test.rb
representable-2.2.1 test/pass_options_test.rb
representable-2.2.0 test/pass_options_test.rb
representable-2.1.8 test/pass_options_test.rb
representable-2.1.7 test/pass_options_test.rb
representable-2.1.6 test/pass_options_test.rb
representable-2.1.5 test/pass_options_test.rb
representable-2.1.4 test/pass_options_test.rb
representable-2.1.3 test/pass_options_test.rb
representable-2.1.1 test/pass_options_test.rb
representable-2.1.0 test/pass_options_test.rb