Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.

Conversation

fonglh
Copy link
Member

@fonglh fonglh commented Jul 14, 2016

Uses 10 seconds as the default.

Fixes #46.


describe Coursemology::Evaluator::CLI::Options do
it { is_expected.to have_attributes(host: nil, api_token: nil, api_user_email: nil) }
it { is_expected.to have_attributes(host: nil, api_token: nil, api_user_email: nil, poll_time: nil, poll_interval: nil) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [125/100]

@fonglh fonglh force-pushed the custom-poll-time branch from 8cead3b to c41db33 Compare July 14, 2016 09:29
describe Coursemology::Evaluator::CLI::Options do
it { is_expected.to have_attributes(host: nil, api_token: nil, api_user_email: nil) }
it { is_expected.to have_attributes(host: nil, api_token: nil, api_user_email: nil,
poll_time: nil, poll_interval: nil) }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expression at 20, 77 should be on its own line.

@fonglh fonglh force-pushed the custom-poll-time branch from c41db33 to 2dbce3d Compare July 14, 2016 09:35
describe Coursemology::Evaluator::CLI::Options do
it { is_expected.to have_attributes(host: nil, api_token: nil, api_user_email: nil) }
it 'checks Options attributes' do
expect(subject).to have_attributes(host: nil, api_token:nil, api_user_email: nil,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after colon.

@fonglh fonglh force-pushed the custom-poll-time branch 2 times, most recently from 81f4995 to 1b340a2 Compare July 14, 2016 09:39
# This sleep might not be triggered in the specs, because interruptions to the thread is
# nondeterministically run by the OS scheduler.
sleep(1.minute)
sleep(@poll_time.send(@poll_interval))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is very susceptible to injection.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I'm not sure if poll intervals are being tested

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No they aren't, I tested this manually.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can stub out sleep, and check that the correct timeout is specified as a spec

@fonglh fonglh force-pushed the custom-poll-time branch from 1b340a2 to 29821fa Compare July 19, 2016 07:04
@fonglh
Copy link
Member Author

fonglh commented Jul 19, 2016

@allenwq suggested just forcing the units to be in seconds. That'll remove the need for parsing and removes the dependency on the ISO8601 gem. The number can also be passed directly to the sleep function.

Add tests for checking the parsing of the poll interval option.
Parse the interval string with the ISO8601 gem and use the value in the
client loop.
Specify default values of optional parameters in a consistent way.
@fonglh fonglh force-pushed the custom-poll-time branch from 29821fa to 0c74bed Compare July 19, 2016 07:13
@allenwq
Copy link
Member

allenwq commented Jul 19, 2016

But since you have done it already, it's OK to stick with the current way. Just that I feel using seconds is enough.

@fonglh
Copy link
Member Author

fonglh commented Jul 19, 2016

I just remembered I also want to do customizable Docker image cache interval. That could vary over a much greater time frame so I'll still need the ISO8601 gem.

@fonglh fonglh force-pushed the custom-poll-time branch from f05f874 to 9698fc6 Compare July 20, 2016 03:16

it 'sleeps with the default poll time' do
# Simulate no evaluations
expect(subject).to receive(:allocate_evaluations) { [] }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

@fonglh fonglh force-pushed the custom-poll-time branch 2 times, most recently from 6972d62 to 44c7df2 Compare July 20, 2016 08:38
expect(subject).to receive(:sleep).with(10)
subject.run
end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra empty line detected at block body end.

Check that the correct poll times are being used.
@fonglh fonglh force-pushed the custom-poll-time branch from 44c7df2 to b01045e Compare July 20, 2016 08:40
@allenwq
Copy link
Member

allenwq commented Jul 20, 2016

LGTM

@allenwq
Copy link
Member

allenwq commented Jul 21, 2016

I will merge this first since @fonglh need it for deploy.

@allenwq allenwq merged commit b8feb82 into Coursemology:master Jul 21, 2016
@fonglh fonglh deleted the custom-poll-time branch July 22, 2016 13:17
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants