How to use config_path method of Spinach Package

Best Spinach_ruby code snippet using Spinach.config_path

cli_test.rb

Source:cli_test.rb Github

copy

Full Screen

...33 end34 it 'sets default tags some are defined in config file' do35 in_current_dir do36 config = Spinach::Config.new37 config.config_path = "spinach.yml"38 File.open(config.config_path, "w") do |f|39 f.write <<-EOS40---41tags:42 - v143 - - ~external44 - js45 EOS46 end47 Spinach.stubs(:config).returns(config)48 cli = Spinach::Cli.new([])49 cli.options50 config[:tags].must_equal [['~wip'], 'v1', ['~external', 'js']]51 end52 end53 describe 'backtrace' do54 %w{-b --backtrace}.each do |opt|55 it 'sets the backtrace if #{opt}' do56 config = Spinach::Config.new57 Spinach.stubs(:config).returns(config)58 cli = Spinach::Cli.new([opt])59 cli.options60 config[:reporter_options][:backtrace].must_equal true61 end62 end63 end64 describe 'reporter class' do65 %w{-r --reporter}.each do |opt|66 it 'sets the reporter class' do67 config = Spinach::Config.new68 Spinach.stubs(:config).returns(config)69 cli = Spinach::Cli.new([opt, 'progress'])70 cli.options71 config.reporter_classes.must_equal ['Spinach::Reporter::Progress']72 end73 it 'sets multiple reporter classes' do74 config = Spinach::Config.new75 Spinach.stubs(:config).returns(config)76 cli = Spinach::Cli.new([opt, 'progress,stdout'])77 cli.options78 config.reporter_classes.must_equal ['Spinach::Reporter::Progress', 'Spinach::Reporter::Stdout']79 end80 end81 end82 describe 'rand' do83 let(:config) { Spinach::Config.new }84 before do85 Spinach.stubs(:config).returns(config)86 Spinach::Cli.new(%w(--rand)).options87 end88 it 'uses the Random orderer' do89 config.orderer_class.must_equal 'Spinach::Orderers::Random'90 end91 it 'sets a numeric seed' do92 config.seed.must_equal config.seed.to_i93 end94 end95 describe 'seed' do96 let(:config) { Spinach::Config.new }97 before do98 Spinach.stubs(:config).returns(config)99 Spinach::Cli.new(%w(--seed 42)).options100 end101 it 'uses the random orderer' do102 config.orderer_class.must_equal 'Spinach::Orderers::Random'103 end104 it 'sets the seed' do105 config.seed.must_equal 42106 end107 end108 describe 'features_path' do109 %w{-f --features_path}.each do |opt|110 it 'sets the given features_path' do111 config = Spinach::Config.new112 Spinach.stubs(:config).returns(config)113 cli = Spinach::Cli.new([opt,"custom_path"])114 cli.options115 config.features_path.must_equal 'custom_path'116 end117 end118 end119 describe 'tags' do120 %w{-t --tags}.each do |opt|121 it 'sets the given tag' do122 config = Spinach::Config.new123 Spinach.stubs(:config).returns(config)124 cli = Spinach::Cli.new([opt,'wip'])125 cli.options126 config.tags.must_equal [['wip']]127 end128 it 'sets OR-ed tags' do129 config = Spinach::Config.new130 Spinach.stubs(:config).returns(config)131 cli = Spinach::Cli.new([opt,'wip,javascript'])132 cli.options133 config.tags.must_equal [['wip', 'javascript']]134 end135 it 'adds ~wip by default' do136 config = Spinach::Config.new137 Spinach.stubs(:config).returns(config)138 cli = Spinach::Cli.new([opt,'javascript'])139 cli.options140 config.tags.must_equal [['~wip', 'javascript']]141 end142 it 'has precedence over tags specified in config file' do143 in_current_dir do144 config = Spinach::Config.new145 config.config_path = "spinach.yml"146 File.open(config.config_path, "w") do |f|147 f.write <<-EOS148---149tags:150 - v1151 EOS152 end153 Spinach.stubs(:config).returns(config)154 cli = Spinach::Cli.new([opt,'javascript'])155 cli.options156 config[:tags].must_equal [['~wip', 'javascript']]157 end158 end159 end160 it 'sets AND-ed tags' do161 config = Spinach::Config.new162 Spinach.stubs(:config).returns(config)163 cli = Spinach::Cli.new(['-t','javascript', '-t', 'wip'])164 cli.options165 config.tags.must_equal [['~wip', 'javascript'],['wip']]166 end167 end168 describe 'generate' do169 %w{-g --generate}.each do |generate_opt|170 it 'inits the generator if #{generate_opt}' do171 config = Spinach::Config.new172 Spinach.stubs(:config).returns(config)173 Spinach::Generators.expects(:run)174 Spinach::Cli.new([generate_opt]).run175 config.generate.must_equal true176 end177 %w{-f --features_path}.each do |feature_path_opt|178 it "honors the #{feature_path_opt} option" do179 config = Spinach::Config.new180 Spinach.stubs(:config).returns(config)181 cli = Spinach::Cli.new([feature_path_opt,"custom_path", generate_opt])182 cli.options183 config.features_path.must_equal 'custom_path'184 end185 end186 end187 end188 describe 'fail-fast' do189 it 'set the fail_fast flag, given "--fail-fast"' do190 config = Spinach::Config.new191 Spinach.stubs(:config).returns(config)192 Spinach::Cli.new(["--fail-fast"]).options193 config.fail_fast.must_equal true194 end195 end196 describe "version" do197 %w{-v --version}.each do |opt|198 it "outputs the version" do199 cli = Spinach::Cli.new([opt])200 cli.expects(:exit)201 cli.expects(:puts).with(Spinach::VERSION)202 capture_stdout do203 cli.options204 end205 end206 end207 end208 describe 'config_path' do209 %w{-c --config_path}.each do |opt|210 it "sets the config path" do211 config = Spinach::Config.new212 Spinach.stubs(:config).returns(config)213 cli = Spinach::Cli.new([opt, 'config_file'])214 config.expects(:parse_from_file)215 cli.options216 config.config_path.must_equal 'config_file'217 end218 it "gets overriden by the other cli options" do219 config = Spinach::Config.new220 Spinach.stubs(:config).returns(config)221 YAML.stubs(:load_file).returns({features_path: 'my_path'})222 cli = Spinach::Cli.new(['-f', 'another_path', opt, 'config_file'])223 cli.options224 config.features_path.must_equal 'another_path'225 end226 end227 end228 describe 'undefined option' do229 %w{-lorem --ipsum}.each do |opt|230 it 'exits and outputs error message with #{opt}' do...

Full Screen

Full Screen

config.rb

Source:config.rb Github

copy

Full Screen

...24 :step_definitions_path,25 :default_reporter,26 :support_path,27 :failure_exceptions,28 :config_path,29 :tags,30 :generate,31 :save_and_open_page_on_failure,32 :reporter_classes,33 :reporter_options,34 :orderer_class,35 :seed,36 :fail_fast,37 :audit38 # The "features path" holds the place where your features will be39 # searched for. Defaults to 'features'40 #41 # @return [String]42 # The features path.43 #44 # @api public45 def features_path46 @features_path || 'features'47 end48 # The "reporter classes" holds an array of reporter class name49 # Default to ["Spinach::Reporter::Stdout"]50 #51 # @return [Array<reporter object>]52 # The reporters that respond to specific messages.53 #54 # @api public55 def reporter_classes56 @reporter_classes || ["Spinach::Reporter::Stdout"]57 end58 # The "reporter_options" holds the options passed to reporter_classes59 #60 # @api public61 def reporter_options62 @reporter_options || {}63 end64 # The "orderer class" holds the orderer class name65 # Defaults to Spinach::Orderers::Default66 #67 # @return [orderer object]68 # The orderer that responds to specific messages.69 #70 # @api public71 def orderer_class72 @orderer_class || "Spinach::Orderers::Default"73 end74 # A randomization seed. This is what spinach uses for test run75 # randomization, so if you call `Kernel.srand(Spinach.config.seed)`76 # in your support environment file, not only will the test run77 # order be guaranteed to be stable under a specific seed, all78 # the Ruby-generated random numbers produced during your test79 # run will also be stable under that seed.80 #81 # @api public82 def seed83 @seed ||= rand(0xFFFF)84 end85 # The "step definitions path" holds the place where your feature step86 # classes will be searched for. Defaults to '#{features_path}/steps'87 #88 # @return [String]89 # The step definitions path.90 #91 # @api public92 def step_definitions_path93 @step_definitions_path || "#{self.features_path}/steps"94 end95 # The "support path" helds the place where you can put your configuration96 # files. Defaults to '#{features_path}/support'97 #98 # @return [String]99 # The support file path.100 #101 # @api public102 def support_path103 @support_path || "#{self.features_path}/support"104 end105 def generate106 @generate || false107 end108 # Allows you to read the config object using a hash-like syntax.109 #110 # @param [String] attribute111 # The attribute to fetch.112 #113 # @example114 # Spinach.config[:step_definitions_path]115 # # => 'features/steps'116 #117 # @api public118 def [](attribute)119 self.send(attribute)120 end121 # Allows you to set config properties using a hash-like syntax.122 #123 # @param [#to_s] attribute124 # The attribute to set.125 #126 # @param [Object] value127 # The value to set the attribute to.128 #129 # @example130 # Spinach.config[:step_definitions_path] = 'integration/steps'131 # # => 'integration/steps'132 #133 # @api public134 def []=(attribute, value)135 self.send("#{attribute}=", value)136 end137 # The failure exceptions return an array of exceptions to be captured and138 # considered as failures (as opposite of errors)139 #140 # @return [Array<Exception>]141 #142 # @api public143 def failure_exceptions144 @failure_exceptions ||= []145 end146 # The "fail_fast" determines if the suite run should exit147 # when encountering a failure/error148 #149 # @return [true/false]150 # The fail_fast flag.151 #152 # @api public153 def fail_fast154 @fail_fast155 end156 # "audit" enables step auditing mode157 #158 # @return [true/false]159 # The audit flag.160 #161 # @api public162 def audit163 @audit || false164 end165 # It allows you to set a config file to parse for all the other options to be set166 #167 # @return [String]168 # The config file name169 #170 def config_path171 @config_path ||= 'config/spinach.yml'172 end173 # When using capybara, it automatically shows the current page when there's174 # a failure175 #176 def save_and_open_page_on_failure177 @save_and_open_page_on_failure ||= false178 end179 # Tags to tell Spinach that you only want to run scenarios that have (or180 # don't have) certain tags.181 #182 # @return [Array]183 # The tags.184 #185 def tags186 @tags ||= []187 end188 # Parse options from the config file189 #190 # @return [Boolean]191 # If the config was parsed from the file192 #193 def parse_from_file194 parsed_opts = YAML.load_file(config_path)195 parsed_opts.delete_if{|k| k.to_s == 'config_path'}196 parsed_opts.each_pair{|k,v| self[k] = v}197 true198 rescue Errno::ENOENT199 false200 end201 end202end...

Full Screen

Full Screen

config_test.rb

Source:config_test.rb Github

copy

Full Screen

...69 subject[:failure_exceptions] << RuntimeError70 subject[:failure_exceptions].must_include RuntimeError71 end72 end73 describe '#config_path' do74 it 'returns a default' do75 subject[:config_path].must_equal 'config/spinach.yml'76 end77 it 'can be overwritten' do78 subject[:config_path] = 'my_config_file.yml'79 subject[:config_path].must_equal 'my_config_file.yml'80 end81 end82 describe '#parse_from_file' do83 before do84 subject[:config_path] = 'a_path'85 YAML.stubs(:load_file).returns({support_path: 'my_path', config_path: 'another_path'})86 subject.parse_from_file87 end88 it 'sets the options' do89 subject[:support_path].must_equal 'my_path'90 end91 it "doesn't set the config_path option" do92 subject[:config_path].must_equal 'a_path'93 end94 end95 describe '#tags' do96 it 'returns a default' do97 subject[:tags].must_be_kind_of Array98 end99 it 'can be overwritten' do100 subject[:tags] = ['wip']101 subject[:tags].must_equal ['wip']102 end103 end104end...

Full Screen

Full Screen

config_path

Using AI Code Generation

copy

Full Screen

1Spinach.config_path = File.expand_path("config.yml")2Spinach.config_path = File.expand_path("config.yml")3Spinach.config_path = File.expand_path("config.yml")4Spinach.config_path = File.expand_path("config.yml")5Spinach.config_path = File.expand_path("config.yml")6Spinach.config_path = File.expand_path("config.yml")7Spinach.config_path = File.expand_path("config.yml")8Spinach.config_path = File.expand_path("config.yml")9Spinach.config_path = File.expand_path("config.yml")10Spinach.config_path = File.expand_path("config.yml")11Spinach.config_path = File.expand_path("config.yml")12Spinach.config_path = File.expand_path("config.yml")13Spinach.config_path = File.expand_path("config.yml")14Spinach.config_path = File.expand_path("config.yml")15Spinach.config_path = File.expand_path("config.yml")16Spinach.config_path = File.expand_path("config.yml")

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Spinach_ruby automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful