Sha256: 342ab581f99f689c17eebdf55f3b4367b4e094e9225e5674efb4758a553aed8d

Contents?: true

Size: 892 Bytes

Versions: 13

Compression:

Stored size: 892 Bytes

Contents

module VacancyFactoryMethods
  def set_vacancy_defaults(attributes)
    attributes[:user_id] ||= @me.id unless attributes[:user_id] || !@me
    attributes[:project_id] ||= Project.last.id unless attributes[:project_id] || Project.all.none?
  end
  
  def new_vacancy(name, state = nil)
    attributes = { name: name }
    attributes[:state] = state if state
    
    set_vacancy_defaults(attributes)
    
    @vacancy = Factory(:vacancy, attributes)
    @vacancy.reload
  end
end

World(VacancyFactoryMethods)

Given /^a vacancy named "([^\"]*)"$/ do |name|
  new_vacancy(name)
end

Given /^a vacancy named "([^\"]*)" with state "([^\"]*)"$/ do |name, state|
  new_vacancy(name, state)
end

Then /^I should see the following vacancies:$/ do |expected_table|
  rows = find('table').all('tr')
  table = rows.map { |r| r.all('th,td').map { |c| c.text.strip } }
  expected_table.diff!(table)
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
voluntary-0.3.0 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.2.4 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.2.3 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.2.2 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.2.1 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.2.0 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.1.0 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.1.0.rc4 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.1.0.rc3 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.1.0.rc2 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.1.0.rc1 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.0.3 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb
voluntary-0.0.2 lib/generators/voluntary/product_dummy/templates/features/step_definitions/vacancy_steps.rb