Skip to content

Instantly share code, notes, and snippets.

@xrd
Last active December 28, 2015 02:08
Show Gist options
  • Select an option

  • Save xrd/7425175 to your computer and use it in GitHub Desktop.

Select an option

Save xrd/7425175 to your computer and use it in GitHub Desktop.
Features file
After do
cleanup()
end
Feature: Add file to repository
Scenario: As a logged in user I can add a file
Given I start the login process
Then I should not see "Logout from GitHub"
And I don't see a logout button
And I acknowledge the 2 factor bug
And I wait for the GitHub oAuth login page
And I login using GitHub oAuth login
And I grab the oauth token for cleanup
Then I wait for the "Loading all repositories.." dialog to close
And I access the "mynewblog" repository
Then I wait for the "Loading repository data.." dialog to close
Then I wait for the "Loading hyde transformations.." dialog to close
And I wait for the repository layout
Then I wait for 10 seconds
And I select "New Post"
And I enter "My new file" as the filename
And I press "Ok"
And I wait for the editor
Then I should see "Markdown"
Then I select "Save File"
Then I wait for 3 seconds
Then I go back
Then I go back
Then I go back
Then I go back
Then I wait for 20 seconds
And I access the "mynewblog" repository
Then I wait for the "Loading repository data.." dialog to close
Then I wait for the "Loading hyde transformations.." dialog to close
And I wait for the repository layout
Then I wait for 10 seconds
Then I press "_posts"
And I scroll until I see the "My new file" as a jekyll post
Then I click on the list item named "My new file"
Then I should see "Markdown"
# require 'byebug'
require 'date'
FORMAT = "%Y-%m-%d"
filename = "My first file"
@auth_token = nil
def convert_name( text )
rv = "#{DateTime.now().strftime( FORMAT )}-#{text.downcase.gsub(/\s+/, '-' )}.md"
rv
end
Given /I start the login process/ do
touch "button text:'Login'"
end
And /I acknowledge the 2 factor bug/ do
tv = query( "textview", "text" )
if tv[0] =~ /2\-factor authentication/
touch "button text:'Ok'"
end
end
And /I scroll to the top/ do
performAction('scroll_up')
end
And /I select "New Post"/ do
touch "ActionMenuItemView id:'action_add_new_post'"
end
And /I select "Save File"/ do
touch "ActionMenuItemView text:'Save File'"
end
Then /I click on the list item named "([^\"]*)"/ do |text|
jekyll_name = convert_name( text )
touch("TextView text:'#{jekyll_name}'")
end
And /I grab the oauth token for cleanup/ do
preferences = get_preferences("com.EditorHyde.app")
@auth_token = preferences['authToken']
end
def cleanup
file = convert_name( "My new file" )
# curl -u "your_login:your_token" \
# https://api.github.com/repos/user/repo
cmd = "curl -i -X DELETE -u 'BurningOnUp:#{@auth_token}' https://api.github.com/repos/BurningOnUp/mynewrepo/contents/_posts/#{file}"
puts "Cmd: #{cmd}"
`#{cmd}`
# /applications/:client_id/tokens
cmd = "curl -i -X DELETE -u 'BurningOnUp:#{@auth_token}' https://api.github.com/applications/e4f185a088112cb1b0e9/tokens"
# puts "Delete the token for the app"
`#{cmd}`
end
Then /^I scroll until I see the "([^\"]*)" as a jekyll post/ do |text|
jekyll_name = convert_name( text )
wait_for( timeout: 60 ) { query("TextView text:'#{jekyll_name}'") }
end
And /I don't see a logout button/ do
query( "button text:'Logout from GitHub'" )
end
And /I wait for the repository layout/ do
wait_for( timeout: 60 ) { query( "textview id:'repo_name'" ) }
end
And /I wait for the editor/ do
wait_for( timeout: 60 ) { query( "editext id:'markdownEditor'" ) }
end
Then /^I should see the text containing "(.*?)"$/ do |arg1|
et = query( "edittext" )
puts et.inspect
unless et[0]['text'] =~ /markdown/i
fail( "Could not find markdown text" )
end
end
Then /I wait for the "([^\"]*)" dialog to close/ do |text|
# See if the dialog exists right now...
unless query( "textview text:'#{text}'" ).length == 0
# If it does, then wait for it to close...
wait_for( timeout: 60 ) { 0 == query( "textview text:'#{text}'" ).length }
end
end
And /I wait for the GitHub oAuth login page/ do
wait_for( timeout: 30 ) { query( "webview" ) }
wait_for( timeout: 30 ) { query( "webview css:'*'" ).length != 3 }
end
And /I enter "([^\"]*)" as the filename/ do |name|
query "edittext", :setText => name
end
And /I login using GitHub oAuth login/ do
set_text "webView css:input[name=login]", "burning@burningon.com"
set_text "webView css:input[name=password]", "smallbaby1"
touch "webView input:'button[type=submit]'"
sleep 10
text = query( "webView css:'.bubble-content'", "textContent" )[0]
if text =~ /Teddy Hyde Android wants/
performAction "scroll_to", "css", "a.oauth-deny"
touch "webView css:'button[name=authorize]'"
end
end
And /I access the "([^\"]*)" repository/ do |text|
touch( "listview textview text:'#{text}'" )
end
sleep 5
adb -s 0222fdc60910aede shell screenrecord /sdcard/calabash.mp4 &
ADB_DEVICE_ARG=0222fdc60910aede calabash-android run ../build/apk/TeddyHyde-debug-unaligned.apk
# osascript record.script &
@saikrishna321
Copy link
Copy Markdown

hey , running the sh file it starts recording but it doesn't not stop after my calabash test end. can you please help me on this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment