forked from michaelfeathers/repodepot-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
weaver_spec.rb
31 lines (25 loc) · 1.24 KB
/
weaver_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require 'rspec'
require_relative 'weaver.rb'
describe "Weaver" do
it "should be able to link events" do
events = (0..2).map { |i| CodeEvent.new(name: i.to_s) }
link events, :next_state
events[0].next_state.should == events[1]
events[1].next_state.should == events[2]
end
it "should be able to weave events" do
events = []
events << CodeEvent.new(class_name: 'Foo', commit: 'a', method_name: 'moe')
events << CodeEvent.new(class_name: 'Foo', commit: 'a', method_name: 'larry')
events << CodeEvent.new(class_name: 'Foo', commit: 'a', method_name: 'curly')
events << CodeEvent.new(class_name: 'Foo', commit: 'b', method_name: 'moe')
events << CodeEvent.new(class_name: 'Foo', commit: 'b', method_name: 'larry')
events << CodeEvent.new(class_name: 'Foo', commit: 'b', method_name: 'curly')
events << CodeEvent.new(class_name: 'Foo', commit: 'c', method_name: 'moe')
events << CodeEvent.new(class_name: 'Foo', commit: 'c', method_name: 'larry')
events << CodeEvent.new(class_name: 'Foo', commit: 'c', method_name: 'curly')
weave(events)
method_events = RepoDepot::Repository.new('', events).methods.first.events
method_events.each_cons(2).map { |e0, e1| e0.next_state.should == e1 }
end
end