Skip to content

Commit 69612b2

Browse files
committed
Add rspec for mashify
Parse a hash to convert it into a hashie mash.
1 parent 53ecf0d commit 69612b2

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
require 'spec_helper'
2+
3+
describe BitBucket::Response::Mashify do
4+
# let(:mashify) { described_class.new }
5+
describe 'parse' do
6+
before do
7+
@mashify = BitBucket::Response::Mashify.new
8+
@string = "Fantastic week!"
9+
@array = ['Monday', 'Tuesday']
10+
@hash = {one: 'one', two: 'two', three: 'three'}
11+
@array_with_hash = ['banana', 'apple', {:third => 'mango'}]
12+
end
13+
it 'parses a hash an returns a hashie mash' do
14+
hashie_mash = @mashify.parse(@hash)
15+
expect(hashie_mash.one).to eq("one")
16+
end
17+
18+
it 'parses a hash that is within an array' do
19+
array_hashie_mash = @mashify.parse(@array_with_hash)
20+
expect(array_hashie_mash[2].third).to eq("mango")
21+
end
22+
23+
it 'returns same object if the object does not contain a hash' do
24+
string = @mashify.parse(@string)
25+
array = @mashify.parse(@array)
26+
27+
expect(string).to eq(@string)
28+
expect(array.length).to eq(2)
29+
expect(array[0]).to eq("Monday")
30+
end
31+
end
32+
end

0 commit comments

Comments
 (0)