Sha256: 391e87b0cf9ca157126317a58e500444a7087246829f84fa1e1f404887824c3f

Contents?: true

Size: 1.16 KB

Versions: 12

Compression:

Stored size: 1.16 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
      RSpec.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
      RSpec.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

12 entries across 12 versions & 1 rubygems

Version Path
opal-rspec-1.1.0.alpha3 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-1.1.0.alpha2 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-1.1.0.alpha1 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-1.0.0 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-1.0.0.alpha1 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-0.8.0 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-0.8.0.alpha3 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-0.8.0.alpha2 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-0.8.0.alpha1 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-0.7.1 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-0.7.0 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature
opal-rspec-0.7.0.rc.2 rspec-core/upstream/features/helper_methods/arbitrary_methods.feature