Feature: The changeref command As a Responsible of definitions for a giventdocument In order to make references reliable I want defmastership to change reference for asciidoctor documents Scenario: Change a definition Given a file named "changeref.yaml" with: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 """ And a file named "thedoc.adoc" with: """ [define, requirement, TOTO-TEMP-XXX1] """ When I run `defmastership changeref thedoc.adoc` Then the stdout should not contain anything And the stderr should not contain anything And the file "changeref.yaml" should contain: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 124 """ And the file "thedoc.adoc" should contain: """ [define, requirement, TOTO-0123] """ Scenario: Change a definition with yaml file parameter Given a file named "pouet.yaml" with: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 """ And a file named "thedoc.adoc" with: """ [define, requirement, TOTO-TEMP-XXX1] """ When I run `defmastership changeref --change-file=pouet.yaml thedoc.adoc` Then the stdout should not contain anything And the stderr should not contain anything And the file "pouet.yaml" should contain: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 124 """ And the file "thedoc.adoc" should contain: """ [define, requirement, TOTO-0123] """ Scenario: Change two definitions Given a file named "changeref.yaml" with: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 """ And a file named "thedoc.adoc" with: """ [define, requirement, TOTO-TEMP-XXX1] [define, requirement, TOTO-TEMP-XXX2] """ When I run `defmastership changeref thedoc.adoc` Then the stdout should not contain anything And the stderr should not contain anything And the file "changeref.yaml" should contain: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 125 """ And the file "thedoc.adoc" should contain: """ [define, requirement, TOTO-0123] [define, requirement, TOTO-0124] """ Scenario: Generate a table with changess Given a file named "changeref.yaml" with: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 """ And a file named "thedoc.adoc" with: """ [define, requirement, TOTO-TEMP-XXX1] [define, requirement, TOTO-TEMP-XXX2] """ When I run `defmastership changeref --change-summary=changes.csv thedoc.adoc` Then the stderr should not contain anything And the stdout should not contain anything And the file "changes.csv" should contain: """ Was,Becomes TOTO-TEMP-XXX1,TOTO-0123 TOTO-TEMP-XXX2,TOTO-0124 """ Scenario: Change two definitions with two schema Given a file named "changeref.yaml" with: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 :tata_or_titi: :from_regexp: "(?TATA|TITI)-TEMP-[X\\d]{4}" :to_template: "%s-%07d" :next_ref: 432 """ And a file named "thedoc.adoc" with: """ [define, requirement, TOTO-TEMP-XXX1] [define, requirement, TITI-TEMP-XXX2] """ When I run `defmastership changeref thedoc.adoc` Then the stdout should not contain anything And the stderr should not contain anything And the file "changeref.yaml" should contain: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 124 :tata_or_titi: :from_regexp: "(?TATA|TITI)-TEMP-[X\\d]{4}" :to_template: "%s-%07d" :next_ref: 433 """ And the file "thedoc.adoc" should contain: """ [define, requirement, TOTO-0123] [define, requirement, TITI-0000432] """ Scenario: Change definitions in two files Given a file named "changeref.yaml" with: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 """ And a file named "thedoc.adoc" with: """ [define, requirement, TOTO-TEMP-XXX1] """ And a file named "thedoc2.adoc" with: """ [define, requirement, TOTO-TEMP-XXX2] """ When I run `defmastership changeref thedoc.adoc thedoc2.adoc` Then the stdout should not contain anything And the stderr should not contain anything And the file "changeref.yaml" should contain: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 125 """ And the file "thedoc.adoc" should contain: """ [define, requirement, TOTO-0123] """ And the file "thedoc2.adoc" should contain: """ [define, requirement, TOTO-0124] """ Scenario: Change a internal refs Given a file named "changeref.yaml" with: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 """ And a file named "thedoc.adoc" with: """ [define, requirement, TOTO-TEMP-XXX1] is the same as defs:iref[TOTO-TEMP-XXX2] and defs:iref[TOTO-TEMP-XXX1] [define, requirement, TOTO-TEMP-XXX2] is the same as defs:iref[TOTO-TEMP-XXX1] """ When I run `defmastership changeref thedoc.adoc` Then the stdout should not contain anything And the stderr should not contain anything And the file "thedoc.adoc" should contain: """ [define, requirement, TOTO-0123] is the same as defs:iref[TOTO-0124] and defs:iref[TOTO-0123] [define, requirement, TOTO-0124] is the same as defs:iref[TOTO-0123] """ Scenario: Change definitions and iref in two files Given a file named "changeref.yaml" with: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 """ And a file named "thedoc.adoc" with: """ [define, requirement, TOTO-TEMP-XXX1] defs:iref[TOTO-TEMP-XXX2] """ And a file named "thedoc2.adoc" with: """ [define, requirement, TOTO-TEMP-XXX2] defs:iref[TOTO-TEMP-XXX1] """ When I run `defmastership changeref thedoc.adoc thedoc2.adoc` Then the stdout should not contain anything And the stderr should not contain anything And the file "changeref.yaml" should contain: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 125 """ And the file "thedoc.adoc" should contain: """ [define, requirement, TOTO-0123] defs:iref[TOTO-0124] """ And the file "thedoc2.adoc" should contain: """ [define, requirement, TOTO-0124] defs:iref[TOTO-0123] """ Scenario: Do not change definitions when in literal Given a file named "changeref.yaml" with: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 """ And a file named "thedoc.adoc" with: """ .... [define, requirement, TOTO-TEMP-XXX1] .... """ When I run `defmastership changeref thedoc.adoc` Then the stdout should not contain anything And the stderr should not contain anything And the file "changeref.yaml" should contain: """ --- :toto: :from_regexp: TOTO-TEMP-[X\d]{4} :to_template: TOTO-%04d :next_ref: 123 """ And the file "thedoc.adoc" should contain: """ .... [define, requirement, TOTO-TEMP-XXX1] .... """