Class: CmQuiz::Review::GetIdeas
- Inherits:
-
BaseReview
- Object
- BaseReview
- CmQuiz::Review::GetIdeas
- Defined in:
- lib/cm_quiz/review/get_ideas.rb
Constant Summary collapse
- VALID_TIME_DIFF =
60 * 5
Instance Attribute Summary
Attributes inherited from BaseReview
Instance Method Summary collapse
-
#initialize(project_api:) ⇒ GetIdeas
constructor
A new instance of GetIdeas.
- #run ⇒ Object
Methods inherited from BaseReview
#build_test_result, #perform, #test_request
Methods included from CmQuiz::ReviewHelper
#be, #be_nil, #be_within, #eq, #expect
Constructor Details
#initialize(project_api:) ⇒ GetIdeas
Returns a new instance of GetIdeas.
8 9 10 11 12 13 |
# File 'lib/cm_quiz/review/get_ideas.rb', line 8 def initialize(project_api:) @project_api = project_api @verb = :get @path = '/ideas' @now = Time.now end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cm_quiz/review/get_ideas.rb', line 15 def run jwt, _ = Factory::User.new({ project_api: @project_api }).create idea_payloads = 3.times.map do |i| Factory::Idea.new({ project_api: @project_api, jwt: jwt, idea_params: { confidence: (3 + i) % 10 + 1 } }).create end res = send_get_ideas_request(jwt: jwt) res_hash = JSON.parse(res.body) idea_payloads.each do |idea_payload| item = res_hash.find { |item| item['id'] == idea_payload['id'] } raise StandardError, "idea not found" unless item expect(item['content']).to eq(idea_payload['content']) expect(item['impact']).to eq(idea_payload['impact']) expect(item['ease']).to eq(idea_payload['ease']) expect(item['confidence']).to eq(idea_payload['confidence']) average_score = (idea_payload['impact'] + idea_payload['ease'] + idea_payload['confidence'])/ 3.0 expect(item['average_score']).to be_within(0.1).of(average_score) diff = Time.now - Time.at(item['created_at']) expect(diff).to be <= VALID_TIME_DIFF end end |