Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 80 lines (65 sloc) 1.845 kB
e9408ff @technoweenie port freckle service
technoweenie authored
1 require File.expand_path('../helper', __FILE__)
2
3 class FreckleTest < Service::TestCase
4 def setup
5 @stubs = Faraday::Adapter::Test::Stubs.new
6 end
7
8 def test_posts_with_2_entries
9 data = call_service :push
10 assert_equal 2, data['entries'].size
11 end
12
13 def test_includes_auth_token
14 data = call_service :push
15 assert_equal '12345', data['token']
16 end
17
18 def test_parses_minutes_from_commit_message
19 data = call_service :push
20 assert_equal '15', data['entries'][0]['minutes']
21 assert_equal '2hrs', data['entries'][1]['minutes']
22 end
23
24 def test_strips_freckle_tags
25 data = call_service :push
26 assert_equal 'stub git call for Grit#heads test',
27 data['entries'][0]['description']
28 assert_equal 'clean up heads test',
29 data['entries'][1]['description']
30 end
31
32 def test_includes_project_name
33 data = call_service :push
34 assert_equal 'Test Project',
35 data['entries'][0]['project_name']
36 end
37
38 def test_includes_author_email_as_user
39 data = call_service :push
40 assert_equal 'tom@mojombo.com',
41 data['entries'][0]['user']
42 end
43
44 def test_includes_commit_url
45 data = call_service :push
46 assert_equal 'http://github.com/mojombo/grit/commit/06f63b43050935962f84fe54473a7c5de7977325',
47 data['entries'][0]['url']
48 end
49
50 def test_includes_timestamp_as_date
51 data = call_service :push
52 assert_equal '2007-10-10T00:11:02-07:00',
53 data['entries'][0]['date']
54 end
55
56 def data
57 {
58 "subdomain" => "abloom",
59 "token" => "12345",
60 "project" => "Test Project"
61 }
62 end
63
64 def service(*args)
65 super Service::Freckle, *args
66 end
67
68 def call_service(event)
69 res = nil
6ef3389 @technoweenie event type is redundant
technoweenie authored
70 svc = service data, payload
e9408ff @technoweenie port freckle service
technoweenie authored
71 @stubs.post '/api/entries/import' do |env|
72 res = JSON.parse env[:body]
73 end
74 svc.send "receive_#{event}"
75 res
76 end
77 end
78
79
Something went wrong with that request. Please try again.