Changed up spec_helper a bit, added respond_to? on Mash
This commit is contained in:
parent
ec359f4bd9
commit
97135789e6
3
Gemfile
3
Gemfile
|
@ -1,9 +1,10 @@
|
|||
# A sample Gemfile
|
||||
source :gemcutter
|
||||
source 'http://rubygems.org'
|
||||
|
||||
group :development do
|
||||
gem 'rake'
|
||||
gem 'json'
|
||||
gem 'jeweler'
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
|
49
Gemfile.lock
49
Gemfile.lock
|
@ -1,25 +1,24 @@
|
|||
---
|
||||
dependencies:
|
||||
rake:
|
||||
group:
|
||||
- :development
|
||||
version: ">= 0"
|
||||
rspec:
|
||||
group:
|
||||
- :test
|
||||
version: ">= 0"
|
||||
json:
|
||||
group:
|
||||
- :development
|
||||
version: ">= 0"
|
||||
specs:
|
||||
- rake:
|
||||
version: 0.8.7
|
||||
- json:
|
||||
version: 1.4.3
|
||||
- rspec:
|
||||
version: 1.3.0
|
||||
hash: d9c314ac1790a9ac25dfdaf7574b86d62b88f1d5
|
||||
sources:
|
||||
- Rubygems:
|
||||
uri: http://gemcutter.org
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
gemcutter (0.6.1)
|
||||
git (1.2.5)
|
||||
jeweler (1.4.0)
|
||||
gemcutter (>= 0.1.0)
|
||||
git (>= 1.2.5)
|
||||
rubyforge (>= 2.0.0)
|
||||
json (1.4.3)
|
||||
json_pure (1.4.3)
|
||||
rake (0.8.7)
|
||||
rspec (1.3.0)
|
||||
rubyforge (2.0.4)
|
||||
json_pure (>= 1.1.7)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
jeweler
|
||||
json
|
||||
rake
|
||||
rspec
|
||||
|
|
|
@ -111,7 +111,13 @@ module Hashie
|
|||
alias_method :update, :deep_update
|
||||
alias_method :merge!, :update
|
||||
|
||||
|
||||
# Will return true if the Mash has had a key
|
||||
# set in addition to normal respond_to? functionality.
|
||||
def respond_to?(method_name)
|
||||
return true if key?(method_name)
|
||||
super
|
||||
end
|
||||
|
||||
def method_missing(method_name, *args, &blk)
|
||||
return self[method_name] if key?(method_name)
|
||||
match = method_name.to_s.match(/(.*?)([?=!]?)$/)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
require 'spec_helper'
|
||||
|
||||
describe Hashie::Clash do
|
||||
before do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
require 'spec_helper'
|
||||
|
||||
class DashTest < Hashie::Dash
|
||||
property :first_name
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
require 'spec_helper'
|
||||
|
||||
describe Hash do
|
||||
it "should be convertible to a Hashie::Mash" do
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
require 'spec_helper'
|
||||
|
||||
describe Hashie::Mash do
|
||||
before(:each) do
|
||||
|
@ -82,6 +82,16 @@ describe Hashie::Mash do
|
|||
record.son = MyMash.new
|
||||
record.son.class.should == MyMash
|
||||
end
|
||||
|
||||
describe '#respond_to?' do
|
||||
it 'should respond to a normal method' do
|
||||
Hashie::Mash.new.should be_respond_to(:key?)
|
||||
end
|
||||
|
||||
it 'should respond to a set key' do
|
||||
Hashie::Mash.new(:abc => 'def').should be_respond_to(:abc)
|
||||
end
|
||||
end
|
||||
|
||||
context "#initialize" do
|
||||
it "should convert an existing hash to a Hashie::Mash" do
|
||||
|
|
Loading…
Reference in New Issue