magicspec 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.project +18 -0
- data/Gemfile +16 -0
- data/LICENSE.txt +20 -0
- data/README.md +95 -0
- data/README.rdoc +38 -0
- data/Rakefile +44 -0
- data/bin/magicspec +6 -0
- data/lib/magicspec/cli.rb +73 -0
- data/lib/magicspec/errors.rb +6 -0
- data/lib/magicspec/ext/string.rb +11 -0
- data/lib/magicspec/generators/magicspec/.rspec +1 -0
- data/lib/magicspec/generators/magicspec/app/matchers/.empty_directory +5 -0
- data/lib/magicspec/generators/magicspec/app/pages/yale/yale_page.rb.tt +15 -0
- data/lib/magicspec/generators/magicspec/app/pages/yale/yale_search_result_page.rb.tt +9 -0
- data/lib/magicspec/generators/magicspec/app/reports/.empty_directory +5 -0
- data/lib/magicspec/generators/magicspec/app/reports/screenshots/.empty_directory +0 -0
- data/lib/magicspec/generators/magicspec/app/spec/shared/login.rb +11 -0
- data/lib/magicspec/generators/magicspec/app/spec/spec_helper.rb.tt +114 -0
- data/lib/magicspec/generators/magicspec/app/spec/support/formatters/dry_run_formatter.rb +13 -0
- data/lib/magicspec/generators/magicspec/app/spec/support/formatters/html_override.rb +360 -0
- data/lib/magicspec/generators/magicspec/app/spec/support/formatters/magicspec_formatter.rb +46 -0
- data/lib/magicspec/generators/magicspec/app/spec/support/matchers/custom_matcher.rb +7 -0
- data/lib/magicspec/generators/magicspec/app/spec/support/matchers/email_matcher.rb +1 -0
- data/lib/magicspec/generators/magicspec/app/spec/support/matchers/file_matcher.rb +12 -0
- data/lib/magicspec/generators/magicspec/app/spec/yale/yale_example_spec.rb +34 -0
- data/lib/magicspec/generators/magicspec/app/test_data/baidu.yml +4 -0
- data/lib/magicspec/generators/magicspec/app/test_data/login_user.yml +4 -0
- data/lib/magicspec/generators/magicspec/bin/console +7 -0
- data/lib/magicspec/generators/magicspec/bin/console.bat +6 -0
- data/lib/magicspec/generators/magicspec/bin/setup.rb.tt +12 -0
- data/lib/magicspec/generators/magicspec/config/config.yml +6 -0
- data/lib/magicspec/generators/magicspec/config/magicspec_formatter.rb +47 -0
- data/lib/magicspec/generators/magicspec/config/override.rb +351 -0
- data/lib/magicspec/magicspec_config.rb +21 -0
- data/lib/magicspec/magicspec_initializer.rb +33 -0
- data/lib/magicspec/page_override.rb +5 -0
- data/lib/magicspec/templates/browser_spec_template.rb.tt +22 -0
- data/lib/magicspec/templates/mobile_template.rb.tt +15 -0
- data/lib/magicspec/templates/plain_template.rb.tt +22 -0
- data/lib/magicspec/templates/template_page.rb.tt +11 -0
- data/lib/magicspec/templates/web_service_template.rb.tt +18 -0
- data/lib/magicspec/watir_browser.rb +7 -0
- data/lib/magicspec.rb +8 -0
- data/magicspec.gemspec +120 -0
- data/spec/app/pages/components/footer.rb +3 -0
- data/spec/app/pages/components/sub/sub_footer.rb +3 -0
- data/spec/app/pages/module1/module1_page.rb +6 -0
- data/spec/app/pages/module1/sub_test_page.rb +4 -0
- data/spec/app/pages/test_navigator.rb +4 -0
- data/spec/app/pages/test_page.rb +4 -0
- data/spec/config/config.yml +3 -0
- data/spec/config/wrong_config.yml +5 -0
- data/spec/lazy_initializer_spec.rb +28 -0
- data/spec/lazy_navigator_spec.rb +36 -0
- data/spec/lazy_page_spec.rb +44 -0
- data/spec/magicspec_config_spec.rb +28 -0
- data/spec/pages/components/footer.rb +2 -0
- data/spec/pages/test_page.rb +5 -0
- data/spec/spec_helper.rb +20 -0
- data/spec/string_spec.rb +10 -0
- metadata +206 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e2df9b3bf3a9cc936884a18d5c4579f71bc9f7cd
|
4
|
+
data.tar.gz: 0df845bfe35aa96f75cad2121a6fad9e659dbd9a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a692b8b2b60302f1859f14011e402e2558856e586af815da3758e2e71f8d3c70b7c39106222b308f6cc9c0c1a0e18b347cbcdfb8314bcaea222fc563376b352
|
7
|
+
data.tar.gz: e13c0167086a27b19ae03c96ca0e3311aead09044ed86609e76cc4bae3073c452d8d0c76861ea607bbf53987ae840ad786eb2aa98c124d05f99271f4003c6224
|
data/.document
ADDED
data/.project
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<projectDescription>
|
3
|
+
<name>lazyman</name>
|
4
|
+
<comment></comment>
|
5
|
+
<projects>
|
6
|
+
</projects>
|
7
|
+
<buildSpec>
|
8
|
+
<buildCommand>
|
9
|
+
<name>com.aptana.ide.core.unifiedBuilder</name>
|
10
|
+
<arguments>
|
11
|
+
</arguments>
|
12
|
+
</buildCommand>
|
13
|
+
</buildSpec>
|
14
|
+
<natures>
|
15
|
+
<nature>com.aptana.ruby.core.rubynature</nature>
|
16
|
+
<nature>com.aptana.projects.webnature</nature>
|
17
|
+
</natures>
|
18
|
+
</projectDescription>
|
data/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
|
5
|
+
# Add dependencies to develop your gem here.
|
6
|
+
# Include everything needed to run rake, tests, features, etc.
|
7
|
+
gem "page-object"
|
8
|
+
gem "thor"
|
9
|
+
|
10
|
+
group :development do
|
11
|
+
gem "rdoc"
|
12
|
+
gem "bundler"
|
13
|
+
gem "jeweler"
|
14
|
+
gem "page-object"
|
15
|
+
gem "thor"
|
16
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 easonhan
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
magic_spec
|
2
|
+
=====================
|
3
|
+
|
4
|
+
A simple web automation test framework using [selenium-webdriver](http://docs.seleniumhq.org/projects/webdriver/),[watir-webdriver](https://github.com/watir/watir-webdriver),[page-object](https://github.com/cheezy/page-object) and [rspec](https://github.com/rspec/rspec).
|
5
|
+
|
6
|
+
This should get you up and running magically.
|
7
|
+
|
8
|
+
Install lazyman
|
9
|
+
---------------
|
10
|
+
Install lazyman from rubygems
|
11
|
+
|
12
|
+
gem install lazyman
|
13
|
+
|
14
|
+
Or clone from github, build the gem and install
|
15
|
+
|
16
|
+
If you have any issue when install lazyman, install the gems below:
|
17
|
+
|
18
|
+
gem install thor
|
19
|
+
|
20
|
+
|
21
|
+
Create a lazyman project
|
22
|
+
------------------------
|
23
|
+
Open a command console and type just like below:
|
24
|
+
|
25
|
+
lazyman new your_project_name
|
26
|
+
|
27
|
+
Run Examples
|
28
|
+
------------
|
29
|
+
|
30
|
+
Lazyman contains some examples that explain how to use lazyman writing your own test cases.
|
31
|
+
|
32
|
+
By default, lazyman runs examples using chrome browser, so make sure you installed google chrome and according [chrome driver](http://code.google.com/p/chromedriver/downloads/list)
|
33
|
+
|
34
|
+
Using following command to make everything running.
|
35
|
+
|
36
|
+
cd your_project_name
|
37
|
+
lazyman go
|
38
|
+
|
39
|
+
Lazyman go command supports all the rspec options and it is the recommend way.
|
40
|
+
|
41
|
+
You can find test report in app/reports folder. It is a html file with current time stamp.
|
42
|
+
|
43
|
+
Using Console
|
44
|
+
-------------
|
45
|
+
You can use eat console to debug your test in irb.
|
46
|
+
|
47
|
+
cd your_project_name
|
48
|
+
lazyman c
|
49
|
+
|
50
|
+
Lazyman will load all your pages, start irb and open browser which was defined in your config.yml.
|
51
|
+
|
52
|
+
Then you can use $navi variable the same way in your test file.
|
53
|
+
|
54
|
+
p = $navi.goto_baidu_page
|
55
|
+
p.keyword="watir-webdriver"
|
56
|
+
p.search_element.click
|
57
|
+
|
58
|
+
You can type everything just like you are write a text case.
|
59
|
+
|
60
|
+
Understand lazyman project structure
|
61
|
+
------------------------------------
|
62
|
+
|
63
|
+
Lazyman project has a clean and simple structure.
|
64
|
+
|
65
|
+
* app: holds your test codes;
|
66
|
+
* config: where your config file placed;
|
67
|
+
|
68
|
+
* app->pages: puts all your pages files here;
|
69
|
+
* app->pages->components: sometimes,there are some html element that could be reused more than once, define a component, place the file here and you can include your components in your pages.
|
70
|
+
|
71
|
+
* app->spec: holds your testcase files;
|
72
|
+
* app->spec->shared: Image that, you are testing a system which need to login before any actions, so you want to define a login function which can be called from your cases. Define reused cases here.
|
73
|
+
|
74
|
+
* app->reports: the fold holds your test reports.
|
75
|
+
|
76
|
+
* app->support->matchers: defind your owner rspec matchers here.
|
77
|
+
|
78
|
+
|
79
|
+
Contributing to lazyman
|
80
|
+
-----------------------
|
81
|
+
|
82
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
83
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
84
|
+
* Fork the project.
|
85
|
+
* Start a feature/bugfix branch.
|
86
|
+
* Commit and push until you are happy with your contribution.
|
87
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
88
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
89
|
+
|
90
|
+
Copyright
|
91
|
+
---------
|
92
|
+
|
93
|
+
Copyright (c) 2013 easonhan. See LICENSE.txt for
|
94
|
+
further details.
|
95
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
lazyman
|
2
|
+
=====================
|
3
|
+
|
4
|
+
A simple web automation test framework using [selenium-webdriver](http://docs.seleniumhq.org/projects/webdriver/),[watir-webdriver](https://github.com/watir/watir-webdriver),[page-object](https://github.com/cheezy/page-object) and rspec(https://github.com/rspec/rspec).
|
5
|
+
|
6
|
+
Now lazyman only tested in windows, other platformes are going to be tested soon.
|
7
|
+
|
8
|
+
Install lazyman
|
9
|
+
---------------
|
10
|
+
Install lazyman from rubygems
|
11
|
+
|
12
|
+
gem install lazyman
|
13
|
+
|
14
|
+
Or clone from github
|
15
|
+
|
16
|
+
Create a lazyman project
|
17
|
+
------------------------
|
18
|
+
In windows, open command console and type just like below:
|
19
|
+
|
20
|
+
lazyman new your_project_name
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
== Contributing to lazyman
|
25
|
+
|
26
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
27
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
28
|
+
* Fork the project.
|
29
|
+
* Start a feature/bugfix branch.
|
30
|
+
* Commit and push until you are happy with your contribution.
|
31
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
32
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
33
|
+
|
34
|
+
== Copyright
|
35
|
+
|
36
|
+
Copyright (c) 2013 easonhan. See LICENSE.txt for
|
37
|
+
further details.
|
38
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "magicspec"
|
18
|
+
gem.homepage = "https://github.com/dmfranko/magic_spec"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A simple web automation test framework}
|
21
|
+
gem.description = %Q{A test framework using watir-webdriver rspec and page-object}
|
22
|
+
gem.email = "dan.franko@yale.edu"
|
23
|
+
gem.homepage = 'https://github.com/dmfranko/magic_spec'
|
24
|
+
gem.authors = ["easonhan,dmfranko"]
|
25
|
+
# dependencies defined in Gemfile
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rdoc/task'
|
37
|
+
Rake::RDocTask.new do |rdoc|
|
38
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
+
|
40
|
+
rdoc.rdoc_dir = 'rdoc'
|
41
|
+
rdoc.title = "magicspec #{version}"
|
42
|
+
rdoc.rdoc_files.include('README*')
|
43
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
+
end
|
data/bin/magicspec
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Magicspec
|
4
|
+
class CLI < Thor
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
File.join File.dirname(__FILE__)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.source_paths
|
12
|
+
puts source_root
|
13
|
+
[source_root + '/generators', source_root + '/templates']
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'new NAME', 'create a magicspec project'
|
17
|
+
def new(name)
|
18
|
+
@name = name
|
19
|
+
if name
|
20
|
+
directory 'magicspec', name
|
21
|
+
else
|
22
|
+
say 'no app name'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
desc 'run ', 'run test case with rspec'
|
27
|
+
def start
|
28
|
+
ARGV.shift
|
29
|
+
puts "rspec #{ARGV.join('')}" if $debug
|
30
|
+
#run "LOCAL=true rspec #{ARGV.join('')}"
|
31
|
+
run "LOCAL=true rspec"
|
32
|
+
end
|
33
|
+
|
34
|
+
# Might just dump the console
|
35
|
+
desc 'c ', 'open magicspec console'
|
36
|
+
def c
|
37
|
+
run 'bin/console'
|
38
|
+
end
|
39
|
+
|
40
|
+
desc "new_page NAME", "create a new page"
|
41
|
+
def new_page(name)
|
42
|
+
@name = name
|
43
|
+
template('template_page.rb.tt', "./app/pages/#{name}_page.rb")
|
44
|
+
end
|
45
|
+
|
46
|
+
|
47
|
+
desc "new_spec NAME ", "create a new spec"
|
48
|
+
option :type,:required => false
|
49
|
+
method_option :type,
|
50
|
+
:default => "browser",
|
51
|
+
:aliases => "-t",
|
52
|
+
:desc => "which type of template to create [browser,webService,plain]."
|
53
|
+
|
54
|
+
# Could probably stand to DRY this up a bit, but it works fine.
|
55
|
+
def new_spec(name)
|
56
|
+
@name = name
|
57
|
+
case options["type"].downcase
|
58
|
+
when "browser"
|
59
|
+
template('browser_spec_template.rb.tt', "./app/spec/#{name}_spec.rb")
|
60
|
+
when "webservice"
|
61
|
+
template('web_service_template.rb.tt', "./app/spec/#{name}_spec.rb")
|
62
|
+
when "plain"
|
63
|
+
template('plain_template.rb.tt', "./app/spec/#{name}_spec.rb")
|
64
|
+
when "mobile"
|
65
|
+
template('mobile_template.rb.tt', "./app/spec/#{name}_spec.rb")
|
66
|
+
else
|
67
|
+
say "Sorry :(. I'm not sure what you're trying to do?"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end #CLI
|
71
|
+
CLI.start
|
72
|
+
end #Lazyman
|
73
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
--default-path=./app/spec
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
class YalePage
|
3
|
+
include PageObject
|
4
|
+
page_url 'www.yale.edu'
|
5
|
+
|
6
|
+
table 'news', id: 'news'
|
7
|
+
text_field 'search', name: 'q'
|
8
|
+
button 'searchButton', id: 'edit-submit'
|
9
|
+
|
10
|
+
def search_for kw
|
11
|
+
self.search = kw
|
12
|
+
self.search_element.send_keys :enter
|
13
|
+
turn_to YaleSearchResultPage
|
14
|
+
end
|
15
|
+
end
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
shared_examples 'login' do
|
2
|
+
it 'should login' do
|
3
|
+
data = test_data('login_user')
|
4
|
+
user = data['demo']['name']
|
5
|
+
password = data['demo']['password']
|
6
|
+
|
7
|
+
login_page = $navi.goto_login_page
|
8
|
+
my_view_page = login_page.login user, password
|
9
|
+
my_view_page.report_issue?.should be_true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,114 @@
|
|
1
|
+
ENV.delete 'HTTP_PROXY' if ENV['HTTP_PROXY']
|
2
|
+
require 'erb'
|
3
|
+
require 'psych'
|
4
|
+
require 'rspec-rerun'
|
5
|
+
require 'fuubar'
|
6
|
+
require 'magicspec'
|
7
|
+
require 'active_record'
|
8
|
+
require 'net/http'
|
9
|
+
require 'byebug'
|
10
|
+
require 'rest_client'
|
11
|
+
require 'sauce_whisk'
|
12
|
+
require 'watir-browser-factory'
|
13
|
+
require 'rspec-rest-formatter'
|
14
|
+
|
15
|
+
Dir["./app/spec/support/**/*.rb"].sort.each {|f|require f}
|
16
|
+
|
17
|
+
SAUCE_USERNAME = ""
|
18
|
+
SAUCE_ACCESS_KEY = ""
|
19
|
+
|
20
|
+
class Hash
|
21
|
+
def find_all_values_for(key)
|
22
|
+
result = []
|
23
|
+
result << self[key]
|
24
|
+
self.values.each do |hash_value|
|
25
|
+
values = [hash_value] unless hash_value.is_a? Array
|
26
|
+
if values
|
27
|
+
values.each do |value|
|
28
|
+
result += value.find_all_values_for(key) if value.is_a? Hash
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
result.compact
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
<% require 'active_support/all' %>
|
37
|
+
Magicspec::Initializer.new(File.expand_path(File.join('.')), '<%= @name %>')
|
38
|
+
$:.unshift(File.expand_path File.join('.'))
|
39
|
+
|
40
|
+
# Make sure all of our supporting files are loaded
|
41
|
+
Dir["./app/spec/support/**/*.rb"].sort.each {|f|require f}
|
42
|
+
|
43
|
+
RSpec.configure do |c|
|
44
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
45
|
+
c.run_all_when_everything_filtered = true
|
46
|
+
c.alias_example_to :test_case
|
47
|
+
c.alias_it_should_behave_like_to :include_shared
|
48
|
+
|
49
|
+
c.color_enabled = true
|
50
|
+
|
51
|
+
# Force expect syntax
|
52
|
+
c.expect_with :rspec do |e|
|
53
|
+
e.syntax = :expect
|
54
|
+
end
|
55
|
+
|
56
|
+
if ENV['REFRESH']
|
57
|
+
# Set everyting to run
|
58
|
+
c.filter_run
|
59
|
+
|
60
|
+
# User the dry run formatter
|
61
|
+
c.add_formatter("DryRunFormatter")
|
62
|
+
#c.add_formatter("documentation")
|
63
|
+
# Make everything fail
|
64
|
+
|
65
|
+
c.before(:all) do
|
66
|
+
raise 'Fail each test immediately'
|
67
|
+
end
|
68
|
+
|
69
|
+
# We'll collect our keys into an array
|
70
|
+
$KEYS = []
|
71
|
+
c.before(:each) do |x|
|
72
|
+
keys = x.example.metadata.each_key.to_a
|
73
|
+
keys.each do |k|
|
74
|
+
$KEYS.push k
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
c.after(:suite) {
|
79
|
+
# Strip out any rspec keys/tags to get just the ones we've added
|
80
|
+
d = [:description_args,:caller,:execution_result,:example_group,:example_group_block]
|
81
|
+
d.each {|k| $KEYS.delete(k)
|
82
|
+
}
|
83
|
+
}
|
84
|
+
else
|
85
|
+
# Add formatters
|
86
|
+
c.add_formatter("Fuubar")
|
87
|
+
#c.add_formatter("Lazyman::LazymanFormatter")
|
88
|
+
# Check to make sure we can reach our service
|
89
|
+
c.add_formatter("RestFormatter")
|
90
|
+
|
91
|
+
# If there is a tag value and no one has passed a filter to rspec use the config
|
92
|
+
if $config.tags && c.inclusion_filter.empty?
|
93
|
+
unless($config.tags.empty?)
|
94
|
+
tags = case
|
95
|
+
when String
|
96
|
+
$config.tags.lazy_to_hash
|
97
|
+
when Hash
|
98
|
+
$config.tags
|
99
|
+
end #case
|
100
|
+
c.filter_run tags
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_data file
|
106
|
+
content = ''
|
107
|
+
file_path = File.expand_path(File.join('.', 'app', 'test_data', "#{file}.yml"))
|
108
|
+
raise "Can not find #{file}.yml" unless File.exists?(file_path)
|
109
|
+
File.open(file_path, 'r') do |handle|
|
110
|
+
content = handle.read
|
111
|
+
end
|
112
|
+
Psych.load ERB.new(content).result(binding)
|
113
|
+
end
|
114
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'rspec/core/formatters/documentation_formatter'
|
2
|
+
|
3
|
+
class DryRunFormatter < RSpec::Core::Formatters::DocumentationFormatter
|
4
|
+
def initialize(output)
|
5
|
+
output = File.new(File.expand_path(File.join('.', 'app', 'reports', "#{Time.now.strftime("%Y%m%d_%H%M%S")}-dry.txt")), 'w')
|
6
|
+
super(output)
|
7
|
+
@group_level = 0
|
8
|
+
end
|
9
|
+
|
10
|
+
def example_failed(example)
|
11
|
+
example_passed(example)
|
12
|
+
end
|
13
|
+
end
|