cucumber_factory 2.0.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/Gemfile.cucumber-1.3 +3 -0
- data/Gemfile.cucumber-1.3.lock +4 -1
- data/Gemfile.cucumber-2.4 +3 -0
- data/Gemfile.cucumber-2.4.lock +4 -1
- data/Gemfile.cucumber-3.0 +3 -0
- data/Gemfile.cucumber-3.0.lock +4 -1
- data/Gemfile.cucumber-3.1 +3 -0
- data/Gemfile.cucumber-3.1.lock +4 -1
- data/README.md +1 -1
- data/lib/cucumber_factory/build_strategy.rb +94 -48
- data/lib/cucumber_factory/factory.rb +22 -9
- data/lib/cucumber_factory/version.rb +1 -1
- data/spec/cucumber_factory/factory/build_strategy_spec.rb +12 -14
- data/spec/cucumber_factory/steps_spec.rb +417 -405
- data/spec/spec_helper.rb +3 -0
- data/spec/support/database.rb +6 -0
- data/spec/support/factories/factories.rb +32 -0
- data/spec/support/models/job_offer.rb +1 -3
- data/spec/support/models/opera.rb +2 -3
- metadata +4 -4
- data/spec/support/factory_bot_mock.rb +0 -17
| @@ -1,490 +1,502 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 3 | 
            +
            TRANSFORMS_SUPPORTED = Cucumber::VERSION < '3'
         | 
| 4 4 |  | 
| 5 | 
            +
            describe 'steps provided by cucumber_factory' do
         | 
| 5 6 | 
             
              before(:each) do
         | 
| 6 7 | 
             
                prepare_cucumber_example
         | 
| 7 8 | 
             
              end
         | 
| 8 9 |  | 
| 9 | 
            -
               | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 15 | 
            -
                 | 
| 16 | 
            -
              end
         | 
| 17 | 
            -
             | 
| 18 | 
            -
              it "should create models that have a machinist blueprint by calling #make" do
         | 
| 19 | 
            -
                MachinistModel.should_receive(:make).with({ :attribute => "foo"})
         | 
| 20 | 
            -
                invoke_cucumber_step('there is a machinist model with the attribute "foo"')
         | 
| 21 | 
            -
              end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
              it "should be able to step_match machinist blueprint variants" do
         | 
| 24 | 
            -
                MachinistModel.should_receive(:make).with(:variant, { :attribute => "foo"})
         | 
| 25 | 
            -
                invoke_cucumber_step('there is a machinist model (variant) with the attribute "foo"')
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              it "should be able to step_match machinist blueprint variants containing spaces or uppercase characters in prose" do
         | 
| 29 | 
            -
                MachinistModel.should_receive(:make).with(:variant_mark_two, { :attribute => "foo"})
         | 
| 30 | 
            -
                invoke_cucumber_step('there is a machinist model (Variant Mark Two) with the attribute "foo"')
         | 
| 31 | 
            -
              end
         | 
| 32 | 
            -
             | 
| 33 | 
            -
              it "should create models that have a factory_bot factory by calling #FactoryBot.create(:model_name)" do
         | 
| 34 | 
            -
                FactoryBot.stub_factories :job_offer => JobOffer
         | 
| 35 | 
            -
                FactoryBot.should_receive(:create).with(:job_offer, { :title => "Awesome job" })
         | 
| 36 | 
            -
                invoke_cucumber_step('there is a job offer with the title "Awesome job"')
         | 
| 37 | 
            -
              end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
              it "should create model variants that have a factory_bot factory by calling #FactoryBot.create(:variant)" do
         | 
| 40 | 
            -
                FactoryBot.stub_factories :tempting_job_offer => JobOffer
         | 
| 41 | 
            -
                FactoryBot.should_receive(:create).with(:tempting_job_offer, { :title => "Awesomafiablyfantasmic job" })
         | 
| 42 | 
            -
                invoke_cucumber_step('there is a job offer (tempting job offer) with the title "Awesomafiablyfantasmic job"')
         | 
| 43 | 
            -
              end
         | 
| 44 | 
            -
             | 
| 45 | 
            -
              it "should create model variants that have a factory_bot trait by calling #FactoryBot.create(:factory, :trait1, :trait2)" do
         | 
| 46 | 
            -
                FactoryBot.stub_factories :tempting_job_offer => JobOffer
         | 
| 47 | 
            -
                FactoryBot.should_receive(:create).with(:tempting_job_offer, :risky, :lucrative, { :title => "Awesomafiablyfantasmic job" })
         | 
| 48 | 
            -
                invoke_cucumber_step('there is a tempting job offer (risky, lucrative) with the title "Awesomafiablyfantasmic job"')
         | 
| 49 | 
            -
              end
         | 
| 10 | 
            +
              context 'FactoryBot' do
         | 
| 11 | 
            +
                it "should create ActiveRecord models by calling #new and #save!" do
         | 
| 12 | 
            +
                  movie = Movie.new
         | 
| 13 | 
            +
                  Movie.should_receive(:new).with(no_args).and_return(movie)
         | 
| 14 | 
            +
                  movie.should_receive(:save!)
         | 
| 15 | 
            +
                  invoke_cucumber_step("there is a movie")
         | 
| 16 | 
            +
                end
         | 
| 50 17 |  | 
| 51 | 
            -
             | 
| 52 | 
            -
             | 
| 53 | 
            -
             | 
| 54 | 
            -
                 | 
| 55 | 
            -
              end
         | 
| 18 | 
            +
                it "should create models that have a factory_bot factory by calling #FactoryBot.create(:model_name)" do
         | 
| 19 | 
            +
                  FactoryBot.should_receive(:create).with(:job_offer, { :title => "Awesome job" })
         | 
| 20 | 
            +
                  invoke_cucumber_step('there is a job offer with the title "Awesome job"')
         | 
| 21 | 
            +
                end
         | 
| 56 22 |  | 
| 57 | 
            -
             | 
| 58 | 
            -
             | 
| 59 | 
            -
             | 
| 60 | 
            -
             | 
| 23 | 
            +
                it "should create model variants that have a factory_bot factory by calling #FactoryBot.create(:variant)" do
         | 
| 24 | 
            +
                  FactoryBot.should_receive(:create).with(:job_offer, :tempting_job_offer, { :title => "Awesomafiablyfantasmic job" })
         | 
| 25 | 
            +
                  invoke_cucumber_step('there is a job offer (tempting job offer) with the title "Awesomafiablyfantasmic job"')
         | 
| 26 | 
            +
                end
         | 
| 61 27 |  | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 28 | 
            +
                it "should create model variants that have a factory_bot trait by calling #FactoryBot.create(:factory, :trait1, :trait2)" do
         | 
| 29 | 
            +
                  FactoryBot.should_receive(:create).with(:job_offer, :risky, :lucrative, { :title => "Awesomafiablyfantasmic job" })
         | 
| 30 | 
            +
                  invoke_cucumber_step('there is a job offer (risky, lucrative) with the title "Awesomafiablyfantasmic job"')
         | 
| 31 | 
            +
                end
         | 
| 66 32 |  | 
| 67 | 
            -
             | 
| 68 | 
            -
             | 
| 69 | 
            -
             | 
| 70 | 
            -
                 | 
| 71 | 
            -
              end
         | 
| 33 | 
            +
                it "should create model variants that have a factory_bot factory by using the model name as a factory name" do
         | 
| 34 | 
            +
                  FactoryBot.should_receive(:create).with(:job_offer, { :title => "Awesomafiablyfantasmic job" })
         | 
| 35 | 
            +
                  invoke_cucumber_step('there is a job offer with the title "Awesomafiablyfantasmic job"')
         | 
| 36 | 
            +
                end
         | 
| 72 37 |  | 
| 73 | 
            -
             | 
| 74 | 
            -
             | 
| 75 | 
            -
             | 
| 76 | 
            -
             | 
| 77 | 
            -
             | 
| 38 | 
            +
                it "should instantiate classes with multiple words in their name" do
         | 
| 39 | 
            +
                  job_offer = JobOffer.new
         | 
| 40 | 
            +
                  JobOffer.should_receive(:new).with(no_args).and_return(job_offer)
         | 
| 41 | 
            +
                  invoke_cucumber_step("there is a job offer")
         | 
| 42 | 
            +
                end
         | 
| 78 43 |  | 
| 79 | 
            -
             | 
| 80 | 
            -
             | 
| 81 | 
            -
             | 
| 82 | 
            -
             | 
| 44 | 
            +
                it "should instantiate classes with uppercase characters in their name" do
         | 
| 45 | 
            +
                  user = User.new
         | 
| 46 | 
            +
                  User.should_receive(:new).and_return(user)
         | 
| 47 | 
            +
                  invoke_cucumber_step("there is a User")
         | 
| 48 | 
            +
                end
         | 
| 83 49 |  | 
| 84 | 
            -
             | 
| 85 | 
            -
             | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
                 | 
| 89 | 
            -
                movie.year.should == 2007
         | 
| 90 | 
            -
              end
         | 
| 50 | 
            +
                it "should allow either 'a' or 'an' for the article" do
         | 
| 51 | 
            +
                  opera = Opera.new
         | 
| 52 | 
            +
                  Opera.should_receive(:new).with(no_args).and_return(opera)
         | 
| 53 | 
            +
                  invoke_cucumber_step("there is an opera")
         | 
| 54 | 
            +
                end
         | 
| 91 55 |  | 
| 92 | 
            -
             | 
| 93 | 
            -
             | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 98 | 
            -
                 | 
| 99 | 
            -
              end
         | 
| 56 | 
            +
                it "should create records with attributes" do
         | 
| 57 | 
            +
                  movie = Movie.new
         | 
| 58 | 
            +
                  Movie.stub(:new => movie)
         | 
| 59 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Sunshine" and the year "2007"')
         | 
| 60 | 
            +
                  movie.title.should == "Sunshine"
         | 
| 61 | 
            +
                  movie.year.should == 2007
         | 
| 62 | 
            +
                end
         | 
| 100 63 |  | 
| 101 | 
            -
             | 
| 102 | 
            -
                it "should apply Cucumber transforms to attribute values" do
         | 
| 64 | 
            +
                it "should allow to join attribute lists with 'and's, commas and 'but's" do
         | 
| 103 65 | 
             
                  movie = Movie.new
         | 
| 104 66 | 
             
                  Movie.stub(:new => movie)
         | 
| 105 | 
            -
                   | 
| 106 | 
            -
             | 
| 107 | 
            -
             | 
| 67 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Sunshine", the year "2007" but with the box office result "32000000"')
         | 
| 68 | 
            +
                  movie.title.should == "Sunshine"
         | 
| 69 | 
            +
                  movie.year.should == 2007
         | 
| 70 | 
            +
                  movie.box_office_result.should == 32000000
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                if TRANSFORMS_SUPPORTED
         | 
| 74 | 
            +
                  it "should apply Cucumber transforms to attribute values" do
         | 
| 75 | 
            +
                    movie = Movie.new
         | 
| 76 | 
            +
                    Movie.stub(:new => movie)
         | 
| 77 | 
            +
                    @main.instance_eval do
         | 
| 78 | 
            +
                      Transform /^(value)$/ do |value|
         | 
| 79 | 
            +
                        'transformed value'
         | 
| 80 | 
            +
                      end
         | 
| 108 81 | 
             
                    end
         | 
| 82 | 
            +
                    invoke_cucumber_step('there is a movie with the title "value"')
         | 
| 83 | 
            +
                    movie.title.should == "transformed value"
         | 
| 109 84 | 
             
                  end
         | 
| 110 | 
            -
                  invoke_cucumber_step('there is a movie with the title "value"')
         | 
| 111 | 
            -
                  movie.title.should == "transformed value"
         | 
| 112 85 | 
             
                end
         | 
| 113 | 
            -
              end
         | 
| 114 86 |  | 
| 115 | 
            -
             | 
| 116 | 
            -
             | 
| 117 | 
            -
             | 
| 118 | 
            -
             | 
| 119 | 
            -
             | 
| 120 | 
            -
             | 
| 87 | 
            +
                it "should create records with attributes containing spaces" do
         | 
| 88 | 
            +
                  movie = Movie.new
         | 
| 89 | 
            +
                  Movie.stub(:new => movie)
         | 
| 90 | 
            +
                  invoke_cucumber_step('there is a movie with the box office result "99999999"')
         | 
| 91 | 
            +
                  movie.box_office_result.should == 99999999
         | 
| 92 | 
            +
                end
         | 
| 121 93 |  | 
| 122 | 
            -
             | 
| 123 | 
            -
             | 
| 124 | 
            -
             | 
| 125 | 
            -
             | 
| 126 | 
            -
             | 
| 127 | 
            -
             | 
| 94 | 
            +
                it "should create records with attributes containing uppercase characters" do
         | 
| 95 | 
            +
                  user = User.new
         | 
| 96 | 
            +
                  User.stub(:new => user)
         | 
| 97 | 
            +
                  invoke_cucumber_step('there is a User with the Name "Susanne"')
         | 
| 98 | 
            +
                  user.name.should == "Susanne"
         | 
| 99 | 
            +
                end
         | 
| 128 100 |  | 
| 129 | 
            -
             | 
| 130 | 
            -
             | 
| 131 | 
            -
             | 
| 132 | 
            -
             | 
| 133 | 
            -
             | 
| 134 | 
            -
             | 
| 101 | 
            +
                it "should override attr_accessible protection" do
         | 
| 102 | 
            +
                  invoke_cucumber_step('there is a payment with the amount "120" and the comment "Thanks for lending"')
         | 
| 103 | 
            +
                  payment = Payment.last
         | 
| 104 | 
            +
                  payment.amount.should == 120
         | 
| 105 | 
            +
                  payment.comment.should == 'Thanks for lending'
         | 
| 106 | 
            +
                end
         | 
| 135 107 |  | 
| 136 | 
            -
             | 
| 137 | 
            -
             | 
| 138 | 
            -
             | 
| 139 | 
            -
             | 
| 140 | 
            -
             | 
| 108 | 
            +
                it "should allow to set an explicit primary key" do
         | 
| 109 | 
            +
                  invoke_cucumber_step('there is a payment with the ID 2')
         | 
| 110 | 
            +
                  payment = Payment.last
         | 
| 111 | 
            +
                  payment.id.should == 2
         | 
| 112 | 
            +
                end
         | 
| 141 113 |  | 
| 142 | 
            -
             | 
| 143 | 
            -
             | 
| 144 | 
            -
             | 
| 145 | 
            -
             | 
| 146 | 
            -
             | 
| 147 | 
            -
             | 
| 148 | 
            -
             | 
| 149 | 
            -
             | 
| 114 | 
            +
                it "should allow to name records and set a belongs_to association to that record by refering to that name" do
         | 
| 115 | 
            +
                  invoke_cucumber_step('"Some Prequel" is a movie with the title "Before Sunrise"')
         | 
| 116 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Limitless"')
         | 
| 117 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunset" and the prequel "Some Prequel"')
         | 
| 118 | 
            +
                  movie = Movie.find_by_title!('Before Sunset')
         | 
| 119 | 
            +
                  prequel = Movie.find_by_title!('Before Sunrise')
         | 
| 120 | 
            +
                  movie.prequel.should == prequel
         | 
| 121 | 
            +
                end
         | 
| 150 122 |  | 
| 151 | 
            -
             | 
| 152 | 
            -
             | 
| 153 | 
            -
             | 
| 154 | 
            -
             | 
| 155 | 
            -
             | 
| 156 | 
            -
             | 
| 157 | 
            -
             | 
| 158 | 
            -
             | 
| 123 | 
            +
                it "should allow to set a belongs_to association to a previously created record by refering to any string attribute of that record" do
         | 
| 124 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunrise"')
         | 
| 125 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Limitless"')
         | 
| 126 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunset" and the prequel "Before Sunrise"')
         | 
| 127 | 
            +
                  movie = Movie.find_by_title!('Before Sunset')
         | 
| 128 | 
            +
                  prequel = Movie.find_by_title!('Before Sunrise')
         | 
| 129 | 
            +
                  movie.prequel.should == prequel
         | 
| 130 | 
            +
                end
         | 
| 159 131 |  | 
| 160 | 
            -
             | 
| 161 | 
            -
             | 
| 162 | 
            -
             | 
| 163 | 
            -
             | 
| 164 | 
            -
             | 
| 165 | 
            -
             | 
| 166 | 
            -
             | 
| 132 | 
            +
                it "should allow to set a belongs_to association to a previously created record by refering to their explicitely set primary keys" do
         | 
| 133 | 
            +
                  invoke_cucumber_step('there is a movie with the ID 123')
         | 
| 134 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunset" and the prequel 123')
         | 
| 135 | 
            +
                  movie = Movie.find_by_title!('Before Sunset')
         | 
| 136 | 
            +
                  prequel = Movie.find(123)
         | 
| 137 | 
            +
                  movie.prequel.should == prequel
         | 
| 138 | 
            +
                end
         | 
| 167 139 |  | 
| 168 | 
            -
             | 
| 169 | 
            -
             | 
| 170 | 
            -
             | 
| 171 | 
            -
             | 
| 172 | 
            -
             | 
| 173 | 
            -
             | 
| 174 | 
            -
             | 
| 175 | 
            -
             | 
| 176 | 
            -
             | 
| 177 | 
            -
             | 
| 140 | 
            +
                it "should allow to set a belongs_to association to a previously created record by saying 'above'" do
         | 
| 141 | 
            +
                  invoke_cucumber_step('there is a user with the name "Jane"')
         | 
| 142 | 
            +
                  invoke_cucumber_step('there is a user with the name "John"')
         | 
| 143 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Limitless"')
         | 
| 144 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunrise"')
         | 
| 145 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunset" and the reviewer above and the prequel above')
         | 
| 146 | 
            +
                  before_sunset = Movie.find_by_title!("Before Sunset")
         | 
| 147 | 
            +
                  before_sunset.prequel.title.should == "Before Sunrise"
         | 
| 148 | 
            +
                  before_sunset.reviewer.name.should == "John"
         | 
| 149 | 
            +
                end
         | 
| 178 150 |  | 
| 179 | 
            -
             | 
| 180 | 
            -
             | 
| 181 | 
            -
             | 
| 182 | 
            -
             | 
| 183 | 
            -
             | 
| 184 | 
            -
             | 
| 151 | 
            +
                if TRANSFORMS_SUPPORTED
         | 
| 152 | 
            +
                  it "should fallback to using transforms when no named record is found" do
         | 
| 153 | 
            +
                    user = User.create!(:name => 'Me')
         | 
| 154 | 
            +
                    @main.instance_eval do
         | 
| 155 | 
            +
                      Transform(/^(me)$/) do |value|
         | 
| 156 | 
            +
                        user
         | 
| 157 | 
            +
                      end
         | 
| 185 158 | 
             
                    end
         | 
| 159 | 
            +
                    invoke_cucumber_step('there is a movie with the title "Before Sunset" and the reviewer "me"')
         | 
| 160 | 
            +
                    before_sunset = Movie.find_by_title!("Before Sunset")
         | 
| 161 | 
            +
                    before_sunset.reviewer.should == user
         | 
| 186 162 | 
             
                  end
         | 
| 187 | 
            -
             | 
| 163 | 
            +
                end
         | 
| 164 | 
            +
             | 
| 165 | 
            +
                it "should give created_at precedence over id when saying 'above' if the primary key is not numeric" do
         | 
| 166 | 
            +
                  invoke_cucumber_step('there is a uuid user with the name "Jane" and the id "jane"')
         | 
| 167 | 
            +
                  invoke_cucumber_step('there is a uuid user with the name "John" and the id "john"')
         | 
| 168 | 
            +
                  UuidUser.find_by_name("John").update_attributes!(:created_at => 1.day.ago)
         | 
| 169 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunset" and the uuid reviewer above')
         | 
| 188 170 | 
             
                  before_sunset = Movie.find_by_title!("Before Sunset")
         | 
| 189 | 
            -
                  before_sunset. | 
| 171 | 
            +
                  before_sunset.uuid_reviewer.name.should == "Jane"
         | 
| 190 172 | 
             
                end
         | 
| 191 | 
            -
              end
         | 
| 192 173 |  | 
| 193 | 
            -
             | 
| 194 | 
            -
             | 
| 195 | 
            -
             | 
| 196 | 
            -
             | 
| 197 | 
            -
             | 
| 198 | 
            -
             | 
| 199 | 
            -
             | 
| 200 | 
            -
             | 
| 174 | 
            +
                it "should ignore created_at if the primary key is numeric" do
         | 
| 175 | 
            +
                  invoke_cucumber_step('there is a user with the name "Jane"')
         | 
| 176 | 
            +
                  invoke_cucumber_step('there is a user with the name "John"')
         | 
| 177 | 
            +
                  User.find_by_name("John").update_attributes!(:created_at => 1.day.ago)
         | 
| 178 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunset" and the reviewer above')
         | 
| 179 | 
            +
                  before_sunset = Movie.find_by_title!("Before Sunset")
         | 
| 180 | 
            +
                  before_sunset.reviewer.name.should == "John"
         | 
| 181 | 
            +
                end
         | 
| 201 182 |  | 
| 202 | 
            -
             | 
| 203 | 
            -
             | 
| 204 | 
            -
             | 
| 205 | 
            -
             | 
| 206 | 
            -
                 | 
| 207 | 
            -
                before_sunset = Movie.find_by_title!("Before Sunset")
         | 
| 208 | 
            -
                before_sunset.reviewer.name.should == "John"
         | 
| 209 | 
            -
              end
         | 
| 183 | 
            +
                it "should raise a proper error if there is no previous record when saying 'above'" do
         | 
| 184 | 
            +
                  lambda do
         | 
| 185 | 
            +
                    invoke_cucumber_step('there is a movie with the title "Before Sunset" and the reviewer above and the prequel above')
         | 
| 186 | 
            +
                  end.should raise_error(/There is no last reviewer/i)
         | 
| 187 | 
            +
                end
         | 
| 210 188 |  | 
| 211 | 
            -
             | 
| 212 | 
            -
             | 
| 213 | 
            -
                   | 
| 214 | 
            -
             | 
| 215 | 
            -
             | 
| 189 | 
            +
                it "should reload an object assigned to a belongs_to before assigning" do
         | 
| 190 | 
            +
                  invoke_cucumber_step('"Jane" is a user who is deleted')
         | 
| 191 | 
            +
                  User.last.update_attributes(:deleted => false)
         | 
| 192 | 
            +
                  proc { invoke_cucumber_step('there is a movie with the title "Before Sunset" and the reviewer "Jane"') }.should_not raise_error
         | 
| 193 | 
            +
                end
         | 
| 216 194 |  | 
| 217 | 
            -
             | 
| 218 | 
            -
             | 
| 219 | 
            -
             | 
| 220 | 
            -
             | 
| 221 | 
            -
             | 
| 195 | 
            +
                it "should allow to set positive boolean attributes with 'who' after the attribute list" do
         | 
| 196 | 
            +
                  user = User.new
         | 
| 197 | 
            +
                  User.stub(:new => user)
         | 
| 198 | 
            +
                  invoke_cucumber_step('there is a user with the name "Jane" who is deleted')
         | 
| 199 | 
            +
                  user.name.should == "Jane"
         | 
| 200 | 
            +
                  user.deleted.should == true
         | 
| 201 | 
            +
                end
         | 
| 222 202 |  | 
| 223 | 
            -
             | 
| 224 | 
            -
             | 
| 225 | 
            -
             | 
| 226 | 
            -
             | 
| 227 | 
            -
             | 
| 228 | 
            -
             | 
| 229 | 
            -
             | 
| 203 | 
            +
                it "should allow to set positive boolean attributes with 'which' after the attribute list" do
         | 
| 204 | 
            +
                  user = User.new
         | 
| 205 | 
            +
                  User.stub(:new => user)
         | 
| 206 | 
            +
                  invoke_cucumber_step('there is a user with the name "Jane" which is deleted')
         | 
| 207 | 
            +
                  user.name.should == "Jane"
         | 
| 208 | 
            +
                  user.deleted.should == true
         | 
| 209 | 
            +
                end
         | 
| 230 210 |  | 
| 231 | 
            -
             | 
| 232 | 
            -
             | 
| 233 | 
            -
             | 
| 234 | 
            -
             | 
| 235 | 
            -
             | 
| 236 | 
            -
             | 
| 237 | 
            -
             | 
| 211 | 
            +
                it "should allow to set positive boolean attributes with 'that' after the attribute list" do
         | 
| 212 | 
            +
                  user = User.new
         | 
| 213 | 
            +
                  User.stub(:new => user)
         | 
| 214 | 
            +
                  invoke_cucumber_step('there is a user with the name "Jane" that is deleted')
         | 
| 215 | 
            +
                  user.name.should == "Jane"
         | 
| 216 | 
            +
                  user.deleted.should == true
         | 
| 217 | 
            +
                end
         | 
| 238 218 |  | 
| 239 | 
            -
             | 
| 240 | 
            -
             | 
| 241 | 
            -
             | 
| 242 | 
            -
             | 
| 243 | 
            -
             | 
| 244 | 
            -
                 | 
| 245 | 
            -
              end
         | 
| 219 | 
            +
                it "should allow to set boolean attributes without regular attributes preceding them" do
         | 
| 220 | 
            +
                  user = User.new
         | 
| 221 | 
            +
                  User.stub(:new => user)
         | 
| 222 | 
            +
                  invoke_cucumber_step('there is a user who is deleted')
         | 
| 223 | 
            +
                  user.deleted.should == true
         | 
| 224 | 
            +
                end
         | 
| 246 225 |  | 
| 247 | 
            -
             | 
| 248 | 
            -
             | 
| 249 | 
            -
             | 
| 250 | 
            -
             | 
| 251 | 
            -
             | 
| 252 | 
            -
             | 
| 226 | 
            +
                it "should allow to set negative boolean attribute" do
         | 
| 227 | 
            +
                  user = User.new
         | 
| 228 | 
            +
                  User.stub(:new => user)
         | 
| 229 | 
            +
                  invoke_cucumber_step('there is a user who is not deleted')
         | 
| 230 | 
            +
                  user.deleted.should == false
         | 
| 231 | 
            +
                end
         | 
| 253 232 |  | 
| 254 | 
            -
             | 
| 255 | 
            -
             | 
| 256 | 
            -
             | 
| 257 | 
            -
             | 
| 258 | 
            -
             | 
| 259 | 
            -
             | 
| 233 | 
            +
                it "should allow to set multiple boolean attributes" do
         | 
| 234 | 
            +
                  user = User.new
         | 
| 235 | 
            +
                  User.stub(:new => user)
         | 
| 236 | 
            +
                  invoke_cucumber_step('there is a user who is locked and not deleted and subscribed')
         | 
| 237 | 
            +
                  user.locked.should == true
         | 
| 238 | 
            +
                  user.deleted.should == false
         | 
| 239 | 
            +
                  user.subscribed.should == true
         | 
| 240 | 
            +
                end
         | 
| 260 241 |  | 
| 261 | 
            -
             | 
| 262 | 
            -
             | 
| 263 | 
            -
             | 
| 264 | 
            -
             | 
| 265 | 
            -
             | 
| 266 | 
            -
             | 
| 267 | 
            -
             | 
| 268 | 
            -
             | 
| 242 | 
            +
                it "should allow to set boolean attributes that are named from multiple words" do
         | 
| 243 | 
            +
                  user = User.new
         | 
| 244 | 
            +
                  User.stub(:new => user)
         | 
| 245 | 
            +
                  invoke_cucumber_step('there is a user who is locked and not scared and scared by spiders and deleted')
         | 
| 246 | 
            +
                  user.locked.should == true
         | 
| 247 | 
            +
                  user.scared.should == false
         | 
| 248 | 
            +
                  user.scared_by_spiders.should == true
         | 
| 249 | 
            +
                  user.deleted.should == true
         | 
| 250 | 
            +
                end
         | 
| 269 251 |  | 
| 270 | 
            -
             | 
| 271 | 
            -
             | 
| 272 | 
            -
             | 
| 273 | 
            -
             | 
| 274 | 
            -
             | 
| 275 | 
            -
             | 
| 276 | 
            -
             | 
| 277 | 
            -
             | 
| 278 | 
            -
             | 
| 252 | 
            +
                it "should allow to join boolean attribute lists with 'and's, commas and 'but's" do
         | 
| 253 | 
            +
                  user = User.new
         | 
| 254 | 
            +
                  User.stub(:new => user)
         | 
| 255 | 
            +
                  invoke_cucumber_step('there is a user who is locked, scared, but scared by spiders and deleted')
         | 
| 256 | 
            +
                  user.locked.should == true
         | 
| 257 | 
            +
                  user.scared.should == true
         | 
| 258 | 
            +
                  user.scared_by_spiders.should == true
         | 
| 259 | 
            +
                  user.deleted.should == true
         | 
| 260 | 
            +
                end
         | 
| 279 261 |  | 
| 280 | 
            -
             | 
| 281 | 
            -
             | 
| 282 | 
            -
             | 
| 283 | 
            -
             | 
| 284 | 
            -
             | 
| 285 | 
            -
             | 
| 286 | 
            -
             | 
| 287 | 
            -
                 | 
| 288 | 
            -
              end
         | 
| 262 | 
            +
                it "should allow to set a has_many association by refering to multiple named records in square brackets" do
         | 
| 263 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Sunshine"')
         | 
| 264 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Limitless"')
         | 
| 265 | 
            +
                  invoke_cucumber_step('there is a user with the reviewed movies ["Sunshine" and "Limitless"]')
         | 
| 266 | 
            +
                  user = User.last
         | 
| 267 | 
            +
                  reviewed_movie_titles = user.reviewed_movies.map(&:title)
         | 
| 268 | 
            +
                  reviewed_movie_titles.should =~ ['Sunshine', 'Limitless']
         | 
| 269 | 
            +
                end
         | 
| 289 270 |  | 
| 290 | 
            -
             | 
| 291 | 
            -
             | 
| 292 | 
            -
             | 
| 293 | 
            -
             | 
| 294 | 
            -
             | 
| 295 | 
            -
             | 
| 271 | 
            +
                it 'allow associations for transient attributes if they are named after the associated model' do
         | 
| 272 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Sunshine"')
         | 
| 273 | 
            +
                  invoke_cucumber_step('there is a user with the movie "Sunshine"')
         | 
| 274 | 
            +
                  user = User.last
         | 
| 275 | 
            +
                  user.reviewed_movies.count.should == 1
         | 
| 276 | 
            +
                  user.reviewed_movies.first.title.should == 'Sunshine'
         | 
| 277 | 
            +
                end
         | 
| 296 278 |  | 
| 297 | 
            -
             | 
| 298 | 
            -
             | 
| 299 | 
            -
             | 
| 300 | 
            -
                obj.attributes[:amount].should be_a(BigDecimal)
         | 
| 301 | 
            -
                obj.attributes[:amount].to_s.should == "1.23"
         | 
| 302 | 
            -
                obj.attributes[:total].should be_a(BigDecimal)
         | 
| 303 | 
            -
                obj.attributes[:total].to_s.should == "45.6"
         | 
| 304 | 
            -
              end
         | 
| 279 | 
            +
                it "should allow to set attributes via doc string" do
         | 
| 280 | 
            +
                  user = User.new
         | 
| 281 | 
            +
                  User.stub(:new => user)
         | 
| 305 282 |  | 
| 306 | 
            -
             | 
| 307 | 
            -
             | 
| 308 | 
            -
             | 
| 309 | 
            -
             | 
| 310 | 
            -
                obj.attributes[:list].should == ['bam', 'baz']
         | 
| 311 | 
            -
              end
         | 
| 283 | 
            +
                  invoke_cucumber_step('there is a user with these attributes:', <<-DOC_STRING)
         | 
| 284 | 
            +
            name: Jane
         | 
| 285 | 
            +
            locked: true
         | 
| 286 | 
            +
                  DOC_STRING
         | 
| 312 287 |  | 
| 313 | 
            -
             | 
| 314 | 
            -
             | 
| 315 | 
            -
                 | 
| 316 | 
            -
                obj.attributes[:integers].should == [1, 2]
         | 
| 317 | 
            -
                obj.attributes[:decimals].should == [BigDecimal('3.4'), BigDecimal('4.5')]
         | 
| 318 | 
            -
              end
         | 
| 288 | 
            +
                  user.name.should == "Jane"
         | 
| 289 | 
            +
                  user.locked.should == true
         | 
| 290 | 
            +
                end
         | 
| 319 291 |  | 
| 320 | 
            -
             | 
| 321 | 
            -
             | 
| 322 | 
            -
             | 
| 323 | 
            -
                obj.attributes[:tags].should == []
         | 
| 324 | 
            -
              end
         | 
| 292 | 
            +
                it "should allow to set attributes via additional doc string" do
         | 
| 293 | 
            +
                  user = User.new
         | 
| 294 | 
            +
                  User.stub(:new => user)
         | 
| 325 295 |  | 
| 326 | 
            -
             | 
| 327 | 
            -
             | 
| 328 | 
            -
             | 
| 329 | 
            -
                obj.attributes[:tags].should == ['foo', 'bar', 'baz']
         | 
| 330 | 
            -
                obj.attributes[:list].should == ['bam', 'baz', 'qux']
         | 
| 331 | 
            -
              end
         | 
| 296 | 
            +
                  invoke_cucumber_step('there is a user with the email "test@invalid.com" and these attributes:', <<-DOC_STRING)
         | 
| 297 | 
            +
            name: Jane
         | 
| 298 | 
            +
                  DOC_STRING
         | 
| 332 299 |  | 
| 333 | 
            -
             | 
| 334 | 
            -
             | 
| 335 | 
            -
                 | 
| 336 | 
            -
                obj.attributes[:tags].should == ['foo', 'bar', 'baz']
         | 
| 337 | 
            -
                obj.attributes[:list].should == ['bam', 'baz', 'qux']
         | 
| 338 | 
            -
              end
         | 
| 300 | 
            +
                  user.name.should == "Jane"
         | 
| 301 | 
            +
                  user.email.should == "test@invalid.com"
         | 
| 302 | 
            +
                end
         | 
| 339 303 |  | 
| 340 | 
            -
             | 
| 341 | 
            -
             | 
| 342 | 
            -
             | 
| 343 | 
            -
             | 
| 344 | 
            -
             | 
| 345 | 
            -
             | 
| 346 | 
            -
             | 
| 347 | 
            -
             | 
| 304 | 
            +
                it 'should allow named records when setting attributes via doc string' do
         | 
| 305 | 
            +
                  invoke_cucumber_step('"Some Prequel" is a movie with these attributes:', <<-DOC_STRING)
         | 
| 306 | 
            +
            title: Before Sunrise
         | 
| 307 | 
            +
                  DOC_STRING
         | 
| 308 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Limitless"')
         | 
| 309 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunset" and the prequel "Some Prequel"')
         | 
| 310 | 
            +
                  movie = Movie.find_by_title!('Before Sunset')
         | 
| 311 | 
            +
                  prequel = Movie.find_by_title!('Before Sunrise')
         | 
| 312 | 
            +
                  movie.prequel.should == prequel
         | 
| 313 | 
            +
                end
         | 
| 348 314 |  | 
| 349 | 
            -
             | 
| 350 | 
            -
             | 
| 351 | 
            -
             | 
| 352 | 
            -
              end
         | 
| 315 | 
            +
                it "should allow to set attributes via data table" do
         | 
| 316 | 
            +
                  user = User.new
         | 
| 317 | 
            +
                  User.stub(:new => user)
         | 
| 353 318 |  | 
| 354 | 
            -
             | 
| 355 | 
            -
             | 
| 356 | 
            -
             | 
| 357 | 
            -
             | 
| 319 | 
            +
                  invoke_cucumber_step('there is a user with these attributes:', nil, <<-DATA_TABLE)
         | 
| 320 | 
            +
            | name   | Jane |
         | 
| 321 | 
            +
            | locked | true |
         | 
| 322 | 
            +
                  DATA_TABLE
         | 
| 358 323 |  | 
| 359 | 
            -
             | 
| 360 | 
            -
             | 
| 361 | 
            -
                 | 
| 362 | 
            -
              end
         | 
| 324 | 
            +
                  user.name.should == "Jane"
         | 
| 325 | 
            +
                  user.locked.should == true
         | 
| 326 | 
            +
                end
         | 
| 363 327 |  | 
| 364 | 
            -
             | 
| 365 | 
            -
             | 
| 366 | 
            -
             | 
| 367 | 
            -
              end
         | 
| 328 | 
            +
                it "should allow to set attributes via additional data table" do
         | 
| 329 | 
            +
                  user = User.new
         | 
| 330 | 
            +
                  User.stub(:new => user)
         | 
| 368 331 |  | 
| 369 | 
            -
             | 
| 370 | 
            -
             | 
| 371 | 
            -
             | 
| 332 | 
            +
                  invoke_cucumber_step('there is a user with the email "test@invalid.com" and these attributes:', nil, <<-DATA_TABLE)
         | 
| 333 | 
            +
            | name | Jane |
         | 
| 334 | 
            +
                  DATA_TABLE
         | 
| 372 335 |  | 
| 373 | 
            -
             | 
| 374 | 
            -
             | 
| 375 | 
            -
             | 
| 376 | 
            -
                DOC_STRING
         | 
| 336 | 
            +
                  user.name.should == "Jane"
         | 
| 337 | 
            +
                  user.email.should == "test@invalid.com"
         | 
| 338 | 
            +
                end
         | 
| 377 339 |  | 
| 378 | 
            -
                 | 
| 379 | 
            -
             | 
| 340 | 
            +
                it 'should allow named records when setting attributes via data table' do
         | 
| 341 | 
            +
                  invoke_cucumber_step('"Some Prequel" is a movie with these attributes:', nil, <<-DATA_TABLE)
         | 
| 342 | 
            +
            | title | Before Sunrise |
         | 
| 343 | 
            +
                  DATA_TABLE
         | 
| 344 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Limitless"')
         | 
| 345 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Before Sunset" and the prequel "Some Prequel"')
         | 
| 346 | 
            +
                  movie = Movie.find_by_title!('Before Sunset')
         | 
| 347 | 
            +
                  prequel = Movie.find_by_title!('Before Sunrise')
         | 
| 348 | 
            +
                  movie.prequel.should == prequel
         | 
| 349 | 
            +
                end
         | 
| 350 | 
            +
             | 
| 351 | 
            +
                it "should allow mixed single quotes for model names" do
         | 
| 352 | 
            +
                  invoke_cucumber_step("'Some Prequel' is a movie with the title \"Before Sunrise\"")
         | 
| 353 | 
            +
                  invoke_cucumber_step('there is a movie with the title "Limitless"')
         | 
| 354 | 
            +
                  invoke_cucumber_step('there is a movie with the title \'Before Sunset\' and the prequel "Some Prequel"')
         | 
| 355 | 
            +
                  movie = Movie.find_by_title!('Before Sunset')
         | 
| 356 | 
            +
                  prequel = Movie.find_by_title!('Before Sunrise')
         | 
| 357 | 
            +
                  movie.prequel.should == prequel
         | 
| 358 | 
            +
                end
         | 
| 380 359 | 
             
              end
         | 
| 381 360 |  | 
| 382 | 
            -
               | 
| 383 | 
            -
                 | 
| 384 | 
            -
             | 
| 361 | 
            +
              context 'without FactoryBot' do
         | 
| 362 | 
            +
                before do
         | 
| 363 | 
            +
                  hide_const("FactoryBot")
         | 
| 364 | 
            +
                end
         | 
| 385 365 |  | 
| 386 | 
            -
                 | 
| 387 | 
            -
             | 
| 388 | 
            -
             | 
| 366 | 
            +
                it "should instantiate plain ruby classes by calling #new" do
         | 
| 367 | 
            +
                  PlainRubyClass.should_receive(:new).with({})
         | 
| 368 | 
            +
                  invoke_cucumber_step("there is a plain ruby class")
         | 
| 369 | 
            +
                end
         | 
| 389 370 |  | 
| 390 | 
            -
                 | 
| 391 | 
            -
             | 
| 392 | 
            -
             | 
| 371 | 
            +
                it "should instantiate namespaced classes" do
         | 
| 372 | 
            +
                  actor = People::Actor.new
         | 
| 373 | 
            +
                  People::Actor.should_receive(:new).and_return(actor)
         | 
| 374 | 
            +
                  invoke_cucumber_step("there is a people/actor")
         | 
| 375 | 
            +
                end
         | 
| 393 376 |  | 
| 394 | 
            -
             | 
| 395 | 
            -
             | 
| 396 | 
            -
             | 
| 397 | 
            -
             | 
| 377 | 
            +
                it "should allow to set integer attributes without surrounding quotes" do
         | 
| 378 | 
            +
                  invoke_cucumber_step('there is a plain Ruby class with the amount 123 and the total 456')
         | 
| 379 | 
            +
                  obj = PlainRubyClass.last
         | 
| 380 | 
            +
                  obj.attributes[:amount].should == 123
         | 
| 381 | 
            +
                  obj.attributes[:total].should == 456
         | 
| 382 | 
            +
                end
         | 
| 398 383 |  | 
| 399 | 
            -
                 | 
| 400 | 
            -
             | 
| 401 | 
            -
             | 
| 384 | 
            +
                it "should allow to set decimal attributes without surrounding quotes" do
         | 
| 385 | 
            +
                  invoke_cucumber_step('there is a plain Ruby class with the amount 1.23 and the total 45.6')
         | 
| 386 | 
            +
                  obj = PlainRubyClass.last
         | 
| 387 | 
            +
                  obj.attributes[:amount].should be_a(BigDecimal)
         | 
| 388 | 
            +
                  obj.attributes[:amount].to_s.should == "1.23"
         | 
| 389 | 
            +
                  obj.attributes[:total].should be_a(BigDecimal)
         | 
| 390 | 
            +
                  obj.attributes[:total].to_s.should == "45.6"
         | 
| 391 | 
            +
                end
         | 
| 402 392 |  | 
| 403 | 
            -
             | 
| 404 | 
            -
             | 
| 405 | 
            -
             | 
| 406 | 
            -
             | 
| 407 | 
            -
             | 
| 408 | 
            -
                 | 
| 409 | 
            -
                movie = Movie.find_by_title!('Before Sunset')
         | 
| 410 | 
            -
                prequel = Movie.find_by_title!('Before Sunrise')
         | 
| 411 | 
            -
                movie.prequel.should == prequel
         | 
| 412 | 
            -
              end
         | 
| 393 | 
            +
                it "should allow set an array of strings with square brackets" do
         | 
| 394 | 
            +
                  invoke_cucumber_step('there is a plain Ruby class with the tags ["foo", "bar"] and the list ["bam", "baz"]')
         | 
| 395 | 
            +
                  obj = PlainRubyClass.last
         | 
| 396 | 
            +
                  obj.attributes[:tags].should == ['foo', 'bar']
         | 
| 397 | 
            +
                  obj.attributes[:list].should == ['bam', 'baz']
         | 
| 398 | 
            +
                end
         | 
| 413 399 |  | 
| 414 | 
            -
             | 
| 415 | 
            -
             | 
| 416 | 
            -
             | 
| 400 | 
            +
                it "should allow set an array of numbers with square brackets" do
         | 
| 401 | 
            +
                  invoke_cucumber_step('there is a plain Ruby class with the integers [1, 2] and the decimals [3.4, 4.5]')
         | 
| 402 | 
            +
                  obj = PlainRubyClass.last
         | 
| 403 | 
            +
                  obj.attributes[:integers].should == [1, 2]
         | 
| 404 | 
            +
                  obj.attributes[:decimals].should == [BigDecimal('3.4'), BigDecimal('4.5')]
         | 
| 405 | 
            +
                end
         | 
| 417 406 |  | 
| 418 | 
            -
                 | 
| 419 | 
            -
             | 
| 420 | 
            -
             | 
| 421 | 
            -
             | 
| 407 | 
            +
                it 'should allow to set an empty array' do
         | 
| 408 | 
            +
                  invoke_cucumber_step('there is a plain Ruby class with the tags []')
         | 
| 409 | 
            +
                  obj = PlainRubyClass.last
         | 
| 410 | 
            +
                  obj.attributes[:tags].should == []
         | 
| 411 | 
            +
                end
         | 
| 422 412 |  | 
| 423 | 
            -
                 | 
| 424 | 
            -
             | 
| 425 | 
            -
             | 
| 413 | 
            +
                it 'should allow to separate array values with either a comma or "and"' do
         | 
| 414 | 
            +
                  invoke_cucumber_step('there is a plain Ruby class with the tags ["foo", "bar" and "baz"] and the list ["bam", "baz" and "qux"]')
         | 
| 415 | 
            +
                  obj = PlainRubyClass.last
         | 
| 416 | 
            +
                  obj.attributes[:tags].should == ['foo', 'bar', 'baz']
         | 
| 417 | 
            +
                  obj.attributes[:list].should == ['bam', 'baz', 'qux']
         | 
| 418 | 
            +
                end
         | 
| 426 419 |  | 
| 427 | 
            -
             | 
| 428 | 
            -
             | 
| 429 | 
            -
             | 
| 420 | 
            +
                it 'should allow to separate array values with an Oxford comma' do
         | 
| 421 | 
            +
                  invoke_cucumber_step('there is a plain Ruby class with the tags ["foo", "bar", and "baz"] and the list ["bam", "baz", and "qux"]')
         | 
| 422 | 
            +
                  obj = PlainRubyClass.last
         | 
| 423 | 
            +
                  obj.attributes[:tags].should == ['foo', 'bar', 'baz']
         | 
| 424 | 
            +
                  obj.attributes[:list].should == ['bam', 'baz', 'qux']
         | 
| 425 | 
            +
                end
         | 
| 430 426 |  | 
| 431 | 
            -
                 | 
| 432 | 
            -
             | 
| 433 | 
            -
             | 
| 427 | 
            +
                it "should allow attribute names starting with 'the'" do
         | 
| 428 | 
            +
                  PlainRubyClass.should_receive(:new).with({:theme => 'Sci-fi'})
         | 
| 429 | 
            +
                  invoke_cucumber_step('there is a plain ruby class with the theme "Sci-fi"')
         | 
| 430 | 
            +
                end
         | 
| 434 431 |  | 
| 435 | 
            -
                 | 
| 436 | 
            -
             | 
| 437 | 
            -
             | 
| 432 | 
            +
                it "should allow attribute names starting with 'and'" do
         | 
| 433 | 
            +
                  PlainRubyClass.should_receive(:new).with({:android => 'Paranoid'})
         | 
| 434 | 
            +
                  invoke_cucumber_step('there is a plain ruby class with the android "Paranoid"')
         | 
| 435 | 
            +
                end
         | 
| 438 436 |  | 
| 439 | 
            -
             | 
| 440 | 
            -
             | 
| 437 | 
            +
                it "should allow attribute names starting with 'with'" do
         | 
| 438 | 
            +
                  PlainRubyClass.should_receive(:new).with({:withdrawal => 'bank_account'})
         | 
| 439 | 
            +
                  invoke_cucumber_step('there is a plain ruby class with the withdrawal "bank_account"')
         | 
| 440 | 
            +
                end
         | 
| 441 | 
            +
             | 
| 442 | 
            +
                it "should allow attribute names starting with 'but'" do
         | 
| 443 | 
            +
                  PlainRubyClass.should_receive(:new).with({:butt => 'pear-shaped'})
         | 
| 444 | 
            +
                  invoke_cucumber_step('there is a plain ruby class with the butt "pear-shaped"')
         | 
| 445 | 
            +
                end
         | 
| 446 | 
            +
             | 
| 447 | 
            +
                it "should allow to set array attributes via doc string" do
         | 
| 448 | 
            +
                  invoke_cucumber_step('there is a plain Ruby class with these attributes:', <<-DOC_STRING)
         | 
| 449 | 
            +
            tags: ["foo", "bar"]
         | 
| 450 | 
            +
                  DOC_STRING
         | 
| 451 | 
            +
             | 
| 452 | 
            +
                  obj = PlainRubyClass.last
         | 
| 453 | 
            +
                  obj.attributes[:tags].should == ['foo', 'bar']
         | 
| 454 | 
            +
                end
         | 
| 455 | 
            +
             | 
| 456 | 
            +
                it "should allow to set array attributes via data table" do
         | 
| 457 | 
            +
                  invoke_cucumber_step('there is a plain Ruby class with these attributes:', nil, <<-DATA_TABLE)
         | 
| 441 458 | 
             
            | tags | ["foo", "bar"] |
         | 
| 442 | 
            -
             | 
| 459 | 
            +
                  DATA_TABLE
         | 
| 443 460 |  | 
| 444 | 
            -
             | 
| 445 | 
            -
             | 
| 446 | 
            -
             | 
| 461 | 
            +
                  obj = PlainRubyClass.last
         | 
| 462 | 
            +
                  obj.attributes[:tags].should == ['foo', 'bar']
         | 
| 463 | 
            +
                end
         | 
| 447 464 |  | 
| 448 | 
            -
             | 
| 449 | 
            -
             | 
| 450 | 
            -
             | 
| 451 | 
            -
                 | 
| 452 | 
            -
                invoke_cucumber_step('there is a movie with the title "Limitless"')
         | 
| 453 | 
            -
                invoke_cucumber_step('there is a movie with the title "Before Sunset" and the prequel "Some Prequel"')
         | 
| 454 | 
            -
                movie = Movie.find_by_title!('Before Sunset')
         | 
| 455 | 
            -
                prequel = Movie.find_by_title!('Before Sunrise')
         | 
| 456 | 
            -
                movie.prequel.should == prequel
         | 
| 457 | 
            -
              end
         | 
| 465 | 
            +
                it "should create models that have a machinist blueprint by calling #make" do
         | 
| 466 | 
            +
                  MachinistModel.should_receive(:make).with({ :attribute => "foo"})
         | 
| 467 | 
            +
                  invoke_cucumber_step('there is a machinist model with the attribute "foo"')
         | 
| 468 | 
            +
                end
         | 
| 458 469 |  | 
| 459 | 
            -
             | 
| 460 | 
            -
             | 
| 461 | 
            -
             | 
| 462 | 
            -
             | 
| 470 | 
            +
                it "should be able to step_match machinist blueprint variants" do
         | 
| 471 | 
            +
                  MachinistModel.should_receive(:make).with(:variant, { :attribute => "foo"})
         | 
| 472 | 
            +
                  invoke_cucumber_step('there is a machinist model (variant) with the attribute "foo"')
         | 
| 473 | 
            +
                end
         | 
| 463 474 |  | 
| 464 | 
            -
             | 
| 465 | 
            -
             | 
| 466 | 
            -
             | 
| 467 | 
            -
             | 
| 475 | 
            +
                it "should be able to step_match machinist blueprint variants containing spaces or uppercase characters in prose" do
         | 
| 476 | 
            +
                  MachinistModel.should_receive(:make).with(:variant_mark_two, { :attribute => "foo"})
         | 
| 477 | 
            +
                  invoke_cucumber_step('there is a machinist model (Variant Mark Two) with the attribute "foo"')
         | 
| 478 | 
            +
                end
         | 
| 468 479 |  | 
| 469 | 
            -
             | 
| 470 | 
            -
             | 
| 471 | 
            -
             | 
| 472 | 
            -
                 | 
| 473 | 
            -
                movie = Movie.find_by_title!('Before Sunset')
         | 
| 474 | 
            -
                prequel = Movie.find_by_title!('Before Sunrise')
         | 
| 475 | 
            -
                movie.prequel.should == prequel
         | 
| 476 | 
            -
              end
         | 
| 480 | 
            +
                it "should allow single quote for attribute values" do
         | 
| 481 | 
            +
                  MachinistModel.should_receive(:make).with({ :attribute => "foo"})
         | 
| 482 | 
            +
                  invoke_cucumber_step("there is a machinist model with the attribute 'foo'")
         | 
| 483 | 
            +
                end
         | 
| 477 484 |  | 
| 478 | 
            -
             | 
| 479 | 
            -
             | 
| 480 | 
            -
             | 
| 481 | 
            -
             | 
| 485 | 
            +
                it "should allow mixed single and double quotes for different attribute values" do
         | 
| 486 | 
            +
                  MachinistModel.should_receive(:make).with({ :attribute => "foo", :other_attribute => "bar" })
         | 
| 487 | 
            +
                  invoke_cucumber_step("there is a machinist model with the attribute 'foo' and the other attribute \"bar\"")
         | 
| 488 | 
            +
                end
         | 
| 482 489 |  | 
| 483 | 
            -
             | 
| 484 | 
            -
             | 
| 485 | 
            -
             | 
| 486 | 
            -
                 | 
| 487 | 
            -
                lambda { invoke_cucumber_step("there is a machinist model with the attribute 'foo'. the other_attribute 'bar' and the third attribute 'baz'") }.should raise_error(ArgumentError, 'Unable to parse attributes ".".')
         | 
| 488 | 
            -
              end
         | 
| 490 | 
            +
                it 'should not raise an error for a blank instance name' do
         | 
| 491 | 
            +
                  MachinistModel.should_receive(:make).with({ :attribute => 'foo' })
         | 
| 492 | 
            +
                  invoke_cucumber_step("'' is a machinist model with the attribute 'foo'")
         | 
| 493 | 
            +
                end
         | 
| 489 494 |  | 
| 495 | 
            +
                it 'should warn if there are unused fragments' do
         | 
| 496 | 
            +
                  MachinistModel.should_not_receive(:make)
         | 
| 497 | 
            +
                  lambda { invoke_cucumber_step("there is a machinist model with the attribute NOQUOTES") }.should raise_error(ArgumentError, 'Unable to parse attributes " with the attribute NOQUOTES".')
         | 
| 498 | 
            +
                  lambda { invoke_cucumber_step("there is a machinist model with the attribute 'foo' and the ") }.should raise_error(ArgumentError, 'Unable to parse attributes " and the ".')
         | 
| 499 | 
            +
                  lambda { invoke_cucumber_step("there is a machinist model with the attribute 'foo'. the other_attribute 'bar' and the third attribute 'baz'") }.should raise_error(ArgumentError, 'Unable to parse attributes ".".')
         | 
| 500 | 
            +
                end
         | 
| 501 | 
            +
              end
         | 
| 490 502 | 
             
            end
         |