email_preview icon indicating copy to clipboard operation
email_preview copied to clipboard

specs integration

Open costa opened this issue 11 years ago • 6 comments

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.

costa avatar Jan 15 '14 09:01 costa

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 avatar Jan 15 '14 14:01 costa

@costa what are you planning to test? do you want an integration test that checks that email_preview works correctly in your setup?

ilyakatz avatar Jan 15 '14 15:01 ilyakatz

@ilyakatz Well it's a kinda "free" mail views test.

costa avatar Jan 15 '14 15:01 costa

@costa sorry, I don't understand. Can you give an example please?

ilyakatz avatar Jan 15 '14 16:01 ilyakatz

@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.

wireframe avatar Jan 15 '14 16:01 wireframe

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).

costa avatar Jan 15 '14 17:01 costa