spec/pushpop-keen_spec.rb in pushpop-keen-0.1.1 vs spec/pushpop-keen_spec.rb in pushpop-keen-0.2

- old
+ new

@@ -35,10 +35,21 @@ step._analyses.should == [{ analysis_type: 'count' }] end end + describe '#record' do + it 'should record an event with properties' do + step = Pushpop::Keen.new do + record 'Pageview', useragent: 'Chrome' + end + + expect(Keen).to receive(:publish).with('Pageview', useragent: 'Chrome') + step.run + end + end + describe '#run' do it 'should run the query based on the analysis type' do Keen.stub(:count).with('pageviews', { timeframe: 'last_3_days' }).and_return(365) @@ -48,9 +59,43 @@ analysis_type 'count' timeframe 'last_3_days' end response = step.run response.should == 365 + end + + it 'should not try to run a query if the analysis type isnt set' do + step = Pushpop::Keen.new do + group_by 'something' + end + + expect(Keen).not_to receive(:send) + expect(Keen).not_to receive(:funnel) + + step.run + end + + it 'should run funnels directly, instead of using send' do + step = Pushpop::Keen.new('one') do + analysis_type 'funnel' + steps [ + { + actor_property: 'uuid', + event_collection: 'pageviews', + timeframe: 'this_3_days' + }, + { + actor_property: 'uuid', + event_collection: 'link_clicks', + timeframe: 'this_3_days' + } + ] + end + + expect(Keen).to receive(:funnel) + expect(Keen).not_to receive(:send) + + step.run end end describe '#to_analysis_options' do it 'should include various options' do