Skip to content

Commit

Permalink
Implement ActiveSupport subscriber compatability tests
Browse files Browse the repository at this point in the history
  • Loading branch information
snovity committed Feb 2, 2017
1 parent 213f34c commit 9282036
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 8 deletions.
51 changes: 50 additions & 1 deletion spec/gem_conflicts/active_support_subscriber_spec.rb
Original file line number Diff line number Diff line change
@@ -1 +1,50 @@
# TODO
require 'spec_helper'

describe "Konstructor with Thor" do

before :all do
require 'konstructor'
require 'active_support/subscriber'
require 'active_support/notifications'
end

before :all do
class TestSubscriber < ActiveSupport::Subscriber
attr_accessor :zero, :one, :two, :three

def before_attached(event)
@one = event.payload[:one]
end

konstructor
def betta(three)
@three = three
end
end

TestSubscriber.attach_to :test_namespace

class TestSubscriber
def after_attached(event)
@two = event.payload[:two]
end
end
end

context "method defined after attaching continue to work" do
let(:instance) do
ActiveSupport::Notifications.instrument('before_attached.test_namespace', one: 111)
ActiveSupport::Notifications.instrument('after_attached.test_namespace', two: 2)
TestSubscriber.subscribers.last
end

specify { expect_instance_state nil, 111, 2, nil }
end

context "konstructor works" do
let(:instance) { TestSubscriber.betta(333) }

specify { expect_instance_state nil, nil, nil, 333 }
end

end
1 change: 0 additions & 1 deletion spec/gem_conflicts/constructor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'spec_helper'
require_relative '../shared'

describe "Konstructor with constructor" do

Expand Down
1 change: 0 additions & 1 deletion spec/inheritance/via_modules_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
require 'spec_helper'
require_relative '../shared'
require 'active_support/concern'

describe "konstructor via modules" do

Expand Down
11 changes: 6 additions & 5 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@
config.extend RspecExtensions

config.register_ordering(:global) do |examples|
gem_specs = []
gem_conflicts_specs = []
general_specs = []

examples.select do |example|
if example.metadata[:file_path].include?('spec/gem_conflicts')
gem_specs << example
gem_conflicts_specs << example
else
general_specs << example
end
end

# gem specs do konstructor core extentions that can't be reverted
general_specs + gem_specs
# gem conflicts specs require konstructor core extentions that can't be reverted
general_specs + gem_conflicts_specs
end
end

require 'konstructor/no_core_ext'
require 'konstructor/no_core_ext'
require 'active_support/concern'

0 comments on commit 9282036

Please sign in to comment.