test/exercism/api_test.rb in exercism-0.0.26 vs test/exercism/api_test.rb in exercism-0.0.27
- old
+ new
@@ -73,6 +73,49 @@
assert_equal 201, response.status
end
end
end
+ def test_save_stash_to_api
+ submission = File.join(FileUtils.pwd, 'bob.rb')
+ File.open(submission, 'w') do |f|
+ f.write "puts 'hello world'"
+ end
+
+ Exercism.stub(:home, home) do
+ VCR.use_cassette('alice-submits-stash') do
+ response = Exercism::Api.new('http://localhost:4567', Exercism.user).save_stash('user/assignments/stash', submission)
+ assert_equal 201, response.status
+ end
+ end
+ end
+
+ def test_apply_stash_from_api
+ submission = File.join(FileUtils.pwd, 'bob.rb')
+ File.open(submission, 'w') do |f|
+ f.write "puts 'hello world'"
+ end
+ Exercism.stub(:home, home) do
+ VCR.use_cassette('alice-gets-stash') do
+ Exercism::Api.new('http://localhost:4567', Exercism.user).save_stash('user/assignments/stash', submission)
+ response = Exercism::Api.new('http://localhost:4567', Exercism.user).apply_stash('user/assignments/stash', 'bob.rb')
+ assert response
+ end
+ end
+ end
+
+ def test_get_stash_list
+ submission = File.join(FileUtils.pwd, 'bob.rb')
+ File.open(submission, 'w') do |f|
+ f.write "puts 'hello world'"
+ end
+ Exercism.stub(:home, home) do
+ VCR.use_cassette('alice-gets-stash-list') do
+ Exercism::Api.new('http://localhost:4567', Exercism.user).save_stash('user/assignments/stash', submission)
+ response = Exercism::Api.new('http://localhost:4567', Exercism.user).list_stash('user/assignments/stash/list')
+ assert response
+ end
+ end
+ end
+
+
end