spec/lib/mtrack/state_spec.rb in mtrack-0.0.4 vs spec/lib/mtrack/state_spec.rb in mtrack-0.0.5
- old
+ new
@@ -48,21 +48,26 @@
expect(subject.tracked).to be_empty
end
end
context "with super state" do
- subject { described_class.new sample_state }
+ subject { described_class.new.tap {|s| s.add_super_state sample_state } }
it "has super state's tracked methods" do
expect(sample_state.tracked(:con_1)).to match_array(sample_group[:con_1][:tracked])
expect(sample_state.tracked(:con_2)).to match_array(sample_group[:con_2][:tracked])
expect(subject.tracked(:con_1)).to match_array(sample_state.tracked(:con_1))
expect(subject.tracked(:con_2)).to match_array(sample_state.tracked(:con_2))
end
end
context "with multiple super states" do
- subject { described_class.new(sample_state).tap {|s| s.add_super_state sample_state_2 } }
+ subject do
+ described_class.new.tap do |s|
+ s.add_super_state sample_state
+ s.add_super_state sample_state_2
+ end
+ end
it "merges tracked methods from all super states" do
expect(subject.tracked(:con_1)).to match_array(sample_group[:con_1][:tracked])
expect(subject.tracked(:con_2)).to match_array(sample_group[:con_2][:tracked] | sample_group_2[:con_2][:tracked])
expect(subject.tracked(:con_3)).to match_array(sample_group_2[:con_3][:tracked])