postrank-labs/goliath — Issue #144: urgent: make Goliath::SpecHelper module robust
Author: hedgehog
Created: 2012-02-15 12:30:32+00:00
State: open

While RSpec does run the following trigger module for the appropriate examples, the `Goliath::TestHelper` methods are not available in the examples.

#spec_helper.rb
module WebhooksTrigger
def self.included(base)
::RSpec.configure do |config|
config.before(:suite) do
require 'goliath/test_helper'
::Goliath.env = :test
config.include ::Goliath::TestHelper, :example_group => { :file_path => /spec\/integration\/webhooks/ }
puts ' Loaded goliath/test_helper'
end
config.after(:each) do
end
config.after(:suite) do
end
end
end
end
RSpec.configure do |config|
config.include WebhooksTrigger, type: :webhook
end

I think the fix is not too difficult, and is essentially laid out in [FakeFS](https://github.com/defunkt/fakefs/blob/master/lib/fakefs/spec_helpers.rb), whose helper methods are correctly loaded by this type of conditional trigger mechanism/technique.

I also think this technique should be illustrated in the Goliath spec suite since it does allow another layer of indirection, and someone once commented: there is no CS problem that can 't be solved by adding another layer of indirection :)