Sha256: eb9010675ce6b4ecddb104ddb60d5d0fd1893503a384d980a2197691188832c4

Contents?: true

Size: 1.43 KB

Versions: 5

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe CucumberFactory::BuildStrategy do

  subject { CucumberFactory::BuildStrategy }

  # most of the behaviour is integration tested in steps_spec.rb

  describe '.from_prose' do

    context 'when describing a factory_bot factory' do

      it 'returns a strategy corresponding to the factories model' do
        FactoryBot.stub_factories :job_offer => JobOffer
        strategy = subject.from_prose('job offer', nil)

        strategy.should be_a(described_class)
        strategy.model_class.should == JobOffer
      end

      it 'uses the variant for the factory name if present' do
        FactoryBot.stub_factories :job_offer => JobOffer
        strategy = subject.from_prose('foo', '(job offer)')

        strategy.should be_a(described_class)
        strategy.model_class.should == JobOffer
      end

    end

    context 'when describing a non factory_bot model' do

      it "should return a strategy for the class matching a natural language expression" do
        subject.from_prose("movie", nil).model_class.should == Movie
        subject.from_prose("job offer", nil).model_class.should == JobOffer
      end

      it "should ignore variants for the class name" do
        subject.from_prose("movie", "(job offer)").model_class.should == Movie
      end

      it "should allow namespaced models" do
        subject.from_prose("people/actor", nil).model_class.should == People::Actor
      end

    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cucumber_factory-2.0.2 spec/cucumber_factory/factory/build_strategy_spec.rb
cucumber_factory-2.0.1 spec/cucumber_factory/factory/build_strategy_spec.rb
cucumber_factory-2.0.0 spec/cucumber_factory/factory/build_strategy_spec.rb
cucumber_factory-1.15.1 spec/cucumber_factory/factory/build_strategy_spec.rb
cucumber_factory-1.15.0 spec/cucumber_factory/factory/build_strategy_spec.rb