test_framework 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ N2E0MGJiMTQwZThhZjhhYTQ0OTdhMGM4ZTdhZDdhZmI3MGRjZjFmOQ==
5
+ data.tar.gz: !binary |-
6
+ NTZjYWI4YmM0MmE0YTUxZTc2M2E2M2M1YjAxNjAyNmM1MTE0MWYwYQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NGY2OWRkNjA4ZmRjYjU3NDc1Yjg4NTdiZGVhYjk5YTVlZWJmMDBhZDA3MjEx
10
+ Y2MxZDU1NGRhMzU2OTNhOGJkZmUwMGFlMmVmYjViNGI5MGQyOWEyYjk1MmQw
11
+ N2RhY2Y2MzZkZWUyYzUxOTQ0MmQ3Yjk0YTkzNDU5YzEzNjVlZDk=
12
+ data.tar.gz: !binary |-
13
+ MjUxNmQzODAwMmNhYzllMmRhOWE2YzJlZmVmOGM5ZTUwYWY5NWI2NGM1ZmQy
14
+ MWFmOTJkN2UwZDJkNjQ0N2ZiZGE3OTliZjUxMTkzZjhiMGY5MmY0MjgyNzY3
15
+ YTJhM2I2NmRiMWVlZDRjYmZkNGYwZjM5NmY0OTcyMzBlNmFiMzA=
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ tmp
6
+ .idea/
@@ -0,0 +1 @@
1
+ test_framework
@@ -0,0 +1 @@
1
+ ruby-1.9.3-p392
@@ -0,0 +1,3 @@
1
+ === Version 0.2 / 2013-07-27
2
+ * Initial release of Test_Framework
3
+
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'fuubar'
5
+ gem 'fuubar-cucumber'
6
+ gem 'rb-fsevent', '~> 0.9.1'
7
+ gem 'growl'
8
+ gem 'guard-rspec'
9
+ gem 'guard-cucumber'
10
+
11
+ # Specify your gem's dependencies in test_framework.gemspec
12
+ gemspec
@@ -0,0 +1,11 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'cucumber', :notification => true, :all_after_pass => false, :cli => '--profile focus' do
5
+ watch(%r{^features/.+\.feature$})
6
+ watch(%r{^features/support/.+$}) { 'features' }
7
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
8
+ watch(%r{^lib/.+\.rb$}) { "features" }
9
+ watch(%r{^lib/.+\.tt$}) { "features" }
10
+ watch(%r{^cucumber.yml$}) { "features" }
11
+ end
@@ -0,0 +1,14 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'cucumber'
4
+ require 'cucumber/rake/task'
5
+
6
+ Cucumber::Rake::Task.new(:features, "Run features") do |t|
7
+ t.profile = 'default'
8
+ end
9
+
10
+ task :lib do
11
+ $LOAD_PATH.unshift(File.expand_path("lib", File.dirname(__FILE__)))
12
+ end
13
+
14
+ task :default => :features
@@ -0,0 +1,3 @@
1
+ # TestFramework
2
+
3
+ A gem that contains generators a test framework for your chosen driver and cucumber.
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test_framework/cli'
4
+ TestFramework::CLI.start
@@ -0,0 +1,3 @@
1
+ default: --no-source --color --format pretty
2
+ focus: --no-source --color --format pretty --tags @focus
3
+
@@ -0,0 +1,6 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'lib'))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../../', 'bin'))
3
+
4
+ require 'aruba/cucumber'
5
+
6
+ require 'test_framework'
@@ -0,0 +1,6 @@
1
+ require 'fileutils'
2
+
3
+ After do
4
+ dir = File.join(File.dirname(__FILE__), '../../', 'tmp/aruba/sample')
5
+ FileUtils.rm_rf dir
6
+ end
@@ -0,0 +1,48 @@
1
+ Feature: Generating a project with TestGen
2
+
3
+ Background:
4
+ When I run `testgen project sample`
5
+
6
+ Scenario: Creating the top level project directory
7
+ Then a directory named "sample" should exist
8
+
9
+ Scenario: Generating the cucumber.yml file
10
+ Then a file named "sample/cucumber.yml" should exist
11
+ And the file "sample/cucumber.yml" should contain "default: --no-source --color --format pretty"
12
+
13
+ Scenario: Generating the Gemfile file
14
+ Then a file named "sample/Gemfile" should exist
15
+ And the file "sample/Gemfile" should contain "gem 'cucumber'"
16
+ And the file "sample/Gemfile" should contain "gem 'rspec'"
17
+ And the file "sample/Gemfile" should contain "source 'http://rubygems.org'"
18
+
19
+
20
+ Scenario: Generating the Rakefile file
21
+ Then a file named "sample/Rakefile" should exist
22
+ And the file "sample/Rakefile" should contain "Cucumber::Rake::Task.new(:features)"
23
+ And the file "sample/Rakefile" should contain exactly:
24
+ """
25
+ require 'rubygems'
26
+ require 'cucumber'
27
+ require 'cucumber/rake/task'
28
+
29
+ Cucumber::Rake::Task.new(:features) do |t|
30
+ t.profile = 'default'
31
+ end
32
+
33
+ task :default => :features
34
+ """
35
+ Scenario: Creating the features set of directories
36
+ Then the following directories should exist:
37
+ | sample/config |
38
+ | sample/config/data |
39
+ | sample/config/environments |
40
+ | sample/features |
41
+ | sample/features/support |
42
+ | sample/features/support/pages |
43
+ | sample/features/support/data |
44
+ | sample/features/step_definitions |
45
+
46
+ Scenario: Generating the env.rb file
47
+ Then a file named "sample/features/support/env.rb" should exist
48
+ And the file "sample/features/support/env.rb" should contain "require 'rspec-expectations'"
@@ -0,0 +1,30 @@
1
+ Feature: Adding support for the --pageobject-driver option
2
+
3
+
4
+ Scenario: Adding page-object to the Gemfile
5
+ When I run `testgen project sample --pageobject-driver=watir`
6
+ Then a file named "sample/Gemfile" should exist
7
+ And the file "sample/Gemfile" should contain "gem 'page-object'"
8
+
9
+ Scenario: Adding page-object to env.rb
10
+ When I run `testgen project sample --pageobject-driver=watir`
11
+ Then a file named "sample/features/support/env.rb" should exist
12
+ And the file "sample/features/support/env.rb" should contain "require 'page-object'"
13
+ And the file "sample/features/support/env.rb" should contain "World(PageObject::PageFactory)"
14
+
15
+ Scenario: Adding the hook file for Watir
16
+ When I run `testgen project sample --pageobject-driver=watir`
17
+ Then a file named "sample/features/support/hooks.rb" should exist
18
+ And the file "sample/features/support/hooks.rb" should contain "require 'watir-webdriver'"
19
+ And the file "sample/features/support/hooks.rb" should contain "@browser = Watir::Browser.new :firefox"
20
+
21
+ Scenario: Adding the hook file for Selenium
22
+ When I run `testgen project sample --pageobject-driver=selenium`
23
+ Then a file named "sample/features/support/hooks.rb" should exist
24
+ And the file "sample/features/support/hooks.rb" should contain "require 'selenium-webdriver'"
25
+ And the file "sample/features/support/hooks.rb" should contain "@browser = Selenium::WebDriver.for :firefox"
26
+
27
+ Scenario: Creating the pages directory
28
+ When I run `testgen project sample --pageobject-driver=selenium`
29
+ Then a directory named "sample/features/support/pages" should exist
30
+
@@ -0,0 +1,2 @@
1
+ require "test_framework/version"
2
+ require 'test_framework/cli'
@@ -0,0 +1,16 @@
1
+ require 'thor'
2
+ require 'test_framework/generators/project'
3
+
4
+ module TestFramework
5
+ class CLI < Thor
6
+
7
+ desc "project <project_name>", "Create a new Test Framework for automation testing with Cucumber"
8
+ method_option :driver, :type => :string, :required => false, :desc => "Select a driver: Valid values are 'watir' or 'capybara'"
9
+
10
+ def project(name)
11
+ driver = options[:driver].nil? ? 'none' : options[:driver]
12
+ TestFramework::Generators::Project.start([name, driver])
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,60 @@
1
+ require 'thor/group'
2
+
3
+ module TestFramework
4
+ module Generators
5
+ class Project < Thor::Group
6
+ include Thor::Actions
7
+
8
+ desc "Generates a project structure for testing with Cucumber"
9
+ argument :name, :type => :string, :desc => 'The name of the test project'
10
+ argument :driver, :type => :string, :desc => 'Driver you want to use'
11
+
12
+ def self.source_root
13
+ File.dirname(__FILE__) + "/project"
14
+ end
15
+
16
+ def create_top_directory
17
+ empty_directory(name)
18
+ end
19
+
20
+ def create_cucumber_directories
21
+ empty_directory("#{name}/lib")
22
+ empty_directory("#{name}/features")
23
+ empty_directory("#{name}/features/support")
24
+ empty_directory("#{name}/features/support/pages")
25
+ empty_directory("#{name}/features/support/helpers")
26
+ empty_directory("#{name}/features/step_definitions")
27
+ end
28
+
29
+ def copy_cucumber_yml
30
+ template "cucumber.yml.tt", "#{name}/cucumber.yml"
31
+ end
32
+
33
+ def copy_env_config
34
+ template "env_config.rb.tt", "#{name}/lib/env_config.rb"
35
+ end
36
+
37
+ def copy_gemfile
38
+ template "Gemfile.tt", "#{name}/Gemfile"
39
+ end
40
+
41
+ def copy_rakefile
42
+ copy_file "Rakefile", "#{name}/Rakefile"
43
+ end
44
+
45
+ def copy_env
46
+ template "env.rb.tt", "#{name}/features/support/env.rb"
47
+ end
48
+
49
+ def copy_hooks
50
+ template "hooks.rb.tt", "#{name}/features/support/hooks.rb" unless no_driver_selected
51
+ end
52
+
53
+ private
54
+
55
+ def no_driver_selected
56
+ driver.downcase == 'none'
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,14 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'cucumber'
4
+ gem 'rspec'
5
+ gem 'rake'
6
+ gem 'fig_newton'
7
+ gem 'nokogiri'
8
+ <% if driver = 'watir' -%>
9
+ gem 'page-object'
10
+ <% elsif driver = 'capybara' -%>
11
+ gem 'capybara'
12
+ gem 'site_prism'
13
+ <% end -%>
14
+
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'cucumber'
3
+ require 'cucumber/rake/task'
4
+
5
+ Cucumber::Rake::Task.new(:features) do |t|
6
+ t.profile = 'default'
7
+ end
8
+
9
+ task :default => :features
10
+
11
+ namespace :cuke do
12
+ profiles = YAML::load(File.open(File.join(Dir.pwd, 'cucumber.yml'))).keys
13
+ profiles.each do |profile|
14
+ Cucumber::Rake::Task.new(profile.to_sym) do |t|
15
+ t.profile = profile
16
+ end
17
+ end
18
+ end
19
+
20
+ task :help do |t|
21
+ message = <<-MESSAGE
22
+ Optional flags:
23
+ CONFIG=ci, ft, uat, rc
24
+ BROWSER=firefox (default), chrome, ie
25
+ JUNIT_OUTPUT= Select some directory
26
+ MESSAGE
27
+ puts message
28
+ end
@@ -0,0 +1 @@
1
+ default: --no-source --color --format pretty
@@ -0,0 +1,34 @@
1
+ require 'rspec'
2
+ require 'rspec-expectations'
3
+ require 'rspec/matchers'
4
+ require 'nokogiri'
5
+
6
+ <% if driver.downcase == 'watir' -%>
7
+ require 'page-object'
8
+
9
+ World(PageObject::PageFactory)
10
+ <% end -%>
11
+
12
+ <% if driver.downcase == 'capybara' -%>
13
+ require 'capybara'
14
+ require 'site_prism'
15
+ <% end -%>
16
+
17
+ #local libs
18
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
19
+ require 'env_config'
20
+
21
+ case ENV['browser']
22
+ when 'chrome'
23
+ browser = Watir::Browser.new :chrome
24
+ when 'ie'
25
+ browser = Watir::Browser.new :ie
26
+ else
27
+ browser = Watir::Browser.new :firefox
28
+ end
29
+
30
+ at_exit do
31
+ browser.close unless browser.nil?
32
+ @browser.close unless @browser.nil?
33
+ end
34
+
@@ -0,0 +1,42 @@
1
+ require 'singleton'
2
+
3
+ class EnvConfig
4
+ include Singleton
5
+ attr_reader :environment_specific_config
6
+ attr_reader :config_file_contents
7
+
8
+ def initialize
9
+ @config_file_contents = config_file_contents
10
+ @environment_specific_config = @config_file_contents[current_config]
11
+ end
12
+
13
+ def value_for(key_name)
14
+ raise "there is no key '#{key_name}' for the config that you specified" if @environment_specific_config[key_name].nil?
15
+ @environment_specific_config[key_name]
16
+ end
17
+
18
+ def self.[](key_name)
19
+ instance.value_for(key_name)
20
+ end
21
+
22
+ def self.current_config
23
+ instance.current_config
24
+ end
25
+
26
+ def current_config
27
+ if ENV['CONFIG'].nil?
28
+ default_config = @config_file_contents['defaults']['default_config']
29
+ default_config.nil? ? abort("No CONFIG supplied, and no default config found in config.yml") : default_config
30
+ else
31
+ ENV['CONFIG']
32
+ end
33
+ end
34
+
35
+ private
36
+
37
+ def config_file_contents
38
+ config_yaml = File.join(Dir.pwd, 'config.yml')
39
+ raise "the config yaml file could not be found" unless File.exists?(config_yaml)
40
+ YAML::load(File.open(config_yaml))
41
+ end
42
+ end
@@ -0,0 +1,22 @@
1
+ <% if driver == 'watir' -%>
2
+ require 'watir-webdriver'
3
+ <% end %>
4
+ <% if driver == 'capybara' -%>
5
+ require 'selenium-webdriver'
6
+ require 'capybara'
7
+ require 'capybara/dsl'
8
+ require 'site_prism'
9
+ <% end %>
10
+
11
+ Before do
12
+ <% if driver == 'watir' -%>
13
+ @browser = Watir::Browser.new :firefox
14
+ <% end %>
15
+ <% if driver == 'capybara' -%>
16
+ @browser = Selenium::WebDriver.for :firefox
17
+ <% end %>
18
+ end
19
+
20
+ After do
21
+ @browser.close
22
+ end
@@ -0,0 +1,3 @@
1
+ module TestFramework
2
+ VERSION = "0.2"
3
+ end
@@ -0,0 +1,27 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "test_framework/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "test_framework"
7
+ s.version = TestFramework::VERSION
8
+ s.authors = ["John Wakeling"]
9
+ s.email = ["test-framework@johnwakeling.com"]
10
+ s.homepage = "http://github.com/johnwake/test_framework"
11
+ s.summary = %q{A test framework for testers using Cucumber}
12
+ s.description = %q{A framework to build things for software testing using Cucumber}
13
+
14
+ s.rubyforge_project = "test_framework"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_dependency 'thor'
22
+ s.add_dependency 'cucumber'
23
+ s.add_dependency 'rspec'
24
+ s.add_dependency 'require_all'
25
+
26
+ s.add_development_dependency 'aruba'
27
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: test_framework
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ platform: ruby
6
+ authors:
7
+ - John Wakeling
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cucumber
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: require_all
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: aruba
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A framework to build things for software testing using Cucumber
84
+ email:
85
+ - test-framework@johnwakeling.com
86
+ executables:
87
+ - test_framework
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - .gitignore
92
+ - .ruby-gemset
93
+ - .ruby-version
94
+ - ChangeLog
95
+ - Gemfile
96
+ - Guardfile
97
+ - Rakefile
98
+ - Readme.md
99
+ - bin/test_framework
100
+ - cucumber.yml
101
+ - features/support/env.rb
102
+ - features/support/hooks.rb
103
+ - features/testgen_project.feature
104
+ - features/testgen_with_pageobject.feature
105
+ - lib/test_framework.rb
106
+ - lib/test_framework/cli.rb
107
+ - lib/test_framework/generators/project.rb
108
+ - lib/test_framework/generators/project/Gemfile.tt
109
+ - lib/test_framework/generators/project/Rakefile
110
+ - lib/test_framework/generators/project/cucumber.yml.tt
111
+ - lib/test_framework/generators/project/env.rb.tt
112
+ - lib/test_framework/generators/project/env_config.rb.tt
113
+ - lib/test_framework/generators/project/hooks.rb.tt
114
+ - lib/test_framework/version.rb
115
+ - test_framework.gemspec
116
+ homepage: http://github.com/johnwake/test_framework
117
+ licenses: []
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project: test_framework
135
+ rubygems_version: 2.0.7
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: A test framework for testers using Cucumber
139
+ test_files:
140
+ - features/support/env.rb
141
+ - features/support/hooks.rb
142
+ - features/testgen_project.feature
143
+ - features/testgen_with_pageobject.feature