Sha256: 0df94d43de5cfad2ac8f5e1e526d5c6041d626174adff9ddd7aba32c9db02c37

Contents?: true

Size: 1.64 KB

Versions: 4

Compression:

Stored size: 1.64 KB

Contents

class FeatureInheritanceTest < BaseTest
  Song  = Struct.new(:title, :album, :composer)
  Album = Struct.new(:name, :songs, :artist)
  Artist = Struct.new(:name)

  module Date
    def date
      "May 16"
    end

    def self.included(includer)
      includer.send :register_feature, self
    end
  end

  # module Name
  #   def name
  #     "Violins"
  #   end
  # end

  class AlbumForm < TestForm
    feature Date # feature.
    property :name

    collection :songs do
      property :title

      property :composer do
        property :name
      end
    end

    property :artist do
      property :name
    end
  end

  let(:song)               { Song.new("Broken") }
  let(:song_with_composer) { Song.new("Resist Stance", nil, composer) }
  let(:composer)           { Artist.new("Greg Graffin") }
  let(:artist)             { Artist.new("Bad Religion") }
  let(:album)              { Album.new("The Dissent Of Man", [song, song_with_composer], artist) }

  let(:form) { AlbumForm.new(album) }

  it do
    assert_equal form.date, "May 16"
    assert_equal form.songs[0].date, "May 16"
  end

  # it { subject.class.include?(Reform::Form::ActiveModel) }
  # it { subject.class.include?(Reform::Form::Coercion) }
  # it { subject.is_a?(Reform::Form::MultiParameterAttributes) }

  # it { subject.band.class.include?(Reform::Form::ActiveModel) }
  # it { subject.band.is_a?(Reform::Form::Coercion) }
  # it { subject.band.is_a?(Reform::Form::MultiParameterAttributes) }

  # it { subject.band.label.is_a?(Reform::Form::ActiveModel) }
  # it { subject.band.label.is_a?(Reform::Form::Coercion) }
  # it { subject.band.label.is_a?(Reform::Form::MultiParameterAttributes) }
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
reform-2.6.2 test/feature_test.rb
reform-2.6.1 test/feature_test.rb
reform-2.6.0 test/feature_test.rb
reform-2.5.0 test/feature_test.rb