Skip to content

Commit

Permalink
DRY up the cucumber step definitions
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Bounds and Tim Jarratt authored and idoru committed Dec 11, 2013
1 parent 4bceb0d commit ded39bc
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 85 deletions.
44 changes: 0 additions & 44 deletions features/scenario_steps/ios_templates_steps.rb

This file was deleted.

41 changes: 0 additions & 41 deletions features/scenario_steps/osx_templates_steps.rb

This file was deleted.

7 changes: 7 additions & 0 deletions features/step_definitions/modify_target_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
When(/^I add a failing test$/) do
`cp features/support/templates/FailingSpec.mm template-project/Specs/ExampleSpec.mm`
end

When(/^I reference AppDelegate in the test$/) do
`cp features/support/templates/ExampleSpec.mm template-project/Specs`
end
17 changes: 17 additions & 0 deletions features/step_definitions/rake_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Then(/^the `rake Specs` should work$/) do
Dir.chdir('template-project/Specs') do
output = `rake Specs 2> /dev/null`
if $? != 0
puts "!!! Spec target failed. Build output:"
puts output
end
$?.exitstatus.should eq(0)
end
end

Then(/^running the specs from the rake task should fail$/) do
Dir.chdir('template-project/Specs') do
`rake Specs 2> /dev/null`
$?.exitstatus.should_not eq(0)
end
end
12 changes: 12 additions & 0 deletions features/step_definitions/xcode_steps.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
When(/^I add an (iOS|OS X) Spec (suite|bundle) target$/) do |os, target_type|
`open -a Xcode template-project/template-project.xcodeproj`
`osascript features/support/scripts/#{os.downcase.gsub(/\s+/, '')}_add_spec_#{target_type.downcase.gsub(/\s+/, '')}.scpt`
File.exist?("template-project/Specs").should be_true
end

Given(/^an Xcode (iOS|OS X) project$/) do |os|
`rm -rf template-project`
`cp -pr features/support/#{os.downcase.gsub(/\s+/, '')}-project-template template-project`
$?.exitstatus.should == 0
File.exist?("template-project").should be_true
end

0 comments on commit ded39bc

Please sign in to comment.