Sha256: 2fbb1c3f709ddd9161da13aa1929cad13988d159570fe92984e65a11ada75230

Contents?: true

Size: 1.29 KB

Versions: 22

Compression:

Stored size: 1.29 KB

Contents

require File.dirname(__FILE__) + '/../../spec_helper'

describe "An AssignsHashProxy" do
  before(:each) do
    @object = Object.new
    @assigns = Hash.new
    @object.stub!(:assigns).and_return(@assigns)
    @proxy = Spec::Rails::Example::AssignsHashProxy.new(@object)
  end

  it "has [] accessor" do
    @proxy['foo'] = 'bar'
    @assigns['foo'].should == 'bar'
    @proxy['foo'].should == 'bar'
  end

  it "works for symbol key" do
    @assigns[:foo] = 2
    @proxy[:foo].should == 2
  end

  it "checks for string key before symbol key" do
    @assigns['foo'] = false
    @assigns[:foo] = 2
    @proxy[:foo].should == false
  end

  it "each method iterates through each element like a Hash" do
    values = {
      'foo' => 1,
      'bar' => 2,
      'baz' => 3
    }
    @proxy['foo'] = values['foo']
    @proxy['bar'] = values['bar']
    @proxy['baz'] = values['baz']

    @proxy.each do |key, value|
      key.should == key
      value.should == values[key]
    end
  end

  it "delete method deletes the element of passed in key" do
    @proxy['foo'] = 'bar'
    @proxy.delete('foo').should == 'bar'
    @proxy['foo'].should be_nil
  end

  it "has_key? detects the presence of a key" do
    @proxy['foo'] = 'bar'
    @proxy.has_key?('foo').should == true
    @proxy.has_key?('bar').should == false
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
picolena-0.0.99 app_generators/picolena/templates/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
picolena-0.1.1 rails_plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
picolena-0.1.0 rails_plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
picolena-0.1.4 rails_plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
picolena-0.1.3 rails_plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
picolena-0.1.2 rails_plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
picolena-0.1.5 rails_plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
picolena-0.1.6 rails_plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
picolena-0.1.7 rails_plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
picolena-0.1.8 rails_plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
spree-0.0.9 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
spree-0.0.8 starter-app/vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
spree-0.2.0 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
typo-5.0.2 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
typo-5.0.1 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
typo-5.0.3.98.1 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
typo-5.0.3.98 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
typo-5.0 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
typo-5.1.1 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb
typo-5.1.2 vendor/plugins/rspec_on_rails/spec/rails/example/assigns_hash_proxy_spec.rb