| 
31 | 31 | }  | 
32 | 32 | EOS  | 
33 | 33 | 
 
  | 
 | 34 | +GROUP_SUMMARY = <<"EOS"  | 
 | 35 | +{  | 
 | 36 | +    "groupId": "group_id",  | 
 | 37 | +    "groupName": "Group name",  | 
 | 38 | +    "pictureUrl":"https://example.com/abcdefghijklmn"  | 
 | 39 | +}  | 
 | 40 | +EOS  | 
 | 41 | + | 
 | 42 | +GROUP_MEMBERS_COUNT = <<"EOS"  | 
 | 43 | +{  | 
 | 44 | +   "count": 3  | 
 | 45 | +}  | 
 | 46 | +EOS  | 
 | 47 | + | 
 | 48 | +ROOM_MEMBERS_COUNT = <<"EOS"  | 
 | 49 | +{  | 
 | 50 | +   "count": 3  | 
 | 51 | +}  | 
 | 52 | +EOS  | 
 | 53 | + | 
34 | 54 | WebMock.allow_net_connect!  | 
35 | 55 | 
 
  | 
36 | 56 | describe Line::Bot::Client do  | 
@@ -136,4 +156,45 @@ def generate_client  | 
136 | 156 |     expect(contact['displayName']).to eq "LINE taro"  | 
137 | 157 |     expect(contact['pictureUrl']).to eq "http://obs.line-apps.com/image"  | 
138 | 158 |   end  | 
 | 159 | + | 
 | 160 | +  it 'gets group summary' do  | 
 | 161 | +    uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/group/{groupId}/summary'  | 
 | 162 | +    stub_request(:get, uri_template).to_return { |request| {body: GROUP_SUMMARY, status: 200} }  | 
 | 163 | + | 
 | 164 | +    client = generate_client  | 
 | 165 | +    group_id = "group_id"  | 
 | 166 | + | 
 | 167 | +    response = client.get_group_summary(group_id)  | 
 | 168 | + | 
 | 169 | +    contact = JSON.parse(response.body)  | 
 | 170 | +    expect(contact['groupId']).to eq "group_id"  | 
 | 171 | +    expect(contact['groupName']).to eq "Group name"  | 
 | 172 | +    expect(contact['pictureUrl']).to eq "https://example.com/abcdefghijklmn"  | 
 | 173 | +  end  | 
 | 174 | + | 
 | 175 | +  it 'gets group members count' do  | 
 | 176 | +    uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/group/{groupId}/members/count'  | 
 | 177 | +    stub_request(:get, uri_template).to_return { |request| {body: GROUP_MEMBERS_COUNT, status: 200} }  | 
 | 178 | + | 
 | 179 | +    client = generate_client  | 
 | 180 | +    group_id = "group_id"  | 
 | 181 | + | 
 | 182 | +    response = client.get_group_members_count(group_id)  | 
 | 183 | + | 
 | 184 | +    contact = JSON.parse(response.body)  | 
 | 185 | +    expect(contact['count']).to eq 3  | 
 | 186 | +  end  | 
 | 187 | + | 
 | 188 | +  it 'gets group members count' do  | 
 | 189 | +    uri_template = Addressable::Template.new Line::Bot::API::DEFAULT_ENDPOINT + '/bot/room/{roomId}/members/count'  | 
 | 190 | +    stub_request(:get, uri_template).to_return { |request| {body: ROOM_MEMBERS_COUNT, status: 200} }  | 
 | 191 | + | 
 | 192 | +    client = generate_client  | 
 | 193 | +    room_id = "room_id"  | 
 | 194 | + | 
 | 195 | +    response = client.get_room_members_count(room_id)  | 
 | 196 | + | 
 | 197 | +    contact = JSON.parse(response.body)  | 
 | 198 | +    expect(contact['count']).to eq 3  | 
 | 199 | +  end  | 
139 | 200 | end  | 
0 commit comments