Sha256: 84f694294cd254424fcd294160ad0458833ad1d824cdd8a8412a67cba86c9a8c

Contents?: true

Size: 1.43 KB

Versions: 179

Compression:

Stored size: 1.43 KB

Contents

Feature: access running example

  In order to take advantage of services that are available
    in my examples when I'm writing matchers
  As a spec author
  I want to call methods on the running example

  If the method exists in the context of the example, it gets
  called. If not, a NoMethodError is raised on the Matcher itself
  (not the example).

  Scenario: call method defined on example from matcher
    Given a file named "example_spec.rb" with:
      """
      RSpec::Matchers.define :bar do
        match do |_|
          foo == "foo"
        end
      end

      describe "something" do
        def foo
          "foo"
        end

        it "does something" do
          "foo".should bar
        end
      end
      """
    When I run `rspec ./example_spec.rb`
    Then the output should contain "1 example, 0 failures"

  Scenario: call method _not_ defined on example from matcher
    Given a file named "example_spec.rb" with:
      """
      RSpec::Matchers.define :bar do
        match do |_|
          foo == "foo"
        end
      end

      describe "something" do
        it "does something" do
          "foo".should bar
        end
      end
      """
    When I run `rspec ./example_spec.rb`
    Then the output should contain "1 example, 1 failure"
    And the output should contain "undefined local variable"
    And the output should contain "RSpec::Matchers::DSL::Matcher"
    And the output should not contain "ExampleGroup"

Version data entries

179 entries across 81 versions & 13 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.1/features/custom_matchers/access_running_example.feature
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.10.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.5 vendor/bundle/gems/rspec-expectations-2.9.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.10.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.4 vendor/bundle/gems/rspec-expectations-2.9.1/features/custom_matchers/access_running_example.feature
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.1/features/custom_matchers/access_running_example.feature
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.9.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.3 vendor/bundle/gems/rspec-expectations-2.10.0/features/custom_matchers/access_running_example.feature
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/features/custom_matchers/access_running_example.feature
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/rspec-expectations-2.11.3/features/custom_matchers/access_running_example.feature
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.10.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.1/features/custom_matchers/access_running_example.feature
classiccms-0.7.2 vendor/bundle/gems/rspec-expectations-2.9.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.10.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.1 vendor/bundle/gems/rspec-expectations-2.9.1/features/custom_matchers/access_running_example.feature
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.10.0/features/custom_matchers/access_running_example.feature
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.9.1/features/custom_matchers/access_running_example.feature
classiccms-0.7.0 vendor/bundle/gems/rspec-expectations-2.9.0/features/custom_matchers/access_running_example.feature