Sha256: d331e19621b7915cd23aa538e9c63f9c937a441b8455dab4f30c6d0aca0cb295

Contents?: true

Size: 759 Bytes

Versions: 4

Compression:

Stored size: 759 Bytes

Contents

module Spec
  module Rails
    module Example
      class AssignsHashProxy #:nodoc:
        def initialize(example_group, &block)
          @target = block.call
          @example_group = example_group
        end

        def [](key)
          assigns[key] || assigns[key.to_s] || @target.instance_variable_get("@#{key}")
        end

        def []=(key, val)
          @target.instance_variable_set("@#{key}", val)
        end

        def delete(key)
          assigns.delete(key.to_s)
        end

        def each(&block)
          assigns.each &block
        end

        def has_key?(key)
          assigns.key?(key.to_s)
        end

        protected
        def assigns
          @example_group.orig_assigns
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
dchelimsky-rspec-rails-1.1.6 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.7 lib/spec/rails/example/assigns_hash_proxy.rb
rspec-rails-1.1.7 lib/spec/rails/example/assigns_hash_proxy.rb
rspec-rails-1.1.6 lib/spec/rails/example/assigns_hash_proxy.rb