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