-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added commandline tests with cucumber and aruba
- Loading branch information
Showing
17 changed files
with
140 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
source 'http://rubygems.org' | ||
gem 'recursive-open-struct' | ||
group :test do | ||
group :test do | ||
gem "mixItRuby" , path: "." | ||
gem 'guard-rspec' | ||
gem 'guard-cucumber' | ||
gem 'guard' | ||
gem 'rspec' | ||
gem 'cucumber' | ||
gem 'aruba' | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,40 @@ | ||
#!/usr/bin/env ruby | ||
require 'mixer' | ||
require 'optparse' | ||
|
||
|
||
require "mixer" | ||
require "json" | ||
options = {} | ||
optparse = OptionParser.new do|opts| | ||
opts.banner = "Usage: mixit [-o outputfile -i inputfile -t templatefile]" | ||
opts.on( '-i', '--input FILE', 'json Inputfile' ) do|p| | ||
opts.on( '-i', '--input FILE', 'json inputfile' ) do|p| | ||
options[:inputfile] = p | ||
end | ||
|
||
opts.on( '-o', '--output FILE', 'mixed outputfile' ) do|p| | ||
options[:outputfile] = p | ||
end | ||
|
||
|
||
opts.on( '-t', '--template directory', 'place where the templates are' ) do|p| | ||
opts.on( '-t', '--templates DIR', 'place where the templates are' ) do|p| | ||
options[:templateDir] = p | ||
end | ||
|
||
end.parse! | ||
|
||
|
||
mixer = MIX::Mixer.new | ||
|
||
input_string = IO.read(options["inputfile"]) | ||
outputfile = File.new(options["outputfile"]) | ||
inputdata = JSON.pars(input_string) | ||
|
||
|
||
|
||
input_filename= options[:inputfile] | ||
if !input_filename | ||
STDOUT.puts "no inputfile given" | ||
exit(1) | ||
end | ||
|
||
inputfile = options[:inputfile] | ||
path = File.dirname(inputfile) | ||
input_string = IO.read(inputfile) | ||
outputfile = options[:outputfile] || File.basename(inputfile,".*") + ".out" | ||
outputfile = File.join(path,outputfile) | ||
inputdata = JSON.parse(input_string, {:symbolize_names => true}) | ||
templateDir = options[:templateDir] | ||
mixer.mixItRuby(inputdata, templateDir) | ||
mixer.writeResult2File(outputfile) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,2 @@ | ||
require 'capybara/cucumber' | ||
require 'capybara/poltergeist' | ||
@processingWorkingDir=File.dirname(__FILE__) | ||
@processingWorkDir=@processingWorkingDir+"/../processing/vert/" | ||
#Start the two servers : | ||
# | ||
#Processing Server : | ||
# @t1 = fork do | ||
# system("cd #{@processingWorkDir} && rvm use jruby-1.7.1@masha_gems && vertx run #{@processingWorkDir}server_app.js -conf test.json") | ||
# end | ||
# sleep(5) | ||
# @siteServerPath=File.dirname(__FILE__) + "/../site/bin/" # This is a Serverinstance which is not deployed. It simulates the server of the provider | ||
# @t2 = fork do | ||
# system("cd #{@siteServerPath} && ruby pageServer.rb -p 4568") | ||
# end | ||
# sleep(5) | ||
if ENV['IN_BROWSER'] | ||
# On demand: non-headless tests via Selenium/WebDriver | ||
# To run the scenarios in browser (default: Firefox), use the following command line: | ||
# IN_BROWSER=true bundle exec cucumber | ||
# or (to have a pause of 1 second between each step): | ||
# IN_BROWSER=true PAUSE=1 bundle exec cucumber | ||
Capybara.default_driver = :selenium | ||
AfterStep do | ||
sleep (ENV['PAUSE'] || 0).to_i | ||
end | ||
else | ||
# DEFAULT: headless tests with poltergeist/PhantomJS | ||
Capybara.register_driver :poltergeist do |app| | ||
Capybara::Poltergeist::Driver.new( | ||
app, | ||
window_size: [1280, 1024]#, | ||
#debug: true | ||
) | ||
end | ||
Capybara.default_driver = :poltergeist | ||
Capybara.javascript_driver = :poltergeist | ||
end | ||
at_exit do | ||
|
||
puts @t1 | ||
puts @t2 | ||
|
||
|
||
if @t1 | ||
puts "processserver killed" | ||
Process.kill("HUP",@t1) | ||
sleep(10) | ||
end | ||
if @t2 | ||
puts "pageServer killed" | ||
Process.kill("HUP",@t2) | ||
sleep(10) | ||
end | ||
puts "bye" | ||
end | ||
$LOAD_PATH << File.join(File.dirname(__FILE__),'../lib') | ||
require "aruba/cucumber" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,32 @@ | ||
Feature:Commandline functionality | ||
|
||
A User should be able to call a command to get a mixed outputfile | ||
@announce | ||
Scenario: CommandlineCall should give an error, when no inputfile | ||
When I run `mixit` | ||
Then the output should contain "no inputfile given" | ||
|
||
|
||
|
||
Scenario: CommandlineCall | ||
Given a empty testenvironment with one erb file and one data file | ||
When I enter "mix dataInput dataoutput templateDir" | ||
Then I should get a file with the name dataInput and the suffix mixed | ||
|
||
|
||
Scenario: exit status of 0 | ||
When I run `mixit` | ||
Then the exit status should be 1 | ||
|
||
|
||
|
||
@announce | ||
Scenario: Generatining an outputfile | ||
Given the testdatafile is in the aruba filespace | ||
When I run `mixit -i testdata/testdata.json` | ||
When I run `cat testdata/testdata.out` | ||
Then the stdout should contain "Bond" | ||
|
||
|
||
@announce | ||
Scenario: mixIt should also run from another templatepath | ||
Given the testdatafile is in the aruba filespace | ||
Given the templatefiles are in the aruby filespace | ||
When I run `mixit -i testdata/testdata.json -t tmp/aruba` | ||
And I run `cat testdata/testdata.out` | ||
Then the stdout should contain "Bond" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
|
||
|
||
Given(/^the testdatafile is in the aruba filespace$/) do | ||
`mkdir tmp/aruba/testdata && cp testdata/testdata.json tmp/aruba/testdata` | ||
end | ||
|
||
|
||
Given(/^a empty testenvironment with one erb file and one data file$/) do | ||
###just do something | ||
if File.exists?("features/testDir/output/test.txt") | ||
system("rm /features/testDir/output/*") | ||
end | ||
end | ||
Given(/^the templatefiles are in the aruby filespace$/) do | ||
`mkdir tmp/aruba/templates && cp templates/* tmp/aruba/templates` | ||
end | ||
|
||
|
||
When(/^I enter "(.*?)"$/) do |arg1| | ||
system(arg1) | ||
end | ||
|
||
Then(/^I should get a file with the name dataInput and the suffix mixed$/) do | ||
File.exists?("features/testDir/output/test.txt").should==true | ||
end |
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
Gem::Specification.new do |s| | ||
s.name = 'mixItRuby' | ||
s.version = '0.0.0' | ||
s.date = '2014-05-29' | ||
s.summary = "MitItRuby!" | ||
s.description = "A gem for mixing a nested json structure in erb files" | ||
s.authors = ["Erhard Karger"] | ||
s.email = '[email protected]' | ||
s.files = ["lib/mixer.rb"] | ||
s.homepage = "www.kargers.org" | ||
'http://rubygems.org/gems/mixItRuby' | ||
s.license = 'MIT' | ||
s.name = 'mixItRuby' | ||
s.version = '0.0.0' | ||
s.date = '2014-05-29' | ||
s.summary = "MitItRuby!" | ||
s.description = "A gem for mixing a nested json structure in erb files" | ||
s.authors = ["Erhard Karger"] | ||
s.email = '[email protected]' | ||
s.homepage = 'http://rubygems.org/gems/mixItRuby' | ||
s.license = 'MIT' | ||
git_files = `git ls-files`.split("\n") rescue '' | ||
s.files = git_files | ||
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.