Skip to content

Commit d8b83c5

Browse files
author
Sam Davies
committed
Suppress warnings with key/in-built method collisions
- Use a new subclass of Hashie::Mash called Github::Mash - Fixes piotrmurach#298
1 parent 807507a commit d8b83c5

11 files changed

Lines changed: 30 additions & 9 deletions

File tree

lib/github_api/mash.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Github
2+
class Mash < ::Hashie::Mash
3+
disable_warnings
4+
end
5+
end

lib/github_api/response/mashify.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
require 'faraday'
44
require 'hashie'
5+
require 'github_api/mash'
56

67
module Github
78
class Response::Mashify < Response
89
dependency 'hashie/mash'
910

1011
define_parser do |body|
11-
::Hashie::Mash.new body
12+
::Github::Mash.new body
1213
end
1314

1415
def parse(body)

spec/github/client/git_data/references/create_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
it "should return the resource" do
5353
reference = subject.create user, repo, inputs
54-
reference.first.should be_a Hashie::Mash
54+
reference.first.should be_a Github::Mash
5555
end
5656

5757
it "should get the reference information" do

spec/github/client/git_data/references/get_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
it "should return mash" do
4747
reference = subject.get user, repo, ref
48-
reference.first.should be_a Hashie::Mash
48+
reference.first.should be_a Github::Mash
4949
end
5050
end
5151

spec/github/client/git_data/references/list_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878

7979
it "should be a mash type" do
8080
references = subject.list user, repo, :ref => ref
81-
references.first.should be_a Hashie::Mash
81+
references.first.should be_a Github::Mash
8282
end
8383

8484
it "should get reference information" do

spec/github/client/git_data/references/update_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
it "should return the resource" do
4848
reference = subject.update user, repo, ref, inputs
49-
reference.first.should be_a Hashie::Mash
49+
reference.first.should be_a Github::Mash
5050
end
5151

5252
it "should get the reference information" do

spec/github/client/issues/labels/add_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
it "should return the resource" do
3737
labels = subject.add user, repo, issue_id, label
38-
labels.first.should be_a Hashie::Mash
38+
labels.first.should be_a Github::Mash
3939
end
4040

4141
it "should get the label information" do

spec/github/client/issues/labels/remove_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
it "should return the resource" do
3333
labels = subject.remove user, repo, number, :label_name => label_name
34-
labels.first.should be_a Hashie::Mash
34+
labels.first.should be_a Github::Mash
3535
end
3636

3737
it "should get the label information" do

spec/github/client/issues/labels/replace_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
it "should return the resource" do
3535
labels = subject.replace user, repo, number, label
36-
labels.first.should be_a Hashie::Mash
36+
labels.first.should be_a Github::Mash
3737
end
3838

3939
it "should get the label information" do

spec/github/mash_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# encoding: utf-8
2+
3+
require 'spec_helper'
4+
require 'github_api/mash'
5+
6+
describe Github::Mash do
7+
it 'suppresses warnings for key/method conflict' do
8+
expect(Hashie.logger).to_not receive(:warn)
9+
Github::Mash.new(size: 1)
10+
end
11+
12+
it 'inherits from Hashie::Mash' do
13+
expect(Github::Mash.new(size: 1)).to be_a(::Hashie::Mash)
14+
end
15+
end

0 commit comments

Comments
 (0)