Sha256: 80b54a7b2e0a79ebad3d11998c46d2ff456b406fa09b96c191307cfc3531aded

Contents?: true

Size: 1.28 KB

Versions: 3

Compression:

Stored size: 1.28 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
require "mememe/meme"

class TestMeme
  include MemeMe::Meme

  def initialize
    @image = File.join(FIXTURES_PATH, 'joe.jpg')
  end
end

describe MemeMe::Meme do

  let(:meme) { TestMeme.new }

  it "has a name" do
    expect(meme.name).to eq "meme"
  end

  it "has an image" do
    expect(meme).to respond_to(:image)
  end

  it "has a top_phrase" do
    expect(meme.top_phrase).to eq ""
  end

  it "sets the top_phrase" do
    meme.top_phrase = "Test"
    expect(meme.top_phrase).to eq "Test"
  end

  it "hase a bottom_phrase" do
    expect(meme.bottom_phrase).to eq ""
  end

  describe 'generate' do

    before :each do
      FileUtils.mkdir TMP_DIR unless File.exists? TMP_DIR
    end

    after :each do
      FileUtils.rm_rf TMP_DIR if File.exists? TMP_DIR
    end

    it "requires a valid image path" do
      expect { meme.generate }.to raise_error ArgumentError
    end

    it "generates an image" do
      meme.top_phrase = "I was proud of my tests"
      meme.bottom_phrase = "Then I spoke to Joe"
      meme.generate(TMP_DIR)
      generated_image = File.join(TMP_DIR, 'meme.jpg')
      expect(File.exists?(generated_image)).to be_true
      expect(FileUtils.cmp(generated_image, meme.image)).to be_false
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mememe-0.1.2 spec/meme_spec.rb
mememe-0.1.1 spec/meme_spec.rb
mememe-0.1.0 spec/meme_spec.rb