Skip to content

Commit a5d1f1a

Browse files
committed
Upgraded to Rubocop 1.16.0.
1 parent 61e5cf9 commit a5d1f1a

File tree

4 files changed

+28
-23
lines changed

4 files changed

+28
-23
lines changed

.rubocop.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,7 @@ Blocks:
6363
WordArray:
6464
# %w vs. [ '', ... ]
6565
Enabled: false
66+
67+
CyclomaticComplexity:
68+
Enabled: false
69+

Gemfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ group :development, :test do
1313
gem 'rspec'
1414
gem 'rack-test', "~> 0.6.2", :require => "rack/test"
1515
gem 'github-markup'
16-
gem 'rubocop', '~> 0.14.1'
16+
gem 'rubocop', '~> 0.16.0'
1717
end
1818

1919
platforms :rbx do
2020
gem 'rubysl', '~> 2.0'
21-
gem 'parser', '2.1.0.pre1'
21+
gem 'parser', '~> 2.1'
2222
end

lib/grape_entity/entity.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,5 @@ def self.merge_options(options)
473473
final.merge(step, &merge_logic)
474474
}.merge(options, &merge_logic)
475475
end
476-
477476
end
478477
end

spec/grape_entity/entity_spec.rb

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
end
2828

2929
it 'makes sure that :format_with as a proc cannot be used with a block' do
30-
expect { subject.expose :name, format_with: proc { } { } }.to raise_error ArgumentError
30+
expect { subject.expose :name, format_with: proc {} {} }.to raise_error ArgumentError
3131
end
3232
end
3333

@@ -51,23 +51,26 @@
5151
module EntitySpec
5252
class SomeObject1
5353
attr_accessor :prop1
54-
54+
5555
def initialize
5656
@prop1 = "value1"
5757
end
5858
end
59-
59+
6060
class BogusEntity < Grape::Entity
6161
expose :prop1
6262
end
6363
end
6464

65-
subject.expose(:bogus, using: EntitySpec::BogusEntity) { self.object.prop1 = "MODIFIED 2"; self.object }
66-
65+
subject.expose(:bogus, using: EntitySpec::BogusEntity) do
66+
object.prop1 = "MODIFIED 2"
67+
object
68+
end
69+
6770
object = EntitySpec::SomeObject1.new
6871
value = subject.represent(object).send(:value_for, :bogus)
6972
value.should be_instance_of EntitySpec::BogusEntity
70-
73+
7174
prop1 = value.send(:value_for, :prop1)
7275
prop1.should == "MODIFIED 2"
7376
end
@@ -131,21 +134,21 @@ class BogusEntity < Grape::Entity
131134
model = { birthday: Time.gm(2012, 2, 27) }
132135
subject.new(double(model)).as_json[:birthday].should == '02/27/2012'
133136
end
134-
137+
135138
it 'formats an exposure with a :format_with lambda that returns a value from the entity instance' do
136139
object = Hash.new
137-
138-
subject.expose(:size, format_with: lambda{|value| self.object.class.to_s})
140+
141+
subject.expose(:size, format_with: lambda { |value| self.object.class.to_s })
139142
subject.represent(object).send(:value_for, :size).should == object.class.to_s
140143
end
141-
144+
142145
it 'formats an exposure with a :format_with symbol that returns a value from the entity instance' do
143146
subject.format_with :size_formatter do |date|
144147
self.object.class.to_s
145148
end
146149

147150
object = Hash.new
148-
151+
149152
subject.expose(:size, format_with: :size_formatter)
150153
subject.represent(object).send(:value_for, :size).should == object.class.to_s
151154
end
@@ -512,7 +515,6 @@ class TestEntity < Grape::Entity
512515

513516
context '#serializable_hash' do
514517
module EntitySpec
515-
516518
class EmbeddedExample
517519
def serializable_hash(opts = {})
518520
{ abc: 'def' }
@@ -697,7 +699,7 @@ class FriendEntity < Grape::Entity
697699
rep.first.serializable_hash[:email].should be_nil
698700
rep.last.serializable_hash[:email].should be_nil
699701

700-
rep = subject.send(:value_for, :friends, { user_type: :admin })
702+
rep = subject.send(:value_for, :friends, user_type: :admin)
701703
rep.should be_kind_of Array
702704
rep.reject { |r| r.is_a?(EntitySpec::FriendEntity) }.should be_empty
703705
rep.first.serializable_hash[:email].should == '[email protected]'
@@ -717,7 +719,7 @@ class FriendEntity < Grape::Entity
717719
expose :friends, using: EntitySpec::FriendEntity
718720
end
719721

720-
rep = subject.send(:value_for, :friends, { collection: false })
722+
rep = subject.send(:value_for, :friends, collection: false)
721723
rep.should be_kind_of Array
722724
rep.reject { |r| r.is_a?(EntitySpec::FriendEntity) }.should be_empty
723725
rep.first.serializable_hash[:email].should == '[email protected]'
@@ -818,18 +820,18 @@ def name
818820
exposure_options = { if: :condition1 }
819821

820822
subject.send(:conditions_met?, exposure_options, {}).should be_false
821-
subject.send(:conditions_met?, exposure_options, { condition1: true }).should be_true
822-
subject.send(:conditions_met?, exposure_options, { condition1: false }).should be_false
823-
subject.send(:conditions_met?, exposure_options, { condition1: nil }).should be_false
823+
subject.send(:conditions_met?, exposure_options, condition1: true).should be_true
824+
subject.send(:conditions_met?, exposure_options, condition1: false).should be_false
825+
subject.send(:conditions_met?, exposure_options, condition1: nil).should be_false
824826
end
825827

826828
it 'looks for absence/falsiness if a symbol is passed' do
827829
exposure_options = { unless: :condition1 }
828830

829831
subject.send(:conditions_met?, exposure_options, {}).should be_true
830-
subject.send(:conditions_met?, exposure_options, { condition1: true }).should be_false
831-
subject.send(:conditions_met?, exposure_options, { condition1: false }).should be_true
832-
subject.send(:conditions_met?, exposure_options, { condition1: nil }).should be_true
832+
subject.send(:conditions_met?, exposure_options, condition1: true).should be_false
833+
subject.send(:conditions_met?, exposure_options, condition1: false).should be_true
834+
subject.send(:conditions_met?, exposure_options, condition1: nil).should be_true
833835
end
834836

835837
it 'only passes through proc :if exposure if it returns truthy value' do

0 commit comments

Comments
 (0)