bdd-legacy 0.0.7 → 0.0.9

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.
Files changed (54) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +6 -0
  3. data/Rakefile +2 -59
  4. data/bdd-legacy.gemspec +51 -0
  5. data/bin/._bdd-legacy +0 -0
  6. data/bin/addition_steps.tt +15 -0
  7. data/bin/additions_feature.tt +10 -0
  8. data/bin/bdd-legacy +84 -0
  9. data/bin/calculator.tt +17 -0
  10. data/bin/env.tt +53 -0
  11. data/bin/generic_browser_steps.tt +66 -0
  12. data/bin/landing_page_feature.tt +23 -0
  13. data/bin/landing_page_steps.tt +30 -0
  14. data/bin/login_feature.tt +13 -0
  15. data/bin/login_steps.tt +33 -0
  16. data/bin/newgem.tt +2 -0
  17. data/bin/rakefile.tt +5 -0
  18. data/bin/sqlhelper.tt +40 -0
  19. data/bin/sqlserver.tt +118 -0
  20. data/bin/templates/addition_steps.tt +15 -0
  21. data/bin/templates/additions_feature.tt +10 -0
  22. data/bin/templates/calculator.tt +17 -0
  23. data/bin/templates/env.tt +53 -0
  24. data/bin/templates/generic_browser_steps.tt +66 -0
  25. data/bin/templates/landing_page_feature.tt +23 -0
  26. data/bin/templates/landing_page_steps.tt +30 -0
  27. data/bin/templates/login_feature.tt +13 -0
  28. data/bin/templates/login_steps.tt +33 -0
  29. data/bin/templates/newgem.tt +2 -0
  30. data/bin/templates/rakefile.tt +5 -0
  31. data/bin/templates/sqlhelper.tt +40 -0
  32. data/bin/templates/sqlserver.tt +118 -0
  33. data/lib/bdd-legacy.rb +5 -6
  34. data/lib/bdd-legacy/version.rb +5 -0
  35. data/lib/templates/addition_steps.tt +15 -0
  36. data/lib/templates/additions_feature.tt +10 -0
  37. data/lib/templates/calculator.tt +17 -0
  38. data/lib/templates/env.tt +53 -0
  39. data/lib/templates/generic_browser_steps.tt +66 -0
  40. data/lib/templates/landing_page_feature.tt +23 -0
  41. data/lib/templates/landing_page_steps.tt +30 -0
  42. data/lib/templates/login_feature.tt +13 -0
  43. data/lib/templates/login_steps.tt +33 -0
  44. data/lib/templates/newgem.tt +2 -0
  45. data/lib/templates/rakefile.tt +5 -0
  46. data/lib/templates/sqlhelper.tt +40 -0
  47. data/lib/templates/sqlserver.tt +118 -0
  48. metadata +384 -24
  49. data/History.txt +0 -4
  50. data/Manifest.txt +0 -29
  51. data/PostInstall.txt +0 -7
  52. data/README.rdoc +0 -48
  53. data/test/test_bdd-legacy.rb +0 -11
  54. data/test/test_helper.rb +0 -3
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bdd-legacy.gemspec
4
+ gemspec
5
+
6
+
data/Rakefile CHANGED
@@ -1,59 +1,2 @@
1
- require 'psych'
2
- require 'yaml'
3
- # YAML::ENGINE.yamler='psych' if defined?(YAML::ENGINE)
4
- require 'rubygems'
5
- # gem 'hoe' , '>= 2.1.0'
6
- require 'hoe'
7
- require 'fileutils'
8
- require './lib/bdd-legacy'
9
-
10
- Hoe.plugin :newgem
11
- # Hoe.plugin :website
12
- # Hoe.plugin :cucumberfeatures
13
-
14
- # Generate all the Rake tasks
15
- # Run 'rake -T' to see list of generated tasks (from gem root directory)
16
- $hoe = Hoe.spec 'bdd-legacy' do
17
- self.developer 'Wavell Watson', 'wavell.watson@gmail.com'
18
- self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
19
- self.rubyforge_name = self.name # TODO this is default value
20
- #self.extra_deps = [['activesupport','>= 2.0.2']]
21
- self.extra_deps = [['activesupport','>= 2.0.2']]
22
- self.extra_deps = [['bundler', '~> 1.0']]
23
- self.extra_deps = [['fakeweb', '~> 1.3']]
24
- self.extra_deps = [['rake', '>= 0.8']]
25
- self.extra_deps = [['rdoc', '~> 2.5']]
26
- self.extra_deps = [['rspec', '>= 2.1']]
27
- self.extra_deps = [['simplecov', '~> 0.3']]
28
- self.extra_deps = [['thor', '= 0.10.2']]
29
- self.extra_deps = [['aruba', '>= 0.3.4']]
30
- self.extra_deps = [['builder', '>= 2.1.2']]
31
- self.extra_deps = [['capybara', '>= 0.4.1']]
32
- self.extra_deps = [['diff-lcs', '>= 1.1.2']]
33
- self.extra_deps = [['gherkin', '>= 2.3.5']]
34
- self.extra_deps = [['json', '>= 1.4.6']]
35
- self.extra_deps = [['nokogiri', '>= 1.4.4']]
36
- self.extra_deps = [['prawn', '= 0.8.4']]
37
- self.extra_deps = [['prawn-layout', '= 0.8.4']]
38
- self.extra_deps = [['rack-test', '>= 0.5.7']]
39
- self.extra_deps = [['rake', '>= 0.8.7']]
40
- self.extra_deps = [['ramaze', '>= 0']]
41
- self.extra_deps = [['rspec', '>= 2.5.0']]
42
- self.extra_deps = [['simplecov', '>= 0.4.1']]
43
- self.extra_deps = [['sinatra', '>= 1.2.0']]
44
- self.extra_deps = [['spork', '>= 0.8.4']]
45
- self.extra_deps = [['syntax', '>= 1.0.0']]
46
- self.extra_deps = [['term-ansicolor', '>= 1.0.5']]
47
- self.extra_deps = [['webrat', '>= 0.7.3']]
48
- self.extra_deps = [['cucumber', '= 0.10.2']]
49
-
50
-
51
-
52
- end
53
-
54
- # require 'newgem/tasks'
55
- # Dir['tasks/**/*.rake'].each { |t| load t }
56
-
57
- # TODO - want other tests/tasks run by default? Add them to the list
58
- # remove_task :default
59
- # task :default => [:spec, :features]
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,51 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "bdd-legacy/version"
4
+
5
+ Gem::Specification.new do |s|
6
+
7
+ s.add_dependency "rake"
8
+ s.add_dependency "bundler", "~> 1.0"
9
+ s.add_dependency "fakeweb", "~> 1.3"
10
+ s.add_dependency "rake", ">= 0.8"
11
+ s.add_dependency "rdoc", "~> 2.5"
12
+ s.add_dependency "rspec", "~> 2.1"
13
+ s.add_dependency "simplecov", "~> 0.3"
14
+ s.add_dependency "thor", ">= 0.10.2"
15
+ s.add_dependency "aruba", ">= 0.3.4"
16
+ s.add_dependency "builder", ">= 2.1.2"
17
+ s.add_dependency "capybara", ">= 0.4.1"
18
+ s.add_dependency "diff-lcs", ">= 1.1.2"
19
+ s.add_dependency "gherkin", ">= 2.3.5"
20
+ s.add_dependency "json", ">= 1.4.6"
21
+ s.add_dependency "nokogiri", ">= 1.4.4"
22
+ s.add_dependency "prawn", "= 0.8.4"
23
+ s.add_dependency "prawn-layout", "= 0.8.4"
24
+ s.add_dependency "rack-test", ">= 0.5.7"
25
+ s.add_dependency "rake", ">= 0.8.7"
26
+ s.add_dependency "ramaze", ">= 0"
27
+ s.add_dependency "rspec", ">= 2.5.0"
28
+ s.add_dependency "simplecov", ">= 0.4.1"
29
+ s.add_dependency "sinatra", ">= 1.2.0"
30
+ # s.add_dependency "spork", ">= 0.8.4"
31
+ s.add_dependency "syntax", ">= 1.0.0"
32
+ s.add_dependency "term-ansicolor", ">= 1.0.5"
33
+ s.add_dependency "webrat", ">= 0.7.3"
34
+ s.add_dependency "cucumber", "= 0.10.2"
35
+
36
+ s.name = "bdd-legacy"
37
+ s.version = Bdd::Legacy::VERSION
38
+ s.platform = Gem::Platform::RUBY
39
+ s.authors = ["Wavell Watson"]
40
+ s.email = ["wavel.watson@gmail.com"]
41
+ s.homepage = ""
42
+ s.summary = %q{Installs tools needed for bdd testing of legacy applications.}
43
+ s.description = %q{Allows for use of feature driven testing of legacy (especially sql server) applications.}
44
+
45
+ s.rubyforge_project = "bdd-legacy"
46
+
47
+ s.files = `git ls-files`.split("\n")
48
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
49
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
50
+ s.require_paths = ["lib"]
51
+ end
Binary file
@@ -0,0 +1,15 @@
1
+ Before do
2
+ @calculator = Calculator.new
3
+ end
4
+
5
+ Given /^I have entered ([0-9]*) into the calculator$/ do |value|
6
+ @calculator.enter( value.to_i )
7
+ end
8
+
9
+ When /^I press add$/ do
10
+ @calculator.add
11
+ end
12
+
13
+ Then /^the result should be ([0-9]*) on the screen$/ do |value|
14
+ @calculator.screen.should equal( value.to_i )
15
+ end
@@ -0,0 +1,10 @@
1
+ Feature: Addition
2
+ In order to avoid silly mistakes
3
+ As a math idiot
4
+ I want to be told the sum of two numbers
5
+
6
+ Scenario: Add two numbers
7
+ Given I have entered 50 into the calculator
8
+ And I have entered 70 into the calculator
9
+ When I press add
10
+ Then the result should be 120 on the screen
@@ -0,0 +1,84 @@
1
+ #!/user/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'thor/group'
5
+
6
+ class BddLegacy < Thor::Group
7
+ include Thor::Actions
8
+
9
+ # Define arguments and options
10
+ argument :name
11
+ # class_option :test_framework, :default => :test_unit
12
+
13
+ def self.source_root
14
+ File.dirname(__FILE__)
15
+ end
16
+
17
+ def create_rake_file
18
+ template('templates/rakefile.tt', "#{name}/rakefile.rb")
19
+ end
20
+
21
+ def create_example_feature_file
22
+ template('templates/additions_feature.tt', "#{name}/features/additions.feature")
23
+ end
24
+
25
+ def create_login_feature_file
26
+ template('templates/login_feature.tt', "#{name}/features/login.feature")
27
+ end
28
+
29
+ def create_landing_page_feature_file
30
+ template('templates/landing_page_feature.tt', "#{name}/features/landing_page.feature")
31
+ end
32
+
33
+ def create_generic_steps_file
34
+ template('templates/generic_browser_steps.tt', "#{name}/features/step_definitions/generic_browser_steps.rb")
35
+ end
36
+
37
+ def create_login_steps_file
38
+ template('templates/login_steps.tt', "#{name}/features/step_definitions/login_steps.rb")
39
+ end
40
+
41
+ def create_landing_page_steps_file
42
+ template('templates/landing_page_steps.tt', "#{name}/features/step_definitions/landing_page_steps.rb")
43
+ end
44
+
45
+ def create_example_steps_file
46
+ template('templates/addition_steps.tt', "#{name}/features/step_definitions/addition_steps.rb")
47
+ end
48
+
49
+ def create_env_file
50
+ template('templates/env.tt', "#{name}/features/support/env.rb")
51
+ end
52
+
53
+ def create_sqlserver_file
54
+ template('templates/sqlserver.tt', "#{name}/lib/sqlserver.rb")
55
+ end
56
+
57
+ def create_sqlserver_wrapper_file
58
+ template('templates/sqlhelper.tt', "#{name}/lib/sqlhelper.rb")
59
+ end
60
+
61
+ def create_example_code_file
62
+ template('templates/calculator.tt', "#{name}/lib/calculator.rb")
63
+ end
64
+
65
+ # def create_feature_file
66
+ # template('templates/features.tt', "#{name}/lib/#{name}.rb")
67
+ # end
68
+
69
+ # def create_test_file
70
+ # test = options[:test_framework] == "rspec" ? :spec : :test
71
+ # create_file "#{name}/#{test}/#{name}_#{test}.rb"
72
+ # end
73
+
74
+ # def copy_licence
75
+ # if yes?("Use MIT license?")
76
+ # Make a copy of the MITLICENSE file at the source root
77
+ # copy_file "MITLICENSE", "#{name}/MITLICENSE"
78
+ # else
79
+ # say "Shame on you�", :red
80
+ # end
81
+ # end
82
+ end
83
+
84
+ BddLegacy.start
@@ -0,0 +1,17 @@
1
+ class Calculator
2
+ def initialize
3
+ @stack = []
4
+ end
5
+
6
+ def enter( value )
7
+ @stack.push value
8
+ end
9
+
10
+ def screen
11
+ @stack[0]
12
+ end
13
+
14
+ def add
15
+ @stack.push( @stack.pop + @stack.pop )
16
+ end
17
+ end
@@ -0,0 +1,53 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'calculator'
3
+ require 'sqlserver'
4
+ require 'sqlserver_wrapper'
5
+ require 'capybara/cucumber'
6
+
7
+ Capybara.run_server = false
8
+
9
+ Capybara.register_driver :selenium_firefox do |app|
10
+ Capybara::Driver::Selenium.new(app,:browser=>:firefox)
11
+ end
12
+
13
+ Capybara.register_driver :selenium_ie do |app|
14
+ Capybara::Driver::Selenium.new(app,:browser=>:ie)
15
+ end
16
+
17
+ Capybara.default_driver = :selenium_firefox
18
+
19
+ workingDBServerOpt||=
20
+ workingDBOpt||={}
21
+ workingEnvLinkOpt||={}
22
+
23
+ # change to :test or :dev or :local
24
+ $currentOpt=:local
25
+
26
+ #TODO change strings to import from yaml file
27
+ #TODO exclude yaml file from check-in
28
+ # the below server name will either be in the format of 'MYSERVERNAME' or 'MYSERVERNAME\DATABASEINSTANCE'
29
+ # depending on how your sql servr is set up
30
+ workingDBServerOpt={:dev => 'MYDEVDATABASESERVER',
31
+ :test => 'MYTESTDATABASESERVER',
32
+ :local => 'MYLOCALDATABASE'}
33
+ workingDBOpt={:dev => 'devdb',
34
+ :test => 'tstdb',
35
+ :local => 'devdb'}
36
+ # if you have a list of links after logging in with a single sign on account,
37
+ # you may also have a page of separate links for local/dev/test/prod etc
38
+ workingEnvLinkOpt = {:local => 'Welcome',
39
+ :dev => 'Welcome',
40
+ :test => 'Welcome'}
41
+
42
+ $workingDBServer = workingDBServerOpt[$currentOpt]
43
+ $workingDB = workingDBOpt[$currentOpt]
44
+ $workingAppUser='myapplicationusername'
45
+ $workingAppPW='myapplicationpw'
46
+ $workingDBUser='mydatabaseusername'
47
+ $workingDBPW='mydatabasepw'
48
+ # Change this to the domain of your web server. Don't add the full url
49
+ $workingAppHostLink='http://localhost'
50
+ # add the url of your login page
51
+ $workingAppLoginRoute='/welcome/logon.asp'
52
+ $workingEnvLink = workingEnvLinkOpt[$currentOpt]
53
+
@@ -0,0 +1,66 @@
1
+ Before('@firefox') do
2
+
3
+ Capybara.app_host = $workingAppHostLink
4
+
5
+ Capybara.current_driver = :selenium_firefox
6
+ visit $workingAppLoginRoute
7
+
8
+ end
9
+
10
+ After('@firefox') do
11
+ Capybara.use_default_driver
12
+ end
13
+
14
+ Before('@ie') do
15
+ Capybara.app_host = $workingAppHostLink
16
+ Capybara.current_driver = :selenium_ie
17
+ visit $workingAppLoginRoute
18
+ end
19
+
20
+ After('@ie') do
21
+ Capybara.use_default_driver
22
+ end
23
+
24
+ When /^I press "([^"]*)"$/ do |arg1|
25
+ continue = find_by_id arg1
26
+ continue.click
27
+ end
28
+
29
+ #example of making something ie specific
30
+ Given /^I press "([^"]*)" in internet explorer$/ do |arg1|
31
+ mybutton = find_button arg1
32
+ mybutton.click
33
+ end
34
+
35
+ Then /^I select the link "([^"]*)"$/ do |arg1|
36
+ click_link arg1
37
+ end
38
+
39
+
40
+ Then /^I should see "([^"]*)"$/ do |arg1|
41
+ page.should have_content(arg1)
42
+ end
43
+
44
+ Then /^I should not see "([^"]*)"$/ do |arg1|
45
+ page.should_not have_content(arg1)
46
+ end
47
+
48
+ Given /^I evaluate the script for "([^"]*)"$/ do |arg1|
49
+ page.evaluate_script arg1
50
+ end
51
+
52
+ # popup example
53
+ Then /^within the "([^"]*)" window, I should see "([^"]*)"$/ do |arg1, arg2|
54
+ page.within_window(arg1){page.should have_content(arg2)}
55
+ end
56
+
57
+ Then /^within the "([^"]*)" window, I select "([^"]*)"$/ do |arg1, arg2|
58
+ page.within_window(arg1) do
59
+ myelem = page.find(:xpath, "//*[@value='#{arg2}']")
60
+ myelem.click
61
+ end
62
+ end
63
+
64
+ Then /^I should see "([^"]*)" in a field$/ do |arg1|
65
+ page.should have_xpath("//*[@value='#{arg1}']")
66
+ end
@@ -0,0 +1,23 @@
1
+ Feature: Landing Page
2
+ In order to work in my app
3
+ As my app's personnel
4
+ I need to land on the home page
5
+
6
+ @firefox
7
+ Scenario: Land on the landing page page
8
+ Given I am logged in
9
+ Then I should see "My App's greeting"
10
+ And I should see "Something Else that I want to check"
11
+
12
+ @firefox @sql_insert_example
13
+ Scenario: Landing page messages
14
+ Given I am logged in
15
+ And I have a message that says "Heyas" waiting for me
16
+ Then I should see "Heyas"
17
+
18
+ @ie @sql_insert_example
19
+ Scenario: Delete Home page messages
20
+ Given I have a message that says "Heyas" waiting for me
21
+ And I am logged in
22
+ And I press "Remove" in internet explorer
23
+ Then I should not see "Heyas"
@@ -0,0 +1,30 @@
1
+ After('@sql_insert_example') do |s|
2
+ delete_message
3
+ end
4
+
5
+ # This is an example. If you need to do setup and teardown data in your database
6
+ # obviously you'll have your own table replace 'messages' below
7
+ def insert_message()
8
+ insertsql||=[]
9
+ insertsql[0]= <<-eos
10
+ INSERT INTO [Messages]
11
+ ([Message])
12
+ VALUES
13
+ ('Heyas')
14
+ eos
15
+
16
+ insertsql[1]= 'select @@IDENTITY'
17
+
18
+ results, field_lists = SqlServer.helperqueries(insertsql)
19
+
20
+ @insertID = results[1][0][0] #get *first* result from *second* query
21
+ end
22
+
23
+ def delete_message
24
+ result = SqlServer.helperquery("delete from Messages where Messageid = #{@insertID}")
25
+ end
26
+
27
+ Given /^I have a message that says "([^"]*)" waiting for me$/ do |arg1|
28
+ insert_message
29
+ end
30
+
@@ -0,0 +1,13 @@
1
+ Feature: Login
2
+ In order to log into my app
3
+ As my app's personnel
4
+ I want to put in my user name and password
5
+
6
+ @firefox
7
+ Scenario: Log in
8
+ Given I enter my username
9
+ And I enter my password
10
+ When I press Continue
11
+ Then I should see the environment link
12
+ And I select the environment link
13
+