Sha256: cb5f79b0187d4422b1d7a245e963ed174a84fe49f9f62d9aa076a2a4e04af532

Contents?: true

Size: 916 Bytes

Versions: 28

Compression:

Stored size: 916 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)
          return false if assigns[key] == false
          return false if assigns[key.to_s] == false
          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)
          @target.instance_variable_set("@#{key}", nil)
        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

28 entries across 28 versions & 4 rubygems

Version Path
dchelimsky-rspec-rails-1.1.10 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.11.1 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.11.2 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.11.3 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.11.4 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.11.5 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.11.6 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.11.7 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.11 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.12 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.8 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.9 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.99.1 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.99.2 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.99.3 lib/spec/rails/example/assigns_hash_proxy.rb
dchelimsky-rspec-rails-1.1.99.4 lib/spec/rails/example/assigns_hash_proxy.rb
rspec-rails-1.1.11 lib/spec/rails/example/assigns_hash_proxy.rb
rspec-rails-1.1.10 lib/spec/rails/example/assigns_hash_proxy.rb
rspec-rails-1.1.12 lib/spec/rails/example/assigns_hash_proxy.rb
rspec-rails-1.1.8 lib/spec/rails/example/assigns_hash_proxy.rb