Sha256: 168ec71dc3d6bcdc88360868e8ea2d21d416bea692acfb2cf2029dc628860ef5

Contents?: true

Size: 2 KB

Versions: 3

Compression:

Stored size: 2 KB

Contents

require 'spec_helper'

describe AtPay::Button::Template do
  let(:session) { mock }
  let(:options) { {destination: "Partner Name", email: 'bob@example.com', amount: 20, templates: "spec/fixtures/templates" } }
  let(:subject) { AtPay::Button::Template.new options }
  let(:subject_class) { AtPay::Button::Template }

  describe "#new" do
    it "adds the provided options to the defaults" do
      subject.instance_eval{ @options }.keys.sort.must_equal [:subject, :title, :color, :image, :processor, :destination, :templates, :email, :amount, :wrap].sort
    end
  end

  describe "#render" do
    it "renders yahoo specific templates for yahoo providers" do
      %w(test@yahoo.com test@ymail.com test@rocketmail.com).each do |email|
        subject.instance_eval { 
          @options[:email] = email 
        }

        subject.render.strip.must_equal "Yahoo"
      end
    end

    it "renders wrapped version of yahoo template for yahoo providers" do
      %w(test@yahoo.com test@ymail.com test@rocketmail.com).each do |email|
        subject.instance_eval { 
          @options[:email] = email 
          @options[:wrap] = true 
        }

        subject.render.strip.must_equal "Yahoo Wrap"
      end
    end

    it "renders default template for all other providers" do
      subject.instance_eval { 
        @options[:email] = "test@atpay.com" 
      }

      subject.render.strip.must_equal "Default"
    end

    it "renders wrapped version of default template for other providers" do
      subject.instance_eval { 
        @options[:email] = "test@atpay.com" 
        @options[:wrap] = true
      }

      subject.render.strip.must_equal "Default Wrap"
    end
  end

  # Integration style tests
  describe "#templates" do
    let(:options) { {destination: "Partner Name", amount: 20 } }
    
    it "should render with all known template types" do
      %w(test@hotmail.com test@yahoo.com test@atpay.com).each do |email|
        subject.instance_eval { @options[:email] = email }
        subject.render
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
atpay_buttons-1.1.1 spec/template_spec.rb
atpay_buttons-1.1.0 spec/template_spec.rb
atpay_buttons-1.0.0 spec/template_spec.rb