email_preview
email_preview copied to clipboard
specs integration
I would like to use my mail preview code in my specs suite; will be grateful for any ideas on doing so — or substantial reasons not to.
To be clear, I've implemented a simple plain ruby class specs for this (and they work fine), I just think this — or a more sophisticated technique — should be mentioned in Readme.
@costa what are you planning to test? do you want an integration test that checks that email_preview works correctly in your setup?
@ilyakatz Well it's a kinda "free" mail views test.
@costa sorry, I don't understand. Can you give an example please?
@costa can you share what your plain ruby class spec looks like? I'm not following what you're looking for and seeing a first-pass solution would be helpful to see what could be integrated into the core gem.
I've just come up with a basic and simplistic outfit:
spec/views/mail_spec.rb:
require 'spec_helper'
describe MailPreview do
MailPreview.new.public_methods(false).each do |e|
example_ok e
end
end
Plus:
class RSpec::Core::ExampleGroup
def self.example_ok(e)
example "##{e}" do
subject.send(e).should_not be_blank
end
end
end
p.s. MailPreview
is my MailView
subclass here, of course, and the goal is to see it renders with no exceptions as a bare minimum (which is not totally trivial, if you mind i18n exceptions etc).