Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

Commit

Permalink
send exercise-name to one_self on dojo creation
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger committed May 25, 2015
1 parent b3531d7 commit 366dec6
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/controllers/setup_controller.rb
Expand Up @@ -18,6 +18,7 @@ def save
kata = katas.create_kata(language, exercise)
hash = {
:kata_id => kata.id,
:exercise_name => exercise_name,
:language_name => language_name,
:test_name => test_name,
:latitude => latitude,
Expand Down
9 changes: 5 additions & 4 deletions lib/OneSelf.rb
Expand Up @@ -15,13 +15,14 @@ def created(hash)
'objectTags' => [ 'cyber-dojo' ],
'actionTags' => [ 'create' ],
'location' => {
'lat' => hash[:latitude],
'lat' => hash[:latitude],
'long' => hash[:longtitude]
},
'properties' => {
'dojo-id' => hash[:kata_id],
'exercise-name' => hash[:exercise_name],
'language-name' => hash[:language_name],
'test-name' => hash[:test_name]
'test-name' => hash[:test_name]
}
}
url = URI.parse("#{streams_url}/#{stream_id}/events")
Expand All @@ -38,8 +39,8 @@ def started(avatar)
response = http_response(url.host, request)
body = JSON.parse(response.body)
one_self = {
:stream_id => body['streamid'],
:read_token => body['readToken'],
:stream_id => body['streamid'],
:read_token => body['readToken'],
:write_token => body['writeToken']
}
@disk[avatar.path].write(manifest_filename, one_self)
Expand Down
29 changes: 26 additions & 3 deletions test/lib/one_self_test.rb
Expand Up @@ -56,21 +56,44 @@ def setup

# - - - - - - - - - - - - - - - - -

test 'http requester' do
requester = HttpRequester.new
url = URI.parse('http://www.google.co.uk')
req = Net::HTTP::Get.new('#q=cyber-dojo')
response = requester.request(url.host, req)
assert response.to_s.start_with? '#<Net::HTTPFound'
end

# - - - - - - - - - - - - - - - - -

test 'kata created' do
http_requester = OneSelfHttpRequesterStub.new
one_self = OneSelf.new(disk, http_requester)
kata = make_kata
exercise_name = kata.exercise.name
language_name,test_name = kata.language.display_name.split(',').map{|s| s.strip }
hash = {
:kata_id => kata.id,
:exercise_name => exercise_name,
:language_name => language_name,
:test_name => test_name,
:latitude => '51.0190',
:test_name => test_name,
:latitude => '51.0190',
:longtitude => '3.1000'
}
one_self.created(hash)

assert_equal 'api.1self.co', http_requester.spied_url_hosts[0]
assert_equal 'api.1self.co', http_requester.spied_url_hosts[0]
body = JSON.parse(http_requester.spied_requests[0].body)
assert_equal ['cyber-dojo'], body['objectTags']
assert_equal ['create'], body['actionTags']
location = body['location']
assert_equal hash[:latitude], location['lat']
assert_equal hash[:longtitude], location['long']
properties = body['properties']
assert_equal kata.id, properties['dojo-id']
assert_equal language_name, properties['language-name']
assert_equal test_name, properties['test-name']
assert_equal kata.exercise.name, properties['exercise-name']
end

# - - - - - - - - - - - - - - - - -
Expand Down
1 change: 1 addition & 0 deletions test/print_coverage_summary.rb
Expand Up @@ -112,6 +112,7 @@ def gather_stats
#- - - - - - - - - - - - - - - - - - - - -

def print_heading
print "test-summary\n"
print_left(indent, '')
column_names.each { |name| print_right(columns[name][0], columns[name][1]) }
print "\n"
Expand Down
2 changes: 1 addition & 1 deletion test/run_all.sh
Expand Up @@ -21,4 +21,4 @@ done
echo
echo

./print_coverage_summary.rb
./print_coverage_summary.rb | tee test-summary.txt
21 changes: 21 additions & 0 deletions test/test-summary.txt
@@ -0,0 +1,21 @@

test-summary
t a f e s time t/s a/s cov
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
app_helpers 14 32 0 0 0 0.03 400.46 915.33 100.00
app_lib 111 4867 0 0 0 1.23 90.19 3954.35 100.00
app_models 119 381 0 0 0 1.13 105.06 336.36 100.00
lib 78 525 0 0 0 4.49 17.36 116.86 100.00
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
total 322 5805 0 0 0 6.88 46.80 843.75

t == number of tests
a == number of assertions
f == number of failures
e == number of errors
s == number of skips
time == time in seconds
t/s == tests per second
a/s == assertions per second
cov == coverage %

0 comments on commit 366dec6

Please sign in to comment.