Sha256: 95a39336a8b8b3d71aa7c3087c46418fcea26b9f9ecb38c1ddde070bf4d3e63a

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

require "rspec/parameterized/version"

module RSpec
  module Parameterized
    module ExampleGroupMethods

      # Set parameters to be bound in specs under this example group.
      #
      # ## Example
      #
      #     where(:a, :b, :answer) do
      #       [
      #         [1 , 2 , 3],
      #         [5 , 8 , 13],
      #         [0 , 0 , 0]
      #       ]
      #     end
      #
      def where(*args, &b)
        @arg_names = args
        @param_sets = b.call
      end

      # Use parameters to execute the block.
      # The given block is converted into +describe+s for each parameter set.
      #
      # ## Example
      #     with_them do
      #       it "should do additions" do
      #         (a + b).should == answer
      #       end
      #     end
      #
      def with_them(*args, &block)
        arg_names = @arg_names
        @param_sets.each do |params|
          describe(params.inspect, *args) do
            [arg_names, params].transpose.each do |n|
              let(n[0]) { n[1] }
            end

            module_eval(&block)
          end
        end
      end
    end
  end

  module Core
    class ExampleGroup
      extend ::RSpec::Parameterized::ExampleGroupMethods
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-parameterized-0.0.1 lib/rspec/parameterized.rb