Skip to content

Commit

Permalink
Fix this by not using stubs/mocks/whatever
Browse files Browse the repository at this point in the history
  • Loading branch information
cheerfulstoic committed Apr 12, 2015
1 parent 4fa6798 commit b37dc14
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions spec/e2e/basic_model_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@
property :name
property :a
property :b

before_destroy :before_destroy_callback
def before_destroy_callback
self.class.before_destroy_callback_calls += 1
end

class << self
attr_accessor :before_destroy_callback_calls
end

self.before_destroy_callback_calls = 0
end
end

Expand Down Expand Up @@ -41,17 +52,21 @@
end

it 'should be possible to #delete_all' do
expect(subject.class).not_to receive(:all)
expect_any_instance_of(subject.class).not_to receive(:before_destroy_callback)

expect(subject.class.count).to eq 3
expect(subject.class.before_destroy_callback_calls).to eq 0
subject.class.delete_all
expect(subject.class.count).to eq 0
expect(subject.class.before_destroy_callback_calls).to eq 0
end

it 'should be possible to #destroy_all' do
expect(subject.class).to receive(:all).and_return(subject.class.all)
expect(subject.class.count).to eq 3
expect(subject.class.before_destroy_callback_calls).to eq 0
subject.class.destroy_all
expect(subject.class.count).to eq 0
expect(subject.class.before_destroy_callback_calls).to eq 3
end
end
end

0 comments on commit b37dc14

Please sign in to comment.