Permalink
Browse files

Changed up spec_helper a bit, added respond_to? on Mash

  • Loading branch information...
1 parent ec359f4 commit 97135789e63644140599b353beee8f9f1084cfe0 Michael Bleigh committed Jul 29, 2010
Showing with 47 additions and 31 deletions.
  1. +2 −1 Gemfile
  2. +24 −25 Gemfile.lock
  3. +7 −1 lib/hashie/mash.rb
  4. +1 −1 spec/hashie/clash_spec.rb
  5. +1 −1 spec/hashie/dash_spec.rb
  6. +1 −1 spec/hashie/hash_spec.rb
  7. +11 −1 spec/hashie/mash_spec.rb
View
@@ -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
View
@@ -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
View
@@ -111,7 +111,13 @@ def deep_update(other_hash)
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
View
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
class DashTest < Hashie::Dash
property :first_name
View
@@ -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
View
@@ -1,4 +1,4 @@
-require File.dirname(__FILE__) + '/../spec_helper'
+require 'spec_helper'
describe Hashie::Mash do
before(:each) do
@@ -82,6 +82,16 @@ class MyMash < Hashie::Mash
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

0 comments on commit 9713578

Please sign in to comment.