clicoder 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0567b3191e30e1d1ce45f90871ca66e14d156ade
4
- data.tar.gz: 09cc27e6694023218291aff531bb7c923bfae22b
3
+ metadata.gz: a4fbdba175792bec585ebf3e610eaaaf2e911c93
4
+ data.tar.gz: 4d3fd54daed52a21ae7b628fd4a6e2e570b0bab8
5
5
  SHA512:
6
- metadata.gz: b33ad4fad9623d20e60768a124052548f3668ad48316d7308faaa5323d5ffc93b707dcf2768fca3155f7a84a120c71593a0b107a9e54c347f0554eed1b6e9b24
7
- data.tar.gz: 7a06d50192cf0d090a7344aa42a20cd860249a4a85971d24a25272b3636e4a0190f900de1fa73d391c357d2f63ada67fe260e1fd83e41c2806350eb0a9f0a8c7
6
+ metadata.gz: 94448688a9b1c76176c85e5cfb925b716aca5aa28cb5a897532ead8eda283eaa95f7ce1517fb68b23c1d9fba011278e31f7a439ebc98fa2043aaa5af2aa45d7e
7
+ data.tar.gz: 06f0311854f2b44dfb49dc51b405d045094abc661026b286eff5218d1679a53f715bbbf952b15b2d8b581a7532fad087557bb6c34ae0693fc50a871131575e21
@@ -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 be_true
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 be_true
70
+ expect(File.exists?("#{Clicoder::MY_OUTPUTS_DIRNAME}/#{basename}")).to be true
71
71
  end
72
72
  end
73
73
 
@@ -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
@@ -1,6 +1,7 @@
1
1
  #include <iostream>
2
+ using namespace std;
2
3
 
3
4
  int main()
4
5
  {
5
- printf("Hello, World.\n");
6
+ cout << "Hello, World." << endl;
6
7
  }
@@ -39,7 +39,6 @@ module Clicoder
39
39
  def start_with(site)
40
40
  site.start
41
41
  puts "created directory #{site.working_directory}"
42
- system("cd #{site.working_directory} && git init")
43
42
  end
44
43
  end
45
44
  end
@@ -13,7 +13,6 @@ module Clicoder
13
13
  include Helper
14
14
 
15
15
  # Parameters
16
- abstract_method :login
17
16
  abstract_method :site_name
18
17
  abstract_method :problem_url
19
18
  abstract_method :description_xpath
@@ -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
- yield
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
- "#{GEM_ROOT}/fixtures/sample_problem.html"
36
+ "http://samplesite.com/sample_problem.html"
34
37
  end
35
38
 
36
39
  def description_xpath
@@ -1,3 +1,3 @@
1
1
  module Clicoder
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -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 be_true
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 be_false
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 be_true }
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 be_false }
60
+ it { should be false }
61
61
  end
62
62
  end
63
63
  end
@@ -57,7 +57,7 @@ module Clicoder
57
57
  end
58
58
 
59
59
  it 'returns true' do
60
- expect(aoj.submit).to be_true
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 be_false
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 be_true
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 be_true
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 no args' do
113
- expect { |b| sample_site.login(&b) }.to yield_with_no_args
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
@@ -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.5
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: 2014-12-25 00:00:00.000000000 Z
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: