Sha256: d101c27c3893b5057b18f95e346d03a56426c5035609e0eb19b15b6e488f8a91

Contents?: true

Size: 1.12 KB

Versions: 2

Compression:

Stored size: 1.12 KB

Contents

Feature: Field with default_when specified
  In order to prevent undesirable effects
  As a developer
  I want to specify a check to be performed when I access a field

  Background:
    Given I have an ActiveModel based model
      """
      class MyActiveModel < ActiveModelExample
        attr_accessor :title
      end
      """
    When I define a Catwalk presenter class for my model
      """
      class MyModelPresenter
        include Catwalk::Presenter

        field :title, :default_when => :nil?
      end
      """

  @default @field
  Scenario: default_when specified
    When I set up my presenter for my model
      """
      @model = MyActiveModel.new
      @model.title = 'a value'
      @presenter = MyModelPresenter.new @model
      """
    Then my presenter should present "title" from my model

  @default @field @defaulted
  Scenario: default_when specified, and criteria matched
    When I set up my presenter for my model
      """
      @model = MyActiveModel.new
      @presenter = MyModelPresenter.new @model
      """
    But my model's "title" attribute is nil
    Then my presenter should present "title" as "Not Set"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
catwalk-0.0.3 features/field_with_default_when_specified.feature
catwalk-0.0.2 features/field_with_default_when_specified.feature