Sha256: 0535ac61c1287390de50c93bfebf9249cf778c2fb205206d7b402c561b779fc0

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 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:
      """
      describe "an example" do
        def help
          :available
        end

        it "has access to methods defined in its group" do
          help.should 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:
      """
      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
            help.should be(:available)
          end
        end
      end
      """
    When I run "rspec example_spec.rb"
    Then the examples should all pass

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rspec-core-2.5.1/features/helper_methods/arbitrary_methods.feature
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-core-2.5.1/features/helper_methods/arbitrary_methods.feature
rspec-core-2.5.2 features/helper_methods/arbitrary_methods.feature
rspec-core-2.5.1 features/helper_methods/arbitrary_methods.feature
rspec-core-2.5.0 features/helper_methods/arbitrary_methods.feature