Sha256: 4597318944347889cad3f71d7d09248310273477b6e6ac660897458496cfd407

Contents?: true

Size: 1.63 KB

Versions: 14

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'

describe Stripe::JavascriptHelper do
  before { Rails.application.config.stripe.publishable_key = 'pub_xxxx' }
  let(:controller)  { ActionView::TestCase::TestController.new }
  let(:view)        { controller.view_context }

  describe '#stripe_javascript_tag' do
    describe 'when no options are passed' do
      it 'should default to v3' do
        view.stripe_javascript_tag.must_include 'https://js.stripe.com/v3/'
      end
    end

    describe 'when the v2 option is passed' do
      it 'should default to v2' do
        view.stripe_javascript_tag(:v2).must_include 'https://js.stripe.com/v2/'
      end
    end

    describe 'when the debug flag is enabled' do
      before { Rails.application.config.stripe.debug_js = true }
      after  { Rails.application.config.stripe.debug_js = false }
      it 'should render the debug js' do
        view.stripe_javascript_tag(:v1).must_include 'https://js.stripe.com/v1/stripe-debug.js'
      end

      describe 'when v3 is selected' do
        it 'should not render debug js' do
          view.stripe_javascript_tag(:v3).wont_include 'https://js.stripe.com/v1/stripe-debug.js'
        end
      end
    end
  end

  describe "render :partial => 'stripe/js'" do
    subject { view.render :partial => 'stripe/js' }

    it 'should render correctly' do
      subject.must_include 'https://js.stripe.com/v3/'
    end
  end

  describe "render :partial => 'stripe/js', local: {stripe_js_version: 'v2'}" do
    subject { view.render :partial => 'stripe/js', locals: {stripe_js_version: 'v2'} }

    it 'should render correctly' do
      subject.must_include 'https://js.stripe.com/v2/'
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
stripe-rails-1.5.5 test/javascript_helper_spec.rb
stripe-rails-1.5.4 test/javascript_helper_spec.rb
stripe-rails-1.5.3 test/javascript_helper_spec.rb
stripe-rails-1.5.2 test/javascript_helper_spec.rb
stripe-rails-1.5.1 test/javascript_helper_spec.rb
stripe-rails-1.5.0 test/javascript_helper_spec.rb
stripe-rails-1.4.2 test/javascript_helper_spec.rb
stripe-rails-1.4.1 test/javascript_helper_spec.rb
stripe-rails-1.4.0 test/javascript_helper_spec.rb
stripe-rails-1.3.0 test/javascript_helper_spec.rb
stripe-rails-1.2.2 test/javascript_helper_spec.rb
stripe-rails-1.2.1 test/javascript_helper_spec.rb
stripe-rails-1.2.0 test/javascript_helper_spec.rb
stripe-rails-1.1.2 test/javascript_helper_spec.rb