Sha256: 7261f72a41bf4b950858f810c472a18b5142788a18adaefe60c5a20cdbabe4e5

Contents?: true

Size: 941 Bytes

Versions: 7

Compression:

Stored size: 941 Bytes

Contents

Feature: each attribute of subject

  Use the each() method as a short-hand to generate a nested example group with
  a single example that specifies the expected value of each attribute of the
  subject.  This can be used with an implicit or explicit subject.

  each() accepts a symbol or a string, and a block representing the example.

      each(:item)     { should be_an(Item)    }
      each("article") { should be_an(Article) }

  Scenario: specify value of each attribute
    Given a file named "example_spec.rb" with:
      """
      require 'rspec-subject-extensions'

      class Movie
        def ratings
          [9, 7, 9]
        end
      end

      describe Movie do
        each(:rating) { should be_an(Integer) }
      end
      """
    When I run `rspec example_spec.rb --format documentation`
    Then the output should contain:
      """
      Movie
        each rating
          should be a kind of Integer
      """

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rspec-subject-extensions-0.3.2 features/class_methods/each_attribute_of_subject.feature
rspec-subject-extensions-0.3.1 features/class_methods/each_attribute_of_subject.feature
rspec-subject-extensions-0.3.0 features/class_methods/each_attribute_of_subject.feature
rspec-subject-extensions-0.2.3 features/class_methods/each_attribute_of_subject.feature
rspec-subject-extensions-0.2.2 features/class_methods/each_attribute_of_subject.feature
rspec-subject-extensions-0.2.1 features/class_methods/each_attribute_of_subject.feature
rspec-subject-extensions-0.2.0 features/class_methods/each_attribute_of_subject.feature