Skip to content

Commit

Permalink
implemented #current? for party_membership and #empty? for reponse
Browse files Browse the repository at this point in the history
  • Loading branch information
giusepped committed Feb 15, 2017
1 parent 6d36c44 commit 6f7934d
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/parliament/decorators/party_membership.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ def start_date
def end_date
respond_to?(:partyMembershipEndDate) ? DateTime.parse(partyMembershipEndDate) : nil
end

def current?
has_end_date = respond_to?(:partyMembershipEndDate)

!has_end_date
end
end
end
end
2 changes: 1 addition & 1 deletion lib/parliament/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Response
include Enumerable
extend Forwardable
attr_reader :nodes
def_delegators :@nodes, :size, :each, :select, :map, :select!, :map!, :count, :length, :[]
def_delegators :@nodes, :size, :each, :select, :map, :select!, :map!, :count, :length, :[], :empty?

def initialize(nodes)
@nodes = nodes
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions spec/parliament/decorators/party_membership_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,12 @@
end
end
end

describe '#current?' do
it 'Grom::Node returns the correct value for a current or non current party membership' do
party_membership_results = @party_membership_nodes.map(&:current?)

expect(party_membership_results).to eq([false, true])
end
end
end
4 changes: 4 additions & 0 deletions spec/parliament/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
it 'should respond to []' do
expect(subject).to respond_to(:[])
end

it 'should respond to empty?' do
expect(subject).to respond_to(:empty?)
end
end

describe '#filter' do
Expand Down

0 comments on commit 6f7934d

Please sign in to comment.