Sha256: e210b1030faf486747b8f9759554139e1e1c57f6e3eb5f3c6372a2648539c5ec

Contents?: true

Size: 856 Bytes

Versions: 6

Compression:

Stored size: 856 Bytes

Contents

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

        def [](ivar)
          if assigns.include?(ivar.to_s)
            assigns[ivar.to_s]
          elsif assigns.include?(ivar)
            assigns[ivar]
          else
            nil
          end
        end

        def []=(ivar, val)
          @block.call.instance_variable_set("@#{ivar}", val)
        end

        def delete(name)
          assigns.delete(name.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

6 entries across 6 versions & 3 rubygems

Version Path
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
pictrails-0.5.0 vendor/plugins/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb
rspec-rails-1.1.5 lib/spec/rails/example/assigns_hash_proxy.rb