backtrace_spec.rb
1.21 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require 'spec_helper'
describe Backtrace do
subject { described_class.new }
its(:fingerprint) { should be_present }
describe "#similar" do
context "no similar backtrace" do
its(:similar) { should be_nil }
end
context "similar backtrace exist" do
let!(:similar_backtrace) { Fabricate(:backtrace, :fingerprint => fingerprint) }
let(:fingerprint) { "fingerprint" }
before { subject.stub(:fingerprint => fingerprint) }
its(:similar) { should == similar_backtrace }
end
end
describe "find_or_create" do
subject { described_class.find_or_create(attributes) }
let(:attributes) { mock :attributes }
let(:backtrace) { mock :backtrace }
before { described_class.stub(:new => backtrace) }
context "no similar backtrace" do
before { backtrace.stub(:similar => nil) }
it "create new backtrace" do
described_class.should_receive(:create).with(attributes)
described_class.find_or_create(attributes)
end
end
context "similar backtrace exist" do
let(:similar_backtrace) { mock :similar_backtrace }
before { backtrace.stub(:similar => similar_backtrace) }
it { should == similar_backtrace }
end
end
end