Skip to content

Commit

Permalink
Exposing a test_helper from event_counter engine to be used in tests …
Browse files Browse the repository at this point in the history
…of other engines
  • Loading branch information
shageman committed Jan 13, 2015
1 parent 828b3fe commit 0d46a3c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 4 deletions.
1 change: 1 addition & 0 deletions components/event_counter/lib/event_counter/test_helper.rb
@@ -0,0 +1 @@
require_relative "../../spec/support/test_helper"
13 changes: 13 additions & 0 deletions components/event_counter/spec/support/test_helper.rb
@@ -0,0 +1,13 @@
module EventCounter
module TestHelper
def self.new_logger(object_identifier = nil, event_identifier = nil, count = nil)
logger = EventCounter::Logger.new
if object_identifier && event_identifier && count
count.times do
logger.log object_identifier, event_identifier
end
end
logger
end
end
end
7 changes: 3 additions & 4 deletions components/teaser/spec/controllers/tease_controller_spec.rb
Expand Up @@ -36,11 +36,10 @@ module Teaser
controller.instance_variable_set "@annoyance_meter", mock_annoyance_meter
entry_manager = EmailSignup::EntryManager.new
controller.instance_variable_set "@entry_manager", entry_manager
event_counter = EventCounter::Logger.new
controller.instance_variable_set "@event_counter", event_counter

entry = entry_manager.create "adam"
event_counter.log "email_signup_entry_#{entry.id}", "signup"

event_counter = EventCounter::TestHelper.new_logger("email_signup_entry_#{entry.id}", "signup", 1)
controller.instance_variable_set "@event_counter", event_counter

xhr :post, :create, new_sign_up_entry: "adam", use_route: "teaser"
response.status.should == 400
Expand Down
1 change: 1 addition & 0 deletions components/teaser/spec/spec_helper.rb
Expand Up @@ -3,6 +3,7 @@

require 'rspec/rails'
require 'shoulda-matchers'
require 'event_counter/test_helper'

Dir[Teaser::Engine.root.join("spec/support/**/*.rb")].each {|f| require f}

Expand Down

0 comments on commit 0d46a3c

Please sign in to comment.