Skip to content

Commit

Permalink
Test realtime observer module.
Browse files Browse the repository at this point in the history
  • Loading branch information
nybblr committed Sep 16, 2013
1 parent 78c6ecf commit aa76ebf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/robin/rails.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'active_support/concern'
require 'net/http'
# require 'robin'

module Robin
module Rails
Expand Down
46 changes: 46 additions & 0 deletions spec/robin/rails_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
require 'spec_helper'
require 'robin-rails'
require 'active_record'

class DummyModel < ActiveRecord::Base
include Robin::Rails
end

describe Robin::Rails do
before(:all) do
# Throw together a fake DB
ActiveRecord::Base.establish_connection(
:adapter => 'sqlite3',
:database => ':memory:'
)

ActiveRecord::Migration.verbose = false
ActiveRecord::Schema.define do
create_table :dummy_models, force: true
end
end

context 'included module' do
before do
Robin.stub(:publish)
end

it 'calls publish after create' do
Robin.should_receive(:publish).with(anything, :created, anything)

DummyModel.create
end

it 'calls publish after update' do
record = DummyModel.create
Robin.should_receive(:publish).with(anything, :updated, anything)
record.save
end

it 'calls publish after destroy' do
record = DummyModel.create
Robin.should_receive(:publish).with(anything, :destroyed, anything)
record.destroy
end
end
end

0 comments on commit aa76ebf

Please sign in to comment.