Ruby, Appium, Android, Rspec, Pry, Automation Testing

Total Page:16

File Type:pdf, Size:1020Kb

Ruby, Appium, Android, Rspec, Pry, Automation Testing GKTCS Innovations Pvt. Ltd. Ruby, Appium, Android, Rspec, Pry, Automation Testing Surendra Panpaliya Director, GKTCS Innovations Pvt. Ltd, Pune. 16 + Years of Experience ( MCA, PGDCS, BSc. [Electronics] , CCNA) Director , GKTCS Innovations Pvt. Ltd. Pune [ Nov 2009 – Till date ] IT Manager and Consultant at Rolta India Ltd, Mumbai [ April 2007 – Oct 2009 ] Associate Professor at Sinhgad Institute , Pune [Jan 2002 – April 2007] Instructor , ITM Bangalore [ May 2000 – Jan 2002 ] Project Trainee, DSYS Software Group, Bangalore [ Jan 1999 to April 2000] Skills ❑ Ruby, Rail,Appium, Python, Jython, Django, Android , PHP, LAMP ❑ Data Communication & Networking, CCNA ❑ UNIX /Linux Shell Scripting, System Programming ❑ CA Siteminder, Autosys, SSO, Service Desk, Service Delivery Author of 4 Books National Paper Presentation Awards at BARC Mumbai 2 Agenda ( Day 1) • Introduction • Ruby installation • What’s New in Ruby • Ruby Data Types/ Data Structure • Ruby Comparison with Other Language ( Java/C+ + ) • Ruby Demo Script • Appium Introduction • Appium Installation Setup • Discussion 3 Agenda ( Day 2) • Android adb commands • About Android AVD • About Appium Architecture • Appium Features • Using Appium to test Android Emulator/ Physical Device • Writing Ruby Scripts to Automate app through Appium • Discussion 4 Agenda ( Day 3) • Manual Testing to Automation using Ruby • Execute and Automate Test • Rspec Introduction • Rspec Installation • Rspec for Automation • Rspec Demo • Pry Introduction • Debugging using Pry • Pry Demo • Discussion 5 Introduction • What is Ruby? • What is difference between Scripting language and Programming Language? • What’s New in Ruby? • Ruby Installation • irb • Ruby Script execution. 6 Appium Introduction What is Appium? • Appium is a mobile UI testing framework supporting cross-platform testing of native, hybrid and mobile-web apps for iOS and Android. • Appium enables you to execute your tests on mobile device irrespective of the device OS. • Framework is basically a wrapper that translates Selenium Webdriver commands into UIAutomation (iOS) or UIAutomator (Android) commands depending on the device type. 7 Appium Introduction • What languages can I use to write the TestScripts? • You can write TestScripts in any language that Selenium WebDriver dependency is available for. This includes C#, Closure, Java, JavaScript with Node.js, Obj-C, Perl, Python, Ruby. • Appium is an open-source tool that can be used to automate your mobile applications. Just like the Selenium WebDriver - which is an open-source tool used to automate web browsers. • Appium is an automation library used to drive your mobile applications, and even the web browser within the mobile simulator, emulator or real device. 8 Advantages of using Appium • It allows you to write tests against multiple mobile platforms using the same API. • You can write and run your tests u s i n g a n y l a n g u a g e o r t e s t framework. • It is an open-source tool that you can easily contribute to. 9 Limitations using APPIUM • Appium does not support testing of Android Version lower than 4.2 • Limited support for hybrid app testing. eg: not possible to test the switching action of application from the web app to native and vice- versa. • No support to run Appium Inspector on Microsoft Windows. 10 APPIUM PHILOSOPHY • Appium was designed to meet mobile automation needs according to a philosophy outlined by the following four tenets: • You shouldn’t have to recompile your app or modify it in any way in order to automate it. • You shouldn’t be locked into a specific language or framework to write and run your tests. • A mobile automation framework shouldn’t reinvent the wheel when it comes to automation APIs. • A mobile automation framework should be open source, in spirit and practice as well as in name! 11 APPIUM Architecture APPIUM Architecture • Appium runs on real devices and emulators. • It takes the Selenium commands from your test code and translates them into a readable format for UIAutomator, using the WebDriver JSON Wire Protocol. • WebDriver (aka "Selenium WebDriver") specifies a client- server protocol (known as the JSON Wire Protocol). • Given this client-server architecture, a client written in any language can be used to send the appropriate HTTP requests to the server. • The client libraries are simply HTTP clients and can be mixed into your code any way you please. • In other words, Appium & WebDriver clients are not technically "test frameworks" -- they are "automation libraries". Appium Concepts • Client/Server Architecture • Appium is at its heart a webserver that exposes a REST API. It receives connections from a client, listens for commands, executes those commands on a mobile device, and responds with an HTTP response representing the result of the command execution. • The fact that we have a client/server architecture opens up a lot of possibilities: we can write our test code in any language that has a http client API, but it is easier to use one of the Appium client libraries. • We can put the server on a different machine than our tests are running on. • We can write test code and rely on a cloud service like Sauce Labs to receive and interpret the commands. Appium Concepts • Session • Automation is always performed in the context of a session. Clients initiate a session with a server in ways specific to each library, but they all end up sending a POST /session request to the server, with a JSON object called the 'desired capabilities' object. • At this point the server will start up the automation session and respond with a session ID which is used for sending further commands. Appium Concepts • Desired Capabilities • Desired capabilities are a set of keys and values (i.e., a map or hash) sent to the Appium server to tell the server what kind of automation session we're interested in starting up. • There are also various capabilities which can modify the behavior of the server during automation. • For example, we might set the platformName capability to iOS to tell Appium that we want an iOS session, rather than an Android one. Or we might set the safariAllowPopups capability to true in order to ensure that, during a Safari automation session, we're allowed to use JavaScript to open up new windows. • http://appium.io/slate/en/master/?ruby#appium-server- capabilities • Appium Server • Appium is a server written in Node.js. It can be built and installed from source or installed directly from NPM. Appium Concepts • Appium Clients • There are client libraries (in Java, Ruby, Python, PHP, JavaScript, and C#) which support Appium's extensions to the WebDriver protocol. When using Appium, you want to use these client libraries instead of your regular WebDriver client. You can view the full list of libraries here. • Appium.app, Appium.exe • There exist GUI wrappers around the Appium server that can be downloaded. These come bundled with everything required to run the Appium server, so you don't need to worry about Node. They also come with an Inspector, which enables you to check out the hierarchy of your app. This can come in handy when writing tests. workflow workflow Architecture workflow • We have a UIAutomator/Selendroid in place of Apple instruments and bootstrap.jar in place of the bootstrap.js file. • Appium supports Android versions greater than or equal to 17; for earlier versions, it uses the Selendroid framework. • When we execute the test scripts, Appium sends the command to the UIAutomator or Selendroid on the basis of the Android version. • Here, bootstrap.jar plays the role of a TCP server, which we can use to send the test command in order to perform the action on the Android device using UIAutomator/Selendroid. Prerequisite • ANDROID SDK • JDK (Java Development Kit) • TestNG • Eclipse • Selenium Server JAR • Webdriver Language Binding Library • APPIUM For Windows • APK App Info On Google Play • Node.js (Not Required - Whenever Appium server is installed, it by default comes with "Node.exe" & NPM. It's included in Current version of Appium.) Installation Steps • 1. Install Java JDK • Edit your .bash_profile with "." before to update your environment to point correctly to java • $ cd • $ open -a TextEdit .bash_profile • If the file doesn't exist you will get the error: • The file /Users/???/.bash_profile does not exist. • Then • $ touch .bash_profile • $ open -a TextEdit .bash_profile Installation Steps • Insert into .bash_profile and save • export JAVA_HOME=$(/usr/libexec/java_home) • Restart the terminal to include the new configurations. In terminal type: • $ source .bash_profile • or just quit and reopen terminal • To test in terminal • $ java -version • For Older Mac OSX • Same as above but hardcode path and replace ?.?.? with your version • export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/?.?.?.jdk/Contents/Home • echo $JAVA_HOME /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home Installation Steps Surendras-MBP:~ SurendraMac$ vim .bash_profile export JAVA_HOME=/Library/Java/JavaVirtualMachines/ jdk1.8.0_60.jdk/Contents/Home export ANDROID_HOME=/Users/SurendraMac/Library/Android/sdk export PATH=$ANDROID_HOME/platform-tools:$PATH export PATH=$ANDROID_HOME/tools:$PATH export PATH=$JAVA_HOME/:$PATH # added by Anaconda 2.3.0 installer export PATH="/Users/SurendraMac/anaconda/bin:$PATH" Installation Steps • 2. Install Android Studio/SDK • Install all SDK tools and emulators • Select "Configure" • Select "SDK Manager" • Install all available packages Installation Steps • 2. Install Android Studio/SDK Installation
Recommended publications
  • Rubicon: Bounded Verification of Web Applications
    Rubicon: Bounded Verification of Web Applications The MIT Faculty has made this article openly available. Please share how this access benefits you. Your story matters. Citation Joseph P. Near and Daniel Jackson. 2012. Rubicon: bounded verification of web applications. In Proceedings of the ACM SIGSOFT 20th International Symposium on the Foundations of Software Engineering (FSE '12). ACM, New York, NY, USA, Article 60, 11 pages. As Published http://dx.doi.org/10.1145/2393596.2393667 Publisher Association for Computing Machinery (ACM) Version Author's final manuscript Citable link http://hdl.handle.net/1721.1/86919 Terms of Use Creative Commons Attribution-Noncommercial-Share Alike Detailed Terms http://creativecommons.org/licenses/by-nc-sa/4.0/ Rubicon: Bounded Verification of Web Applications Joseph P. Near, Daniel Jackson Computer Science and Artificial Intelligence Lab Massachusetts Institute of Technology Cambridge, MA, USA {jnear,dnj}@csail.mit.edu ABSTRACT ification language is an extension of the Ruby-based RSpec We present Rubicon, an application of lightweight formal domain-specific language for testing [7]; Rubicon adds the methods to web programming. Rubicon provides an embed- quantifiers of first-order logic, allowing programmers to re- ded domain-specific language for writing formal specifica- place RSpec tests over a set of mock objects with general tions of web applications and performs automatic bounded specifications over all objects. This compatibility with the checking that those specifications hold. Rubicon's language existing RSpec language makes it easy for programmers al- is based on the RSpec testing framework, and is designed to ready familiar with testing to write specifications, and to be both powerful and familiar to programmers experienced convert existing RSpec tests into specifications.
    [Show full text]
  • Rubicon: Bounded Verification of Web Applications
    View metadata, citation and similar papers at core.ac.uk brought to you by CORE provided by DSpace@MIT Rubicon: Bounded Verification of Web Applications Joseph P. Near, Daniel Jackson Computer Science and Artificial Intelligence Lab Massachusetts Institute of Technology Cambridge, MA, USA {jnear,dnj}@csail.mit.edu ABSTRACT ification language is an extension of the Ruby-based RSpec We present Rubicon, an application of lightweight formal domain-specific language for testing [7]; Rubicon adds the methods to web programming. Rubicon provides an embed- quantifiers of first-order logic, allowing programmers to re- ded domain-specific language for writing formal specifica- place RSpec tests over a set of mock objects with general tions of web applications and performs automatic bounded specifications over all objects. This compatibility with the checking that those specifications hold. Rubicon's language existing RSpec language makes it easy for programmers al- is based on the RSpec testing framework, and is designed to ready familiar with testing to write specifications, and to be both powerful and familiar to programmers experienced convert existing RSpec tests into specifications. in testing. Rubicon's analysis leverages the standard Ruby interpreter to perform symbolic execution, generating veri- Rubicon's automated analysis comprises two parts: first, fication conditions that Rubicon discharges using the Alloy Rubicon generates verification conditions based on specifica- Analyzer. We have tested Rubicon's scalability on five real- tions; second, Rubicon invokes a constraint solver to check world applications, and found a previously unknown secu- those conditions. The Rubicon library modifies the envi- rity bug in Fat Free CRM, a popular customer relationship ronment so that executing a specification performs symbolic management system.
    [Show full text]
  • Ola Bini Computational Metalinguist [email protected] 698E 2885 C1DE 74E3 2CD5 03AD 295C 7469 84AF 7F0C
    JRuby For The Win Ola Bini computational metalinguist [email protected] http://olabini.com/blog 698E 2885 C1DE 74E3 2CD5 03AD 295C 7469 84AF 7F0C onsdag 12 juni 13 Logistics and Demographics onsdag 12 juni 13 LAST MINUTE DEMO onsdag 12 juni 13 JRuby Implementation of the Ruby language Java 1.6+ 1.8.7 and 1.9.3 compatible (experimental 2.0 support) Open Source Created 2001 Embraces testing Current version: 1.7.4 Support from EngineYard, RedHat & ThoughtWorks onsdag 12 juni 13 Why JRuby? Threading Unicode Performance Memory Explicit extension API and OO internals Libraries and legacy systems Politics onsdag 12 juni 13 InvokeDynamic onsdag 12 juni 13 JRuby Differences Most compatible alternative implementation Native threads vs Green threads No C extensions (well, some) No continuations No fork ObjectSpace disabled by default onsdag 12 juni 13 Simple JRuby onsdag 12 juni 13 Java integration Java types == Ruby types Call methods, construct instances Static generation of classes camelCase or snake_case .getFoo(), setFoo(v) becomes .foo and .foo = v Interfaces can be implemented Classes can be inherited from Implicit closure conversion Extra added features to Rubyfy Java onsdag 12 juni 13 Ant+Rake onsdag 12 juni 13 Clojure STM onsdag 12 juni 13 Web onsdag 12 juni 13 Rails onsdag 12 juni 13 Sinatra onsdag 12 juni 13 Trinidad onsdag 12 juni 13 Swing Swing API == large and complex Ruby magic simplifies most of the tricky bits Java is a very verbose language Ruby makes Swing fun (more fun at least) No consistent cross-platform GUI library for Ruby
    [Show full text]
  • Ruby on Rails™ Tutorial: Learn Web Developments with Rails
    ptg8286261 www.it-ebooks.info Praise for Michael Hartl’s Books and Videos on Ruby on RailsTM ‘‘My former company (CD Baby) was one of the first to loudly switch to Ruby on ptg8286261 Rails, and then even more loudly switch back to PHP (Google me to read about the drama). This book by Michael Hartl came so highly recommended that I had to try it, and the Ruby on RailsTM Tutorial is what I used to switch back to Rails again.’’ —From the Foreword by Derek Sivers (sivers.org) Formerly: Founder, CD Baby Currently: Founder, Thoughts Ltd. ‘‘Michael Hartl’s Rails Tutorial book is the #1 (and only, in my opinion) place to start when it comes to books about learning Rails. It’s an amazing piece of work and, unusually, walks you through building a Rails app from start to finish with testing. If you want to read just one book and feel like a Rails master by the end of it, pick the Ruby on RailsTM Tutorial.’’ —Peter Cooper Editor, Ruby Inside www.it-ebooks.info ‘‘Grounded in the real world.’’ —I Programmer (www.i-programmer.info), by Ian Elliot ‘‘The book gives you the theory and practice, while the videos focus on showing you in person how its done. Highly recommended combo.’’ —Antonio Cangiano, Software Engineer, IBM ‘‘The author is clearly an expert at the Ruby language and the Rails framework, but more than that, he is a working software engineer who introduces best practices throughout the text.’’ —Greg Charles, Senior Software Developer, Fairway Technologies ‘‘Overall, these video tutorials should be a great resource for anyone new to Rails.’’ —Michael Morin, ruby.about.com ‘‘Hands-down, I would recommend this book to anyone wanting to get into Ruby on Rails development.’’ —Michael Crump, Microsoft MVP ptg8286261 www.it-ebooks.info RUBY ON RAILSTM TUTORIAL Second Edition ptg8286261 www.it-ebooks.info Visit informit.com/ruby for a complete list of available products.
    [Show full text]
  • Collaborative Topic Modeling for Recommending Github Repositories
    Collaborative Topic Modeling for Recommending GitHub Repositories Naoki Orii School of Computer Science Carnegie Mellon University Pittsburgh, PA 15213, USA [email protected] ABSTRACT While an increase in the number of availble open source software projects certainly benefits the open source ecosys- The rise of distributed version control systems has led to a tem, it has become more difficult for programmers to find significant increase in the number of open source projects projects of interest. In 2009, GitHub hosted a recommenda- available online. As a consequence, finding relevant projects tion contest to recommend repositories to users. The train- has become more difficult for programmers. Item recom- ing dataset was based on 440,000 user-watches-repository mendation provides a way to solve this problem. In this pa- relationships given by over 56,000 users to nearly 121,000 per, we utilize a recently proposed algorithm that combines repositories. The test dataset consisted of 4,800 users (which traditional collaborative filtering and probabilistic topic mod- all of them are in the training data), and the goal is to rec- eling. We study a large dataset from GitHub, a social net- ommend up to 10 repositories for each of the test users. working and open source hosting site for programmers, and compare the method against traditional methods. We also The problem of item recommendation has been studied provide interpretations on the latent structure for users and extensively, especially involving the Netflix Prize. However, repositories. there is a distinct difference between the Netflix Prize and GitHub's recommendation contest. While in both contests we have the user-item matrix, we can also consider source 1.
    [Show full text]
  • Ruby on Rails
    Ruby.learn{ |stuff| } ● What is Ruby? ● What features make it interesting to me (and maybe you)? ● A quick, idiosyncratic tour of the Ruby ecosphere. Tuesday Software Lunch Talk: March 4, 2008 What is it? ● a dynamic, object-oriented, open source programming language... ● with a uniquely (but not too uniquely), expressive syntax ● dynamically or “duck” typed ● influenced by Perl, Smalltalk, Eiffel, Ada and Lisp ● has aspects of functional and imperative programming styles History ● created by Yukihiro “Matz” Matsumoto on Feb 24 1993, released to public in 1995 ● “Ruby” coined in comparison to “Perl” Philosophy (the “Ruby Way”) ● emphasize programmer needs over computer needs ● encourage good design, good APIs ● Principle of Least Surprise (POLS) – the language should behave in such a way as to minimize confusion for experienced users ● “Everything should be a simple as possible, but no simpler.” - Einstein ● orthogonality ● change at runtime is not to be feared Interesting Stuff... ● Is Not a Ruby tutorial – http://tryruby.hobix.com/ – Programming Ruby: The Pragmatic Programmer's Guide – our just google it – you want something totally different? ● http://poignantguide.net/ruby/ ● Is what I find interesting/different/well done about Ruby. Everything's an Object ● no exceptions Falsiness ● only false and nil are falsey. Not 0. Symbols ● labels ● lightweight strings with no behaviour ● often used as hash keys Blocks ● another name for a Ruby block is a “closure” ● clo-sure [kloh-zher] – noun. A function that is evaluated in an environment containing one or more bound variables. Procs ● anonymous subroutines or closures with a life of their own Adding Methods to Classes ● You can add methods to an object at runtime in several ways..
    [Show full text]
  • Getting Started with Appium
    E-BOOK Getting Started With Appium RUBY EDITION 2018.1 LEARN MORE AT SAUCELABS.COM BY JONATHAN LIPPS TABLE OF CONTENTS 3 Preface 20 Chapter 4: Writing Your First Test 4 Chapter 1: Introduction 25 Chapter 5: Introduction to Page Objects 4 The Appium Vision 30 Chapter 6: Android Joins the Party 5 The Appium Drivers 35 Chapter 7: Running Local Tests With Rake 6 The Appium Clients 36 Chapter 8: Running Tests in the Sauce Labs Cloud 7 Chapter 2: Getting Set Up 40 Annotating Tests on Sauce 7 Assumed Knowledge 41 Chapter 9: Automating Test Runs with a CI Server 7 iOS-specific System Setup 41 Setting Up Jenkins 7 Android-Specific System Setup 42 Creating an Android Build 8 Appium Setup 44 Creating an iOS Build 10 Ruby Client Setup 44 Running on Sauce 10 Project Setup 45 Jenkins for Production 11 Known Working Versions 46 Chapter 10: Heading Out on Your Own 12 Chapter 3: Exploring Your App 46 Resources 12 Using the Appium Ruby Console 47 Support 17 Using the Appium Desktop Inspector PREFACE This little e-book will help you get started with Appium using the Ruby programming language. It is a complete revision from the ground up of an earlier guide written by Dave Haeffner, who along with Matthew Edwards deserves a lot of thanks for all the work put into the first edition. Appium is an open source project that is always changing, and guides like this one will never be accurate forever. When possible I will indicate which versions of various software are being used, which might help in ensuring reproducibility of the code samples used here.
    [Show full text]
  • Ruby on Rails Django
    glossarytech.com Ruby A Redis -backed library for creating background jobs, placing those jobs Resque on multiple queues, and processing them later. Active A Ruby library for working with Relational SQL Databases, like MySQL Record and Postgres . It provides an Object Relational Mapping . A security scanner. Checks Ruby on Rails applications for security Brakeman vulnerabilities. Looks at the source code of an application. Ensures Ruby applications run the same code on every machine. Tracks Bundler and installs the exact gems and versions that are needed. Remote server automation and deployment tool written in Ruby . Capistrano C apistrano automates the process of making a new version of an application available on one or more web servers. Automation library that provides a means for controlling a browser. Capybara S imulates scenarios for user stories and automates web application testing for behavior-driven software development. A dynamic, functional language designed for building scalable and maintainable applications. Leverages the Erlang VM, known for the Crystal r unning low-latency, distributed and fault-tolerant systems, while also being successfully used in web development and the embedded software domain. Embedded Ruby. A templating language that enables to embed Ruby ERB c ode in an HTML document, similar to ASP, JSP and PHP and other server-side scripting languages. Fast, simple event-processing library for Ruby programs. The most EventMachi p opular library for concurrent computing in the Ruby programming ne language. A software library for the Ruby . Provides factory methods to create test FactoryBot fixtures for automated software testing. REST -like API micro-framework for Ruby .
    [Show full text]
  • Fine Articles on Ruby & Rails
    Rails Magazine MyMagazineIssue 1, Julyfine 2008 articles on Ruby & Rails Extending Rails Through Plugins by John Yerhot Receiving E-Mail With Rails by Jason Seifer Delegation in Ruby by Khaled al Habache Subscription billing with Saasy by Alex MacCaw Making the Switch From RSpec to Shoulda by Dan Pickett Playing Hooky a.k.a. web hooks by John Nunemaker Adhearsion by Jason Goecke & Jay Phillips Rails Performance Analysis by Terry Heath Getting Started with JRuby and JRuby on Rails by Joshua Moore 1 ISSN 1916-8004 http://RailsMagazine.com Editorial2 by Olimpiu Metiu Editorial Contents by Olimpiu Metiu Welcome to the first edition of Rails Magazine, the first and Editorial ...........................................................................2 only free magazine dedicated to the Ruby on Rails community! by Olimpiu Metiu If you are interested in a quality compilation of timely, relevant articles, with editorial oversight and beautiful layout, Extending Rails Through Plugins .................................3 please check out the magazine regularly or subscribe online. by John Yerhot Long before launch, I was impressed with the level of interest and receptiveness. Rails always had a vibrant and dedicated com- Receiving E-Mail With Rails .........................................4 munity, and I hope Rails Magazine will become an appreciated by Jason Seifer resource for those looking for quality information — at the same time providing global exposure to those interested in getting Delegation in Ruby .........................................................8 published. by Khaled al Habache Subscription billing with Saasy ...................................13 Olimpiu Metiu is a Toronto-based architect and by Alex MacCaw the leader of the Emergent Technologies group at Bell Canada. His work includes many of Canada's Making the Switch From RSpec to Shoulda ..............16 largest web sites and intranet portals.
    [Show full text]
  • Qcon Not Just Another JVM Language
    Sun Microsystems, Inc. Agenda • Ruby feature walkthrough • JRuby enhancements and additions • Swing programming • Demo: Swing in Ruby • Web applications • Demo: JRuby on Rails • Persistence • Build automation • Test and behavior-driven development 2 Who am I • Charles Oliver Nutter • Longtime Java developer (10+ yrs) • Engineer at Sun Microsystems for 1 yr • Full-time JRuby developer • Also working on JVM dynlang support • Wide range of past experience > C, C++, C#, Perl, Python, Delphi, Lisp, Scheme > Java EE and ME, JINI, WS 3 Page 1 Sun Microsystems, Inc. What Is Ruby • Dynamic-typed, pure OO language > Interpreted > Open source, written in C > Good: easy to write, easy to read, powerful, “fun” > Bad: green threads, unicode support, libraries, “slow” • Created 1993 by Yukihiro “Matz” Matsumoto > “More powerful than Perl and more OO than Python” • Very active community, wide range of apps • Ruby 1.8.x is current, 1.9 is in development to become 2.0 4 Ruby Quick Tour: Pure OO • Everything is an Object > Circle.new(4) => instance of Circle > “abc”.length => 3 > 1.to_s => “1” • All Objects are instances of Classes > 1.class => Fixnum • Single-Inheritance • Object is base class of all classes 5 Ruby Quick Tour: Basics • Literals > Fixnum: 1 > Float: 1.0 > Bignum: 12345678987654321 > String: “one” 'one' %Q[one] %q[one] ... > Multiline string (“here doc”): x = <<EOS extend across two lines EOS > Symbol: :one, %s[one] > Regexp: /^foo\w+.*bar$/, %r[^foo$] > Array: [1, “ein”, :ichi] > Hash: {:one => 1, :two => 2} 6 Page 2 Sun Microsystems, Inc. Ruby Quick Tour: Basics • String substitution > a = “foo” > b = “bar#{a}baz” => “barfoobaz” • Operator overloading > def +(arg); ..
    [Show full text]
  • Rspec Documentation
    RSPec Documentation Contents: 1. Introduction to Rspec - Installing Rspec Gem (Getting Started) - Terminology used in Rspec 2. Writing Simple Rspec Tests 3. Running Rspec Testfiles 4. Scenario Testing Examples of OAR REST APIs using Rspec 5. Creating Rspec Testsuites 6. Tutorials/References Written by , Narayanan K Gsoc-2010,OAR Testsuites Introduction to Rspec Rspec is a behavior driven test development framework developed for Ruby. Behavior Driven Development(BDD) began its journey as an attempt to better understand and explain the process of Test Driven Development. Behavior driven development is an agile software development technique . Lot of beautiful documentations describing RSpec are available online including the e- book, “The RSpec Book” by David Chelinsky. I have included the sites and the e-book that is available in the reference section of this documentation that really got me testing my codes with RSpec. This documentation specifically deals with how to perform unit/scenario testing of the OAR REST APIs. The RSpec tool is a Ruby package that lets you build a specification alongside your software. This specification is actually a test that describes the behavior of your system. Here's the flow for development with RSpec: • You write a test. This test describes the behavior of a small element of your system. • You run the test. The test fails because you have not yet built the code for that part of your system. This important step tests your test case, verifying that your test case fails when it should. • You write enough code to make the test pass. • You run the tests and verify that they pass.
    [Show full text]
  • Effective Testing with Rspec 3 Build Ruby Apps with Confidence
    Extracted from: Effective Testing with RSpec 3 Build Ruby Apps with Confidence This PDF file contains pages extracted from Effective Testing with RSpec 3, pub- lished by the Pragmatic Bookshelf. For more information or to purchase a paper- back or PDF copy, please visit http://www.pragprog.com. Note: This extract contains some colored text (particularly in code listing). This is available only in online versions of the books. The printed versions are black and white. Pagination might vary between the online and printed versions; the content is otherwise identical. Copyright © 2017 The Pragmatic Programmers, LLC. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form, or by any means, electronic, mechanical, photocopying, recording, or otherwise, without the prior consent of the publisher. The Pragmatic Bookshelf Raleigh, North Carolina Effective Testing with RSpec 3 Build Ruby Apps with Confidence Myron Marston Ian Dees The Pragmatic Bookshelf Raleigh, North Carolina Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf, PragProg and the linking g device are trade- marks of The Pragmatic Programmers, LLC. Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
    [Show full text]