Skip to content

Commit

Permalink
Using newest rspec-rails and upgrade rspec-mocks from 3.10.2 to 3.12.5
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Guo committed Apr 27, 2023
1 parent 8eef832 commit e104ffa
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 149 deletions.
160 changes: 80 additions & 80 deletions spec/lib/wechat/api_spec.rb

Large diffs are not rendered by default.

98 changes: 49 additions & 49 deletions spec/lib/wechat/corp_api_spec.rb

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions spec/lib/wechat/draft_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
]
}
result = { media_id: 'MEDIA_ID' }
expect(subject.client).to receive(:post).with('draft/add', draft_news.to_json, params: { access_token: 'access_token' }).and_return(result)
expect(subject.client).to receive(:post).with('draft/add', draft_news.to_json, hash_including(params: { access_token: 'access_token' })).and_return(result)
expect(subject.draft_add(Wechat::Message.new(MsgType: 'draft_news').draft_news(items))).to eq(result)
end
end
Expand All @@ -82,7 +82,7 @@
}

expect(subject.client).to receive(:post)
.with('draft/get', { media_id: 'media_id' }.to_json, params: { access_token: 'access_token' }).and_return(news_item_result)
.with('draft/get', { media_id: 'media_id' }.to_json, hash_including(params: { access_token: 'access_token' })).and_return(news_item_result)
expect(subject.draft_get('media_id')).to eq(news_item_result)
end
end
Expand All @@ -93,7 +93,7 @@
payload = { media_id: 'media_id' }
expect(subject.client).to receive(:post)
.with('draft/delete', payload.to_json,
params: { access_token: 'access_token' }).and_return(draft_delete_result)
hash_including(params: { access_token: 'access_token' })).and_return(draft_delete_result)
expect(subject.draft_delete('media_id')).to eq draft_delete_result
end
end
Expand All @@ -118,15 +118,15 @@
}
expect(subject.client).to receive(:post)
.with('draft/update', payload.to_json,
params: { access_token: 'access_token' }).and_return(draft_update_result)
hash_including(params: { access_token: 'access_token' })).and_return(draft_update_result)
expect(subject.draft_update('media_id', to_update_article, index: 1)).to eq draft_update_result
end
end

describe '#draft_count' do
specify 'will get draft_count' do
draft_count_result = { total_count: 1 }
expect(subject.client).to receive(:get).with('draft/count', params: { access_token: 'access_token' }).and_return(draft_count_result)
expect(subject.client).to receive(:get).with('draft/count', hash_including(params: { access_token: 'access_token' })).and_return(draft_count_result)
expect(subject.draft_count).to eq draft_count_result
end
end
Expand Down Expand Up @@ -155,7 +155,7 @@
},
update_time: 12345 }] }
expect(subject.client).to receive(:post)
.with('draft/batchget', draft_batchget_request.to_json, params: { access_token: 'access_token' }).and_return(draft_batchget_result)
.with('draft/batchget', draft_batchget_request.to_json, hash_including(params: { access_token: 'access_token' })).and_return(draft_batchget_result)
expect(subject.draft_batchget(0, 20)).to eq draft_batchget_result
end
end
Expand All @@ -165,7 +165,7 @@
draft_switch_result = { errcode: 123, errmsg: "ERRMSG", is_open: 1 }
expect(subject.client).to receive(:post)
.with('draft/switch', nil,
params: { access_token: 'access_token', checkonly: 1 }).and_return(draft_switch_result)
hash_including(params: { access_token: 'access_token', checkonly: 1 })).and_return(draft_switch_result)
expect(subject.draft_switch(checkonly: true)).to eq draft_switch_result
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/wechat/message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,10 @@

message = Wechat::Message.to('toUser')
expect(model_class).to receive(:new)
.with(to_user_name: 'toUser',
.with(hash_including(to_user_name: 'toUser',
msg_type: 'text',
content: 'text message',
create_time: message[:CreateTime]).and_return(model)
create_time: message[:CreateTime])).and_return(model)
expect(model).to receive(:save!).and_return(true)

expect(message.text('text message').save_to!(model_class)).to eq(message)
Expand Down
18 changes: 9 additions & 9 deletions spec/lib/wechat/mp_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

expect(subject.client).to receive(:post)
.with('message/wxopen/template/send', payload.to_json,
params: { access_token: 'access_token' }, content_type: :json).and_return(response_result)
hash_including(params: { access_token: 'access_token' }, content_type: :json)).and_return(response_result)

expect(subject.template_message_send(payload)).to eq response_result
end
Expand All @@ -53,7 +53,7 @@

expect(subject.client).to receive(:post)
.with('wxopen/template/library/list', { offset: 0, count: 5 }.to_json,
params: { access_token: 'access_token' }).and_return(response_result)
hash_including(params: { access_token: 'access_token' })).and_return(response_result)

expect(subject.list_template_library(count: 5)).to eq response_result
end
Expand All @@ -75,7 +75,7 @@

expect(subject.client).to receive(:post)
.with('wxopen/template/library/get', { id: 'AT0002' }.to_json,
params: { access_token: 'access_token' }).and_return(response_result)
hash_including(params: { access_token: 'access_token' })).and_return(response_result)

expect(subject.list_template_library_keywords('AT0002')).to eq response_result
end
Expand All @@ -91,7 +91,7 @@

expect(subject.client).to receive(:post)
.with('wxopen/template/add', { id: 'AT0002', keyword_id_list: [3, 4, 5] }.to_json,
params: { access_token: 'access_token' }).and_return(response_result)
hash_including(params: { access_token: 'access_token' })).and_return(response_result)

expect(subject.add_message_template('AT0002', [3, 4, 5])).to eq response_result
end
Expand All @@ -110,7 +110,7 @@

expect(subject.client).to receive(:post)
.with('wxopen/template/list', { offset: 0, count: 1 }.to_json,
params: { access_token: 'access_token' }).and_return(response_result)
hash_including(params: { access_token: 'access_token' })).and_return(response_result)

expect(subject.list_message_template(count: 1)).to eq response_result
end
Expand All @@ -125,7 +125,7 @@

expect(subject.client).to receive(:post)
.with('wxopen/template/del', { template_id: 'wDYzYZVxobJivW9oMpSCpuvACOfJXQIoKUm0PY397Tc' }.to_json,
params: { access_token: 'access_token' }).and_return(response_result)
hash_including(params: { access_token: 'access_token' })).and_return(response_result)

expect(subject.del_message_template('wDYzYZVxobJivW9oMpSCpuvACOfJXQIoKUm0PY397Tc')).to eq response_result
end
Expand All @@ -147,7 +147,7 @@

expect(subject.client).to receive(:post)
.with('message/subscribe/send', payload.to_json,
params: { access_token: 'access_token' }).and_return(response_result)
hash_including(params: { access_token: 'access_token' })).and_return(response_result)

expect(subject.subscribe_message_send(payload)).to eq response_result
end
Expand All @@ -162,8 +162,8 @@
}

expect(subject.client).to receive(:get)
.with('jscode2session', params: { appid: 'appid', secret: 'secret', js_code: 'code', grant_type: 'authorization_code' },
base: Wechat::Api::OAUTH2_BASE).and_return(response_result)
.with('jscode2session', hash_including(params: { appid: 'appid', secret: 'secret', js_code: 'code', grant_type: 'authorization_code' },
base: Wechat::Api::OAUTH2_BASE)).and_return(response_result)

expect(subject.jscode2session('code')).to eq response_result
end
Expand Down
4 changes: 2 additions & 2 deletions wechat.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Gem::Specification.new do |s|

s.add_development_dependency 'rubocop', '~> 1.9'
s.add_development_dependency 'rails', '>= 7.0.0'
s.add_development_dependency 'rspec-rails', '~> 5.1'
s.add_development_dependency 'rspec-mocks', '= 3.10.2'
s.add_development_dependency 'rspec-rails', '~> 6.0'
s.add_development_dependency 'rspec-mocks', '~> 3.12'
s.add_development_dependency 'sqlite3', '~> 1.5'
end

0 comments on commit e104ffa

Please sign in to comment.