Sha256: d03c057032616998d6ae88546f2c0916eb3c90d7cb8c36999bb9e439499719f6

Contents?: true

Size: 1.82 KB

Versions: 1

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'

describe Rtml::Test::SimulatorPostProcessors::CardParsers do
  def tml_for(parser, params)
  <<-end_tml
    <tml>
      <screen id='setup' next='#first'>
        #{setup_tml_for(parser)}
      </screen>          

      <screen id='alt_first'>
        <next uri='#second'>
          <variant uri='#first' key='1' />
        </next>
        #{setup_tml_for(parser)}
      </screen>

      <screen id='first' next='#second'><tform><card parser='#{parser}' parser_params='#{params}' /></tform></screen>
      <screen id='second'><display>done</display></screen>
    </tml>
  end_tml
  end

  def setup_tml_for(parser)
    case parser.to_s
      when 'mag'
      <<-end_tml
        <tform>
          <card parser="mag" parser_params="read_data" />
        </tform>
      end_tml
      else raise 'no setup code for '+parser.to_s
    end
  end

  subject do
    Rtml::Test::Simulator.new
  end

  context "with a 'mag' parser" do
    context "and 'risk_mgmt' params" do
      before(:each) do
        subject.load_tml! tml_for("mag", "risk_mgmt")
      end

      it "should set 'card.parser.verdict' to 'online'" do
        subject.swipe_card(:visa)
        subject.variables['card.parser.verdict'].should == 'online'
      end

      it "should move to the next screen" do
        subject.swipe_card(:visa)
        subject.current_screen_id.should_not == "first"
        subject.current_screen_id.should_not be_nil
      end
      
      context "given a next element with false variants" do
        it "should follow the next uri" do
          subject.visit("#alt_first")
          subject.current_screen_id.should == "alt_first"
          subject.swipe_card(:visa)
          subject.current_screen_id.should_not == "first"
          subject.current_screen_id.should_not be_nil
        end
      end
    end
  end

  it "with an 'emv' reader"
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rtml-2.0.4 spec/widgets/simulator_post_processors/card_parsers_spec.rb