Sha256: 7a40eab5f17af45a10a13291a574bec67afaf2690ce9b7b5788541148b34f5b7

Contents?: true

Size: 1.43 KB

Versions: 48

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:
      """ruby
      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:
      """ruby
      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 match /undefined.*method/
    And the output should contain "RSpec::Matchers::DSL::Matcher"
    And the output should not contain "ExampleGroup"

Version data entries

48 entries across 48 versions & 14 rubygems

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