spec/stratify-github/activity_spec.rb in stratify-github-0.1.1 vs spec/stratify-github/activity_spec.rb in stratify-github-0.1.2

- old
+ new

@@ -21,10 +21,17 @@ activity.checksum.should == checksum end end context 'translation' do + it 'properly interprets the incoming created_at field' do + data = DM({'type' => 'WatchEvent', + 'created_at' => '2012-08-01T09:35:11-07:00'}) + event = Stratify::GitHub::Activity.from_api_hash(data) + event.created_at.should == DateTime.parse('2012-08-01T09:35:11-07:00') + end + it 'raises an error when the API passes an unknown event type' do fields = {'type' => 'BendGirderEvent'} lambda {Stratify::GitHub::Activity.from_api_hash(fields)}.should raise_error(GitHubApiError) end @@ -226,9 +233,22 @@ event = Stratify::GitHub::Activity.from_api_hash(data) event.action.should == 'pushed' event.event_type.should == 'PushEvent' event.ref.should == 'refs/head/master' event.repository.should == 'https://github.com/daemianmack/clj-cronviz' + event.payload.should == 'Fix all the things' + end + + it 'produces correct fields for a PushEvent without a repository' do + data = DM({'type' => 'PushEvent', + 'payload' => { + 'ref' => 'refs/head/master', + 'shas' => [[nil, nil, 'Fix all the things']]}}) + event = Stratify::GitHub::Activity.from_api_hash(data) + event.action.should == 'pushed' + event.event_type.should == 'PushEvent' + event.ref.should == 'refs/head/master' + event.repository.should be_nil event.payload.should == 'Fix all the things' end it 'produces correct fields for a WatchEvent' do data = DM({'type' => 'WatchEvent'})