Sha256: 6c507931ae4a21c7b6e59bd21921e73c825c92413a90daf74c06e1b4e7fed576

Contents?: true

Size: 1.48 KB

Versions: 6

Compression:

Stored size: 1.48 KB

Contents

require 'spec_helper'
require_relative '../../support/factory_girl_mock'

describe Cucumber::Factory::BuildStrategy do

  subject { Cucumber::Factory::BuildStrategy }

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

  describe '.from_prose' do

    context 'when describing a factory girl factory' do

      it 'returns a strategy corresponding to the factories model' do
        FactoryGirl.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
        FactoryGirl.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 girl 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

6 entries across 6 versions & 1 rubygems

Version Path
cucumber_factory-1.11.4 spec/shared/cucumber_factory/factory/build_strategy_spec.rb
cucumber_factory-1.11.3 spec/shared/cucumber_factory/factory/build_strategy_spec.rb
cucumber_factory-1.11.2 spec/shared/cucumber_factory/factory/build_strategy_spec.rb
cucumber_factory-1.11.1 spec/shared/cucumber_factory/factory/build_strategy_spec.rb
cucumber_factory-1.11.0 spec/shared/cucumber_factory/factory/build_strategy_spec.rb
cucumber_factory-1.10.0 spec/shared/cucumber_factory/factory/build_strategy_spec.rb