clicoder 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -0
- data/README.md +10 -0
- data/features/step_definitions/sample_site_steps.rb +2 -2
- data/features/support/webmock.rb +7 -0
- data/fixtures/clicoder.d/template.cpp +2 -1
- data/lib/clicoder/cli.rb +0 -1
- data/lib/clicoder/site_base.rb +0 -1
- data/lib/clicoder/sites/sample_site.rb +5 -2
- data/lib/clicoder/version.rb +1 -1
- data/spec/judge_spec.rb +4 -4
- data/spec/sites/aoj_spec.rb +2 -2
- data/spec/sites/sample_site_spec.rb +10 -4
- data/wercker.yml +30 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a4fbdba175792bec585ebf3e610eaaaf2e911c93
|
4
|
+
data.tar.gz: 4d3fd54daed52a21ae7b628fd4a6e2e570b0bab8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 94448688a9b1c76176c85e5cfb925b716aca5aa28cb5a897532ead8eda283eaa95f7ce1517fb68b23c1d9fba011278e31f7a439ebc98fa2043aaa5af2aa45d7e
|
7
|
+
data.tar.gz: 06f0311854f2b44dfb49dc51b405d045094abc661026b286eff5218d1679a53f715bbbf952b15b2d8b581a7532fad087557bb6c34ae0693fc50a871131575e21
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.1.3
|
data/README.md
CHANGED
@@ -142,6 +142,16 @@ Thank you for your contributions.
|
|
142
142
|
4. Push to the branch (`git push origin my-new-feature`)
|
143
143
|
5. Create new Pull Request
|
144
144
|
|
145
|
+
## Testing
|
146
|
+
|
147
|
+
This repository uses `RSpec` to test application logic and `Cucumber` to test acceptance as a CLI tool.
|
148
|
+
Make sure both tests passes before submitting pull requests.
|
149
|
+
|
150
|
+
```
|
151
|
+
$ bundle exec rspec spec/
|
152
|
+
$ bundle exec cucumber features/
|
153
|
+
```
|
154
|
+
|
145
155
|
## Add a Site
|
146
156
|
|
147
157
|
It's easy to add new sites.
|
@@ -61,13 +61,13 @@ Given /^Launchy.open is stubbed/ do
|
|
61
61
|
end
|
62
62
|
|
63
63
|
Then /^an executable should be generated/ do
|
64
|
-
expect(File.exists?('a.out')).to
|
64
|
+
expect(File.exists?('a.out')).to be true
|
65
65
|
end
|
66
66
|
|
67
67
|
Then /^my answer should be output in my outputs directory/ do
|
68
68
|
Dir.glob("#{Clicoder::INPUTS_DIRNAME}/*.txt") do |file|
|
69
69
|
basename = File.basename(file)
|
70
|
-
expect(File.exists?("#{Clicoder::MY_OUTPUTS_DIRNAME}/#{basename}")).to
|
70
|
+
expect(File.exists?("#{Clicoder::MY_OUTPUTS_DIRNAME}/#{basename}")).to be true
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
data/features/support/webmock.rb
CHANGED
@@ -3,3 +3,10 @@ require 'webmock/cucumber'
|
|
3
3
|
# TODO: DRY. see spec/spec_helper.rb
|
4
4
|
GEM_ROOT = Gem::Specification.find_by_name('clicoder').gem_dir
|
5
5
|
FIXTURE_DIR = GEM_ROOT + '/fixtures'
|
6
|
+
|
7
|
+
Before do
|
8
|
+
# TODO: DRY. see spec/spec_helper.rb
|
9
|
+
stub_request(:get, "http://samplesite.com/sample_problem.html").
|
10
|
+
to_return(status: 200,
|
11
|
+
body: File.read("#{FIXTURE_DIR}/sample_problem.html"))
|
12
|
+
end
|
data/lib/clicoder/cli.rb
CHANGED
data/lib/clicoder/site_base.rb
CHANGED
@@ -3,6 +3,7 @@ require 'clicoder/config'
|
|
3
3
|
|
4
4
|
require 'net/http'
|
5
5
|
require 'launchy'
|
6
|
+
require 'mechanize'
|
6
7
|
|
7
8
|
module Clicoder
|
8
9
|
class SampleSite < SiteBase
|
@@ -22,7 +23,9 @@ module Clicoder
|
|
22
23
|
end
|
23
24
|
|
24
25
|
def login
|
25
|
-
|
26
|
+
Mechanize.start do |m|
|
27
|
+
yield m
|
28
|
+
end
|
26
29
|
end
|
27
30
|
|
28
31
|
def site_name
|
@@ -30,7 +33,7 @@ module Clicoder
|
|
30
33
|
end
|
31
34
|
|
32
35
|
def problem_url
|
33
|
-
"
|
36
|
+
"http://samplesite.com/sample_problem.html"
|
34
37
|
end
|
35
38
|
|
36
39
|
def description_xpath
|
data/lib/clicoder/version.rb
CHANGED
data/spec/judge_spec.rb
CHANGED
@@ -24,11 +24,11 @@ module Clicoder
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it 'returns true when the contents of two files are the same' do
|
27
|
-
expect(judge.diff_judge(@input.path, @correct_output.path)).to
|
27
|
+
expect(judge.diff_judge(@input.path, @correct_output.path)).to be true
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'returns false when the contents of two files are different' do
|
31
|
-
expect(judge.diff_judge(@input.path, @wrong_output.path)).to
|
31
|
+
expect(judge.diff_judge(@input.path, @wrong_output.path)).to be false
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -52,12 +52,12 @@ module Clicoder
|
|
52
52
|
|
53
53
|
context 'when diff is less than allowed absolute error' do
|
54
54
|
let(:abs_error) { 10**(-1) }
|
55
|
-
it { should
|
55
|
+
it { should be true }
|
56
56
|
end
|
57
57
|
|
58
58
|
context 'when diff is less than allowed absolute error' do
|
59
59
|
let(:abs_error) { 10**(-2) }
|
60
|
-
it { should
|
60
|
+
it { should be false }
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
data/spec/sites/aoj_spec.rb
CHANGED
@@ -57,7 +57,7 @@ module Clicoder
|
|
57
57
|
end
|
58
58
|
|
59
59
|
it 'returns true' do
|
60
|
-
expect(aoj.submit).to
|
60
|
+
expect(aoj.submit).to be true
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
@@ -67,7 +67,7 @@ module Clicoder
|
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'returns false' do
|
70
|
-
expect(aoj.submit).to
|
70
|
+
expect(aoj.submit).to be false
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
@@ -10,20 +10,26 @@ module Clicoder
|
|
10
10
|
let(:sample_site) { SampleSite.new }
|
11
11
|
let(:config) { sample_site.config }
|
12
12
|
|
13
|
+
before do
|
14
|
+
stub_request(:get, "http://samplesite.com/sample_problem.html").
|
15
|
+
to_return(status: 200,
|
16
|
+
body: File.read("#{FIXTURE_DIR}/sample_problem.html"))
|
17
|
+
end
|
18
|
+
|
13
19
|
describe '#start' do
|
14
20
|
before do
|
15
21
|
sample_site.start
|
16
22
|
end
|
17
23
|
|
18
24
|
it 'creates working directory specified by #working_directory' do
|
19
|
-
expect(File.directory?(sample_site.working_directory)).to
|
25
|
+
expect(File.directory?(sample_site.working_directory)).to be true
|
20
26
|
end
|
21
27
|
|
22
28
|
it 'prepares directories for inputs, outpus, and myoutputs' do
|
23
29
|
dirs = [INPUTS_DIRNAME, OUTPUTS_DIRNAME, MY_OUTPUTS_DIRNAME]
|
24
30
|
Dir.chdir(sample_site.working_directory) do
|
25
31
|
dirs.each do |dir|
|
26
|
-
expect(File.directory?(dir)).to
|
32
|
+
expect(File.directory?(dir)).to be true
|
27
33
|
end
|
28
34
|
end
|
29
35
|
end
|
@@ -109,8 +115,8 @@ module Clicoder
|
|
109
115
|
end
|
110
116
|
|
111
117
|
describe '#login' do
|
112
|
-
it 'yields control with
|
113
|
-
expect { |b| sample_site.login(&b) }.to
|
118
|
+
it 'yields control with mechanize args' do
|
119
|
+
expect { |b| sample_site.login(&b) }.to yield_control
|
114
120
|
end
|
115
121
|
end
|
116
122
|
end
|
data/wercker.yml
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
box: wercker/rvm
|
2
|
+
# Build definition
|
3
|
+
build:
|
4
|
+
# The steps that will be executed on build
|
5
|
+
# See the Ruby section on the wercker devcenter:
|
6
|
+
# http://devcenter.wercker.com/articles/languages/ruby.html
|
7
|
+
steps:
|
8
|
+
# Uncomment this to force RVM to use a specific Ruby version
|
9
|
+
- rvm-use:
|
10
|
+
version: 2.1.3
|
11
|
+
|
12
|
+
# A step that executes `bundle install` command
|
13
|
+
- bundle-install
|
14
|
+
|
15
|
+
# A custom script step, name value is used in the UI
|
16
|
+
# and the code value contains the command that get executed
|
17
|
+
- script:
|
18
|
+
name: echo ruby information
|
19
|
+
code: |
|
20
|
+
echo "ruby version $(ruby --version) running"
|
21
|
+
echo "from location $(which ruby)"
|
22
|
+
echo -p "gem list: $(gem list)"
|
23
|
+
|
24
|
+
- script:
|
25
|
+
name: rspec
|
26
|
+
code: bundle exec rspec spec/
|
27
|
+
|
28
|
+
- script:
|
29
|
+
name: cucumber
|
30
|
+
code: bundle exec cucumber features/
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clicoder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugimoto
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -202,6 +202,7 @@ extensions: []
|
|
202
202
|
extra_rdoc_files: []
|
203
203
|
files:
|
204
204
|
- ".gitignore"
|
205
|
+
- ".ruby-version"
|
205
206
|
- Gemfile
|
206
207
|
- LICENSE.txt
|
207
208
|
- README.md
|
@@ -231,6 +232,7 @@ files:
|
|
231
232
|
- spec/sites/aoj_spec.rb
|
232
233
|
- spec/sites/sample_site_spec.rb
|
233
234
|
- spec/spec_helper.rb
|
235
|
+
- wercker.yml
|
234
236
|
homepage: https://github.com/Genki-S/clicoder
|
235
237
|
licenses:
|
236
238
|
- MIT
|
@@ -266,4 +268,3 @@ test_files:
|
|
266
268
|
- spec/sites/aoj_spec.rb
|
267
269
|
- spec/sites/sample_site_spec.rb
|
268
270
|
- spec/spec_helper.rb
|
269
|
-
has_rdoc:
|