Rspec file organization

Hi,

How should i best organise my custom matcher files, should stay in
spec/matchers? And how should they be namespaced? Also where should i
but custom example groups?

module ProjectName
module Spec
module Matchers
end
end
end

On Thu, Jan 1, 2009 at 2:45 PM, Jon S. [email protected]
wrote:

Hi,

How should i best organise my custom matcher files, should stay in
spec/matchers? And how should they be namespaced? Also where should i
but custom example groups?

I keep them in spec/support/matchers. As for namespacing, I don’t
write them into the Spec::Matchers module, but rather in their own
module (like you have below), which then gets included via the
configuration in spec/spec_helper.rb:

Spec::Runner.configure do |config|
config.include(ProjectName::Spec::Matchers)
end

I actually haven’t written any custom example groups aside from those
in the rspec-rails library, so I don’t have a convention for this, but
I imagine I’d put them in spec/support/example_groups.

HTH,
David

ps - you may want to check out the rspec users group as well:
http://groups.google.com/group/rspec

Thanks for you suggestion, i will go for the support folder. I’m not
sure if I use the example group as i should. I have done a special one
for acceptences test with watir.

class AcceptanceExampleGroup < Spec::Rails::Example::RailsExampleGroup
self.use_transactional_fixtures = false
attr_reader :browser

before(:all) do
@browser = Watir::Safari.new
end

before(:each) do
load(File.join(Rails.root, ‘db’, ‘schema.rb’))
end

after(:all) do
# @browser.close
end

Spec::Example::ExampleGroupFactory.register(:acceptance, self)
end

I maybe should use cucumber here, but as we don’t use it yet i feels
better to don’t add more frameworks.

Thanks
Jon

David C. wrote:

On Thu, Jan 1, 2009 at 2:45 PM, Jon S. [email protected]
wrote:

Hi,

How should i best organise my custom matcher files, should stay in
spec/matchers? And how should they be namespaced? Also where should i
but custom example groups?

I keep them in spec/support/matchers. As for namespacing, I don’t
write them into the Spec::Matchers module, but rather in their own
module (like you have below), which then gets included via the
configuration in spec/spec_helper.rb:

Spec::Runner.configure do |config|
config.include(ProjectName::Spec::Matchers)
end

I actually haven’t written any custom example groups aside from those
in the rspec-rails library, so I don’t have a convention for this, but
I imagine I’d put them in spec/support/example_groups.

HTH,
David

ps - you may want to check out the rspec users group as well:
http://groups.google.com/group/rspec