How to use feature_name method of Spinach Package

Best Spinach_ruby code snippet using Spinach.feature_name

spinach.rb

Source:spinach.rb Github

copy

Full Screen

...17 skipped_scenarios = {}18 Dir["#{Rails.root}/perforce_swarm/features/**/*.feature"].each do |engine_file|19 app_file = engine_file.gsub(%r{/perforce_swarm}, '')20 next unless File.exist?(app_file)21 feature_name = `grep 'Feature:' #{engine_file} |sed 's/Feature: *//g'`.strip22 local_skipped_scenarios = `grep -C 1 '@skip-parent' #{engine_file} |grep 'Scenario:'|sed 's/Scenario: *//g'`23 .split("\n")24 .each { |a| a.strip! if a.respond_to? :strip! }25 if local_skipped_scenarios.any?26 skipped_scenarios[feature_name] = local_skipped_scenarios27 end28 end29 # Modifying the Spinach 'Features' object so that it skips the list of scenarios specified by 'skipped_scenarios'30 Spinach.hooks.before_feature do |feature|31 if skipped_scenarios.key?(feature.name)32 feature.scenarios.select! do |scenario|33 !skipped_scenarios[feature.name].include?(scenario.name)34 end35 end36 end37 # Add overridden steps from the engine to the parent application's path38 Dir.glob(39 File.expand_path(File.join(Rails.root, 'perforce_swarm', 'features', 'steps', '**', '*.rb'))40 ).sort { |a, b| [b.count(File::SEPARATOR), a] <=> [a.count(File::SEPARATOR), b] }.each do |file|...

Full Screen

Full Screen

support_test.rb

Source:support_test.rb Github

copy

Full Screen

...23 end24 end25 describe '#underscore' do26 it 'changes dashes to underscores' do27 Spinach::Support.underscore('feature-name').must_equal 'feature_name'28 end29 it 'downcases the text' do30 Spinach::Support.underscore('FEATURE').must_equal 'feature'31 end32 it 'converts namespaces to paths' do33 Spinach::Support.underscore('Spinach::Support').must_equal 'spinach/support'34 end35 it 'prepends underscores to uppercase letters' do36 Spinach::Support.underscore('FeatureName').must_equal 'feature_name'37 end38 it 'only prepends underscores to the last uppercase letter' do39 Spinach::Support.underscore('SSLError').must_equal 'ssl_error'40 end41 it 'does not modify the original string' do42 text = 'FeatureName'43 underscored_text = Spinach::Support.underscore(text)44 text.wont_equal underscored_text45 end46 it 'accepts non string values' do47 Spinach::Support.underscore(:FeatureName).must_equal 'feature_name'48 end49 it 'changes spaces to underscores' do50 Spinach::Support.underscore('feature name').must_equal 'feature_name'51 end52 end53 describe "#escape" do54 it "escapes the name" do55 Spinach::Support.escape_single_commas(56 "I've been doing things I shouldn't be doing"57 ).must_include "I\\'ve been doing things I shouldn\\'t be doing"58 end59 end60 describe '#constantize' do61 it "converts a string into a class" do62 Spinach::Support.constantize("Spinach::FeatureSteps").must_equal Spinach::FeatureSteps63 end64 end...

Full Screen

Full Screen

spinach_test.rb

Source:spinach_test.rb Github

copy

Full Screen

1require_relative 'test_helper'2describe Spinach do3 before do4 @feature_steps1 = OpenStruct.new(feature_name: 'User authentication')5 @feature_steps2 = OpenStruct.new(feature_name: 'Slip management')6 @feature_steps3 = OpenStruct.new(feature_name: 'File attachments')7 @feature_steps4 = OpenStruct.new(name: 'UserSendsAMessage')8 @feature_steps5 = OpenStruct.new(name: 'Spinach::Features::ScopedFeature')9 [@feature_steps1, @feature_steps2,10 @feature_steps3, @feature_steps4, @feature_steps5].each do |feature|11 Spinach.feature_steps << feature12 end13 end14 describe '#features' do15 it 'returns all the loaded features' do16 Spinach.feature_steps.must_include @feature_steps117 Spinach.feature_steps.must_include @feature_steps218 Spinach.feature_steps.must_include @feature_steps319 end20 end21 describe '#reset_features' do22 it 'resets the features to a pristine state' do23 Spinach.reset_feature_steps24 [@feature_steps1, @feature_steps3, @feature_steps3].each do |feature|25 Spinach.feature_steps.wont_include feature26 end27 end28 end29 describe '#find_step_definitions' do30 it 'finds a feature by name' do31 Spinach.find_step_definitions('User authentication').must_equal @feature_steps132 Spinach.find_step_definitions('Slip management').must_equal @feature_steps233 Spinach.find_step_definitions('File attachments').must_equal @feature_steps334 end35 describe 'when a feature class does not set a feature_name' do36 it 'guesses the feature class from the feature name' do37 Spinach.find_step_definitions('User sends a message').must_equal @feature_steps438 end39 it 'finds scoped features' do40 Spinach.find_step_definitions('Scoped feature').must_equal @feature_steps541 end42 it 'returns nil when it cannot find the class' do43 Spinach.find_step_definitions('This feature does not exist').must_equal nil44 end45 end46 end47end...

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