Sha256: cbb7e8da3e10226900c5dfa581693e5c2d66a8e1152041cdeaee384c6653661d

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

Feature: arbitrary helper methods

  You can define methods in any example group using Ruby's `def` keyword or
  `define_method` method. These _helper_ methods are exposed to examples in the
  group in which they are defined and groups nested within that group, but not
  parent or sibling groups.

  Scenario: use a method defined in the same group
    Given a file named "example_spec.rb" with:
      """ruby
      describe "an example" do
        def help
          :available
        end

        it "has access to methods defined in its group" do
          expect(help).to be(:available)
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the examples should all pass

  Scenario: use a method defined in a parent group
    Given a file named "example_spec.rb" with:
      """ruby
      describe "an example" do
        def help
          :available
        end

        describe "in a nested group" do
          it "has access to methods defined in its parent group" do
            expect(help).to be(:available)
          end
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the examples should all pass

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rspec-core-3.0.0.beta2 features/helper_methods/arbitrary_methods.feature
rspec-core-3.0.0.beta1 features/helper_methods/arbitrary_methods.feature