Sha256: 6ede387ecf68105847531e5a1a2f89f87e0bfa3863a86bb0761d0efacce4fe36

Contents?: true

Size: 1.14 KB

Versions: 51

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
          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:
      """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
            help.should be(:available)
          end
        end
      end
      """
    When I run `rspec example_spec.rb`
    Then the examples should all pass

Version data entries

51 entries across 51 versions & 13 rubygems

Version Path
vagrant-unbundled-2.2.7.0 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/features/helper_methods/arbitrary_methods.feature
vagrant-unbundled-1.9.5.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/features/helper_methods/arbitrary_methods.feature
vagrant-unbundled-1.9.1.1 vendor/bundle/ruby/2.4.0/gems/rspec-core-2.14.8/features/helper_methods/arbitrary_methods.feature
vagrant-unbundled-1.8.5.2 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/features/helper_methods/arbitrary_methods.feature
vagrant-unbundled-1.8.5.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/features/helper_methods/arbitrary_methods.feature
vagrant-unbundled-1.8.4.2 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/features/helper_methods/arbitrary_methods.feature
vagrant-unbundled-1.8.4.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/features/helper_methods/arbitrary_methods.feature
vagrant-unbundled-1.8.1.1 vendor/bundle/ruby/2.3.0/gems/rspec-core-2.14.8/features/helper_methods/arbitrary_methods.feature
vagrant-cloudstack-1.1.0 vendor/bundle/gems/rspec-core-2.14.8/features/helper_methods/arbitrary_methods.feature
judge-2.0.5 vendor/bundle/ruby/2.1.0/gems/rspec-core-2.13.0/features/helper_methods/arbitrary_methods.feature
rspec-core-2.99.2 features/helper_methods/arbitrary_methods.feature
dxruby_rp5-0.0.4 spec/vendor/rspec-core-2.14.7/features/helper_methods/arbitrary_methods.feature
rspec-core-2.99.1 features/helper_methods/arbitrary_methods.feature
rspec-core-2.99.0 features/helper_methods/arbitrary_methods.feature
rspec-core-2.99.0.rc1 features/helper_methods/arbitrary_methods.feature
rspec-core-2.14.8 features/helper_methods/arbitrary_methods.feature
rspec-core-2.99.0.beta2 features/helper_methods/arbitrary_methods.feature
mango-0.8.0 vendor/bundler/ruby/2.1.0/gems/rspec-core-2.14.7/features/helper_methods/arbitrary_methods.feature
mango-0.7.1 vendor/bundler/ruby/2.0.0/gems/rspec-core-2.14.7/features/helper_methods/arbitrary_methods.feature
dxruby_rp5-0.0.3 spec/vendor/rspec-core-2.14.7/features/helper_methods/arbitrary_methods.feature