Sha256: a7203b349ff0a52909479c22ea51e5bf3e362dd36ea3300e922f5c09aedda24a

Contents?: true

Size: 1.22 KB

Versions: 7

Compression:

Stored size: 1.22 KB

Contents

require 'tailor/file_line'

def contains_camel_case? keyword
  @ruby_source = File.open(@file_list[0], 'r')

  contains_camel_case = false
  @ruby_source.each_line do |source_line|
    line = FileLine.new source_line

    if keyword.eql? "method"
      line.snake_case_method? ? (return false) : (return false)
    elsif keyword.eql? "class"
      line.camel_case_class? ? (return true) : (return false)
    end
  end
end

Given /^the file contains a "([^\"]*)" that has a camel\-cased name$/ do
  |keyword|
  contains_camel_case?(keyword).should be_true
end

Given /^the file contains a "([^\"]*)" that has a snake\-cased name$/ do
  |keyword|
  contains_camel_case?(keyword).should be_false
end

Then /^the checker should tell me I have a camel\-cased method name$/ do
  @result.should include("Method name uses camel case")
end

Then /^the checker shouldn't tell me the method name is camel\-case$/ do
  @result.should_not include("Method name uses camel case")
end

Then /^the checker shouldn't tell me the class name is camel\-case$/ do
  @result.should_not include("Class name uses camel case")
end

Then /^the checker should tell me the class name is not camel\-case$/ do
  @result.should include("Class name does NOT use camel case")
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tailor-0.1.5 features/step_definitions/case_checking_steps.rb
tailor-0.1.4 features/step_definitions/case_checking_steps.rb
tailor-0.1.3 features/step_definitions/case_checking_steps.rb
tailor-0.1.2 features/step_definitions/case_checking_steps.rb
tailor-0.1.1 features/step_definitions/case_checking_steps.rb
tailor-0.1.0 features/step_definitions/case_checking_steps.rb
tailor-0.0.3 features/step_definitions/case_checking_steps.rb