learn-test 3.2.3 → 3.3.0.pre.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,33 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  describe LearnTest::Strategies::None do
4
- describe '#detect' do
5
- context 'there is a .canvas file' do
6
- before { FileUtils.touch('.canvas') }
7
- after { FileUtils.rm('.canvas') }
8
-
9
- it 'is true' do
10
- runner = LearnTest::Runner.new(double(:repo), {})
11
- strategy = LearnTest::Strategies::None.new(runner)
12
-
13
- expect(strategy.detect).to eq(true)
14
- end
15
- end
16
-
17
- context 'there is no .canvas file' do
18
- it 'is false' do
19
- runner = LearnTest::Runner.new(double(:repo), {})
20
- strategy = LearnTest::Strategies::None.new(runner)
21
-
22
- expect(strategy.detect).to eq(false)
23
- end
24
- end
25
- end
26
-
27
4
  describe '#run' do
28
5
  it 'prints a message' do
29
6
  strategy = LearnTest::Strategies::None.new(double(:runner, options: {}))
30
- msg = "Your assignment was submitted. You can resubmit by running `learn test` again.\n"
7
+
8
+ msg = <<~MSG
9
+ This directory doesn't appear to have any specs in it, so there’s no test to run.
10
+
11
+ If you are working on Canvas, this assignment has been submitted. You can resubmit by running `learn test` again.
12
+ MSG
31
13
 
32
14
  expect { strategy.run }.to output(msg).to_stdout
33
15
  end
@@ -52,7 +34,6 @@ describe LearnTest::Strategies::None do
52
34
  expect(LearnTest::LearnOauthTokenParser).to receive(:get_learn_oauth_token)
53
35
  .and_return(oauth_token)
54
36
 
55
-
56
37
  expect(strategy.results).to eq(
57
38
  username: username,
58
39
  github_user_id: user_id,
@@ -1,6 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'aruba/rspec'
4
+ require 'digest'
5
+ require 'simplecov'
6
+
7
+ SimpleCov.start
8
+
3
9
  require_relative '../lib/learn_test'
10
+
11
+ support_dir = File.join('./', 'spec', 'support', '**', '*.rb')
12
+ Dir.glob(support_dir).each { |f| require f }
13
+
4
14
  RSpec.configure do |config|
5
15
  config.expect_with :rspec do |expectations|
6
16
  expectations.include_chain_clauses_in_custom_matcher_descriptions = true
@@ -0,0 +1,17 @@
1
+ def git_set_user
2
+ run_command_and_stop 'git config user.email "info@flatironschool.com"'
3
+ run_command_and_stop 'git config user.name "Flatiron School"'
4
+ end
5
+
6
+ def git_init
7
+ run_command_and_stop 'git init'
8
+ git_set_user
9
+ end
10
+
11
+ def git_add(files = '.')
12
+ run_command_and_stop "git add #{files}"
13
+ end
14
+
15
+ def git_commit(msg)
16
+ run_command_and_stop "git commit -m \"#{msg}\""
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: learn-test
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.3
4
+ version: 3.3.0.pre.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Flatiron School
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-22 00:00:00.000000000 Z
11
+ date: 2020-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -136,24 +136,37 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.8.1
139
- description:
139
+ - !ruby/object:Gem::Dependency
140
+ name: zeitwerk
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: 2.4.0
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: 2.4.0
153
+ description:
140
154
  email:
141
155
  - learn@flatironschool.com
142
156
  executables:
143
157
  - learn-test
144
- - learn-test-wip
145
158
  extensions: []
146
159
  extra_rdoc_files: []
147
160
  files:
148
161
  - ".circleci/config.yml"
149
162
  - ".gitignore"
150
163
  - ".rspec"
164
+ - ".rubocop.yml"
151
165
  - Gemfile
152
166
  - LICENSE.txt
153
167
  - README.md
154
168
  - Rakefile
155
169
  - bin/learn-test
156
- - bin/learn-test-wip
157
170
  - learn-test.gemspec
158
171
  - lib/learn_test.rb
159
172
  - lib/learn_test/client.rb
@@ -168,7 +181,10 @@ files:
168
181
  - lib/learn_test/dependencies/selenium_server.rb
169
182
  - lib/learn_test/dependency.rb
170
183
  - lib/learn_test/file_finder.rb
171
- - lib/learn_test/git_wip.rb
184
+ - lib/learn_test/git.rb
185
+ - lib/learn_test/git/wip/base.rb
186
+ - lib/learn_test/git/wip/branch.rb
187
+ - lib/learn_test/git/wip/error.rb
172
188
  - lib/learn_test/github_interactor.rb
173
189
  - lib/learn_test/js_strategy.rb
174
190
  - lib/learn_test/learn_oauth_token_parser.rb
@@ -197,10 +213,14 @@ files:
197
213
  - node_modules/karma-json-reporter/package.json
198
214
  - spec/features/rspec_unit_spec.rb
199
215
  - spec/fixtures/.netrc
216
+ - spec/fixtures/rspec-unit-spec/.results.json
200
217
  - spec/fixtures/rspec-unit-spec/.rspec
201
218
  - spec/fixtures/rspec-unit-spec/lib/dog.rb
202
219
  - spec/fixtures/rspec-unit-spec/spec/dog_spec.rb
203
220
  - spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
221
+ - spec/learn_test/git/wip/base_spec.rb
222
+ - spec/learn_test/git/wip/branch_spec.rb
223
+ - spec/learn_test/git/wip/error_spec.rb
204
224
  - spec/learn_test/git_spec.rb
205
225
  - spec/learn_test/reporter_spec.rb
206
226
  - spec/learn_test/username_parser_spec.rb
@@ -208,11 +228,12 @@ files:
208
228
  - spec/lib/learn_test/strategies/none_spec.rb
209
229
  - spec/repo_parser_spec.rb
210
230
  - spec/spec_helper.rb
231
+ - spec/support/git.rb
211
232
  homepage: https://github.com/learn-co/learn-test
212
233
  licenses:
213
234
  - MIT
214
235
  metadata: {}
215
- post_install_message:
236
+ post_install_message:
216
237
  rdoc_options: []
217
238
  require_paths:
218
239
  - lib
@@ -224,22 +245,26 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
245
  version: 2.5.0
225
246
  required_rubygems_version: !ruby/object:Gem::Requirement
226
247
  requirements:
227
- - - ">="
248
+ - - ">"
228
249
  - !ruby/object:Gem::Version
229
- version: '0'
250
+ version: 1.3.1
230
251
  requirements: []
231
- rubygems_version: 3.0.6
232
- signing_key:
252
+ rubygems_version: 3.1.2
253
+ signing_key:
233
254
  specification_version: 4
234
255
  summary: Runs RSpec, Karma, Mocha, and Python Pytest Test builds and pushes JSON output
235
256
  to Learn.
236
257
  test_files:
237
258
  - spec/features/rspec_unit_spec.rb
238
259
  - spec/fixtures/.netrc
260
+ - spec/fixtures/rspec-unit-spec/.results.json
239
261
  - spec/fixtures/rspec-unit-spec/.rspec
240
262
  - spec/fixtures/rspec-unit-spec/lib/dog.rb
241
263
  - spec/fixtures/rspec-unit-spec/spec/dog_spec.rb
242
264
  - spec/fixtures/rspec-unit-spec/spec/spec_helper.rb
265
+ - spec/learn_test/git/wip/base_spec.rb
266
+ - spec/learn_test/git/wip/branch_spec.rb
267
+ - spec/learn_test/git/wip/error_spec.rb
243
268
  - spec/learn_test/git_spec.rb
244
269
  - spec/learn_test/reporter_spec.rb
245
270
  - spec/learn_test/username_parser_spec.rb
@@ -247,3 +272,4 @@ test_files:
247
272
  - spec/lib/learn_test/strategies/none_spec.rb
248
273
  - spec/repo_parser_spec.rb
249
274
  - spec/spec_helper.rb
275
+ - spec/support/git.rb
@@ -1,249 +0,0 @@
1
- #!/bin/bash
2
- #
3
- # Copyright Bart Trojanowski <bart@jukie.net>
4
- #
5
- # git-wip is a script that will manage Work In Progress (or WIP) branches.
6
- # WIP branches are mostly throw away but identify points of development
7
- # between commits. The intent is to tie this script into your editor so
8
- # that each time you save your file, the git-wip script captures that
9
- # state in git. git-wip also helps you return back to a previous state of
10
- # development.
11
- #
12
- # See also http://github.com/bartman/git-wip
13
- #
14
- # The code is licensed as GPL v2 or, at your option, any later version.
15
- # Please see http://www.gnu.org/licenses/gpl-2.0.txt
16
- #
17
-
18
- USAGE='[ save <message> [ --editor | --untracked | --no-gpg-sign ] | delete ] [ [--] <file>... ]'
19
- LONG_USAGE="Manage Work In Progress branches
20
-
21
- Commands:
22
- git wip - create a new WIP commit
23
- git wip save <message> - create a new WIP commit with custom message
24
-
25
- Options for save:
26
- -e --editor - be less verbose, assume called from an editor
27
- -u --untracked - capture also untracked files
28
- -i --ignored - capture also ignored files
29
- --no-gpg-sign - do not sign commit; that is, countermand
30
- 'commit.gpgSign = true'
31
- "
32
-
33
- . "$(git --exec-path)/git-sh-setup"
34
-
35
- require_work_tree
36
-
37
- TMP=$(mktemp -d -t .git-wip)
38
-
39
- cleanup () {
40
- rm -f "$TMP-*"
41
- }
42
-
43
- trap cleanup 0
44
-
45
- WIP_INDEX="$TMP-INDEX"
46
-
47
- WIP_PREFIX=refs/wip/
48
- WIP_COMMAND=
49
- WIP_MESSAGE=WIP
50
- EDITOR_MODE=false
51
-
52
- dbg() {
53
- if test -n "$WIP_DEBUG"
54
- then
55
- printf '# %s\n' "$*"
56
- fi
57
- }
58
-
59
- # some errors are not worth reporting in --editor mode
60
- report_soft_error () {
61
- $EDITOR_MODE && exit 0
62
- die "$@"
63
- }
64
-
65
- get_work_branch () {
66
- ref=$(git symbolic-ref -q HEAD) \
67
- || report_soft_error "git-wip requires a branch"
68
-
69
-
70
- branch=${ref#refs/heads/}
71
- if [ $branch = $ref ] ; then
72
- die "git-wip requires a local branch"
73
- fi
74
-
75
- echo $branch
76
- }
77
-
78
- check_files () {
79
- local -a files="$@"
80
-
81
- for f in "${files[@]}"
82
- do
83
- [ -f "$f" -o -d "$f" ] || die "$f: No such file or directory."
84
- done
85
- }
86
-
87
- build_new_tree () {
88
- local untracked=$1 ; shift
89
- local ignored=$1 ; shift
90
- local files="$@"
91
-
92
- (
93
- set -e
94
- rm -f "$WIP_INDEX"
95
- cp -p "$GIT_DIR/index" "$WIP_INDEX"
96
- export GIT_INDEX_FILE="$WIP_INDEX"
97
- git read-tree $wip_parent
98
- if [ -n "$files" ]
99
- then
100
- git add -f "${files[@]}"
101
- else
102
- git add --update .
103
- fi
104
- [ -n "$untracked" ] && git add .
105
- [ -n "$ignored" ] && git add -f -A .
106
- git write-tree
107
- rm -f "$WIP_INDEX"
108
- )
109
- }
110
-
111
- do_save () {
112
- local msg="$1" ; shift
113
- local add_untracked=
114
- local add_ignored=
115
- local no_sign=
116
-
117
- while test $# != 0
118
- do
119
- case "$1" in
120
- -e|--editor)
121
- EDITOR_MODE=true
122
- ;;
123
- -u|--untracked)
124
- add_untracked=t
125
- ;;
126
- -i|--ignored)
127
- add_ignored=t
128
- ;;
129
- --no-gpg-sign)
130
- no_sign=--no-gpg-sign
131
- ;;
132
- --)
133
- shift
134
- break
135
- ;;
136
- *)
137
- [ -f "$1" ] && break
138
- die "Unknown option '$1'."
139
- ;;
140
- esac
141
- shift
142
- done
143
- local files="$@"
144
- local "add_untracked=$add_untracked"
145
- local "add_ignored=$add_ignored"
146
-
147
- if test ${#files} -gt 0
148
- then
149
- check_files "${files[@]}"
150
- fi
151
-
152
- dbg "msg=$msg"
153
- dbg "files=$files"
154
-
155
- local work_branch=$(get_work_branch)
156
- local wip_branch="$WIP_PREFIX$work_branch"
157
-
158
- dbg "work_branch=$work_branch"
159
- dbg "wip_branch=$wip_branch"
160
-
161
- # enable reflog
162
- local wip_branch_file="$GIT_DIR/logs/$wip_branch"
163
- dbg "wip_branch_file=$wip_branch_file"
164
- mkdir -p "$(dirname "$wip_branch_file")"
165
- : >>"$wip_branch_file"
166
-
167
- if ! work_last=$(git rev-parse --verify $work_branch)
168
- then
169
- report_soft_error "'$work_branch' branch has no commits."
170
- fi
171
-
172
- dbg "work_last=$work_last"
173
-
174
- if wip_last=$(git rev-parse --quiet --verify $wip_branch)
175
- then
176
- local base=$(git merge-base $wip_last $work_last) \
177
- || die "'work_branch' and '$wip_branch' are unrelated."
178
-
179
- if [ $base = $work_last ] ; then
180
- wip_parent=$wip_last
181
- else
182
- wip_parent=$work_last
183
- fi
184
- else
185
- wip_parent=$work_last
186
- fi
187
-
188
- dbg "wip_parent=$wip_parent"
189
-
190
- new_tree=$( build_new_tree "$add_untracked" "$add_ignored" "${files[@]}" ) \
191
- || die "Cannot save the current worktree state."
192
-
193
- dbg "new_tree=$new_tree"
194
-
195
- if git diff-tree --exit-code --quiet $new_tree $wip_parent ; then
196
- report_soft_error "no changes"
197
- fi
198
-
199
- dbg "... has changes"
200
-
201
- new_wip=$(printf '%s\n' "$msg" | git commit-tree $no_sign $new_tree -p $wip_parent 2>/dev/null) \
202
- || die "Cannot record working tree state"
203
-
204
- dbg "new_wip=$new_wip"
205
-
206
- msg1=$(printf '%s\n' "$msg" | sed -e 1q)
207
- git update-ref -m "git-wip: $msg1" $wip_branch $new_wip $wip_last
208
-
209
- dbg "SUCCESS"
210
- }
211
-
212
- if test $# -eq 0
213
- then
214
- dbg "no arguments"
215
-
216
- do_save "WIP"
217
- exit $?
218
- fi
219
-
220
- dbg "args: $@"
221
-
222
- case "$1" in
223
- save)
224
- WIP_COMMAND=$1
225
- shift
226
- if [ -n "$1" ]
227
- then
228
- WIP_MESSAGE="$1"
229
- shift
230
- fi
231
- ;;
232
- --*)
233
- ;;
234
- *)
235
- [ -f "$1" ] || die "Unknown command '$1'."
236
- ;;
237
- esac
238
-
239
- case $WIP_COMMAND in
240
- save)
241
- do_save "$WIP_MESSAGE" $@
242
- ;;
243
- *)
244
- usage
245
- exit 1
246
- ;;
247
- esac
248
-
249
- # vim: set noet sw=8