Skip to content

Commit

Permalink
Merge branch 'release/v0.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
rippinrobr committed Feb 21, 2011
2 parents a0c6252 + 5528200 commit 94eb53e
Show file tree
Hide file tree
Showing 78 changed files with 408 additions and 2,588 deletions.
2 changes: 2 additions & 0 deletions .gitignore
@@ -1 +1,3 @@
*.swp
spec/generator/out/*.cs
out
67 changes: 33 additions & 34 deletions features/cli_invalid_params.feature
Expand Up @@ -12,59 +12,59 @@ Feature: Generator Command Line Interface

Scenarios: no options
| cmd_1 | val_1 | cmd_2 | val_2 | msg_0 | msg_1 | msg_2 |
| | | | | Required Options: | --input-type, -i db\|url\|text | --language, -l ruby\|c_sharp |
| | | | | Required Options: | --input-type, -i url\|text | --language, -l ruby\|c_sharp |

Scenarios: one required option
| cmd_1 | val_1 | cmd_2 | val_2 | msg_0 | msg_1 | msg_2 |
| --input-type | db | -tada | | Required Options: | --input-type, -i db\|url\|text | --language, -l ruby\|c_sharp |
| --i | db | -lala | | Required Options: | --input-type, -i db\|url\|text | --language, -l ruby\|c_sharp |
| --language | c_sharp | -in | | Required Options: | --input-type, -i db\|url\|text | --language, -l ruby\|c_sharp |
| --l | db | -tt | | Required Options: | --input-type, -i db\|url\|text | --language, -l ruby\|c_sharp |
| --input-type | db | -tada | | Required Options: | --input-type, -i url\|text | --language, -l ruby\|c_sharp |
| --i | db | -lala | | Required Options: | --input-type, -i url\|text | --language, -l ruby\|c_sharp |
| --language | c_sharp | -in | | Required Options: | --input-type, -i url\|text | --language, -l ruby\|c_sharp |
| --l | db | -tt | | Required Options: | --input-type, -i url\|text | --language, -l ruby\|c_sharp |

@invalid
Scenario Outline: start generation from command line with valid options that have invalid values
Given I have not started the script
When I start a generation job with "<cmd_1>" "<val_1>" and no "<cmd_2>" "<val_2>"
When I start a generation job with "<cmd_1>" "<val_1>" "<cmd_3>" "<val_3>" and no "<cmd_2>" "<val_2>"
And I should see "<msg_1>"
And I should see "<msg_2>"

Scenarios: required options present but one has an invalid value
| cmd_1 | val_1 | cmd_2 | val_2 | msg_1 | msg_2 |
| --input-type | db | --language | ada | 'ada' is not a supported language | Supported Languages: ruby, c_sharp |
| -i | db | -l | C++ | 'C++' is not a supported language | Supported Languages: ruby, c_sharp |
| --input-type | from | --language | ruby | 'from' is not a supported input type | Supported Input Types: db, url, text |
| -i | blah | --language | ruby | 'blah' is not a supported input type | Supported Input Types: db, url, text |

| cmd_1 | val_1 | cmd_2 | val_2 | msg_1 | msg_2 | cmd_3 | val_3 |
| --input-type | text | --language | ada | 'ada' is not a supported language | Supported Languages: ruby, c_sharp |-sf | ../../spec/generator/data/allstar.txt |
| -i | text | -l | C++ | 'C++' is not a supported language | Supported Languages: ruby, c_sharp | -sf | ../../spec/generator/data/allstar.txt |
| --input-type | from | --language | ruby | 'from' is not a supported input type | Supported Input Types: url, text | | |
| -i | blah | --language | ruby | 'blah' is not a supported input type | Supported Input Types: url, text | | |
@missing-optional
Scenario Outline: Start generation from command line with valid required options and optionals missing their values
Given I have not started the script
When I start a generation job with "<cmd_1>" "<val_1>" "<cmd_2>" "<val_2>" "<cmd_3>" "<val_3>"
When I start a generation job with "<cmd_1>" "<val_1>" "<cmd_2>" "<val_2>" "<cmd_3>" "<val_3>" "<cmd_4>" "<val_4>"
Then I should see "<msg_0>"
And I should see "<msg_1>"

Scenarios: Missing Optional Values
| cmd_1 | val_1 | cmd_2 | val_2 | cmd_3 | val_3 | msg_0 | msg_1 |
| -i | db | -l | ruby | -m | ears | 'ears' is not a supported output option | Supported Output Options: emit, src (default) |
| -i | db | -l | ruby | --model | ears | 'ears' is not a supported output option | Supported Output Options: emit, src (default) |
| cmd_1 | val_1 | cmd_2 | val_2 | cmd_3 | val_3 | cmd_4 | val_4 | msg_0 | msg_1 |
| -i | text | -l | ruby | -m | ears | -sf | ../../spec/generator/data/allstar.txt | 'ears' is not a supported output option | Supported Output Options: src (default) |
| -i | text | -l | ruby | --model | ears | -sf | ../../spec/generator/data/allstar.txt | 'ears' is not a supported output option | Supported Output Options: src (default) |

@cli-missing-values
Scenario Outline: Start generation from command line with valid required options and optionals missing its value (no set of valid options)
Given I have not started the script
When I start a generation job with "<cmd_1>" "<val_1>" "<cmd_2>" "<val_2>" "<cmd_3>" "<val_3>"
When I start a generation job with "<cmd_1>" "<val_1>" "<cmd_2>" "<val_2>" "<cmd_3>" "<val_3>" "<cmd_4>" "<val_4>"
Then I should see "<msg_0>"

@missing-values
Scenarios: Missing Value
| cmd_1 | val_1 | cmd_2 | val_2 | cmd_3 | val_3 | msg_0 |
| -i | db | -l | ruby | -a | | -a \| --assembly requires a name (.NET only) |
| -i | db | -l | ruby | --assembly | | -a \| --assembly requires a name (.NET only) |
| -i | db | -l | ruby | -mn | | -mn \| --model-namespace requires a name |
| -i | db | -l | ruby | --model-namespace | | -mn \| --model-namespace requires a name |
| -i | db | -l | ruby | -mod | | -mod \| --model-output-dir requires a valid directory |
| -i | db | -l | ruby | --model-output-dir | c:\zzzz | -mod \| --model-output-dir requires a valid directory |
| -i | db | -l | ruby | -sod | | -sod \| --service-output-dir requires a valid directory |
| -i | db | -l | ruby | --model-output-dir | | -mod \| --model-output-dir requires a valid directory |
| -i | db | -l | ruby | -sod | | -sod \| --service-output-dir requires a valid directory |
| -i | db | -l | ruby | --service-output-dir | | -sod \| --service-output-dir requires a valid directory |
| -i | db | -l | ruby | -imp | | -imp \| --imports requires at least a name and can be a comma-delimeted list |
| -i | db | -l | ruby | --imports | | -imp \| --imports requires at least a name and can be a comma-delimeted list |
| cmd_1 | val_1 | cmd_2 | val_2 | cmd_3 | val_3 | cmd_4 | val_4 | msg_0 |
| -i | text | -l | ruby | -mn | | -sf | ../../spec/generator/data/allstar.txt | -mn \| --model-namespace requires a name |
| -i | text | -l | ruby | --model-namespace | | -sf | ../../spec/generator/data/allstar.txt | -mn \| --model-namespace requires a name |
| -i | text | -l | ruby | -mod | | -sf | ../../spec/generator/data/allstar.txt | -mod \| --model-output-dir requires a valid directory |
| -i | text | -l | ruby | --model-output-dir | c:\zzzz | -sf | ../../spec/generator/data/allstar.txt | -mod \| --model-output-dir requires a valid directory |
| -i | text | -l | ruby | -sod | | -sf | ../../spec/generator/data/allstar.txt | -sod \| --service-output-dir requires a valid directory|
| -i | text | -l | ruby | --model-output-dir | | -sf | ../../spec/generator/data/allstar.txt | -mod \| --model-output-dir requires a valid directory |
| -i | text | -l | ruby | -sod | | -sf | ../../spec/generator/data/allstar.txt | -sod \| --service-output-dir requires a valid directory|
| -i | text | -l | ruby | --service-output-dir | | -sf | ../../spec/generator/data/allstar.txt | -sod \| --service-output-dir requires a valid directory |
| -i | text | -l | ruby | -imp | | -sf | ../../spec/generator/data/allstar.txt | -imp \| --imports requires at least a name and can be a comma-delimeted list |
| -i | text | -l | ruby | --imports | | -sf | ../../spec/generator/data/allstar.txt | -imp \| --imports requires at least a name and can be a comma-delimeted list |

Scenario Outline: When I pass the quiet command-line option I should see no output from the script
Given I have not started the script
Expand All @@ -80,17 +80,16 @@ Feature: Generator Command Line Interface
Given I have not started the script
When I pass the command "<cmd>"
Then I should see "Required Options:"
And I should see "--input-type, -i db|url|text"
And I should see "--input-type, -i url|text"
And I should see " when using url -url followed by a valid URI to the input is required"
And I should see " when using text --source-file or -sf followed by a path to the input file is required"
And I should see "--language, -l ruby|c_sharp"
And I should see ""
And I should see "Optional:"
And I should see "--assembly, -a name of the output assembly (.NET only)"
And I should see "--service-output-dir, -sod the name of the directory to place the service source"
And I should see "--help, -h displays this message"
And I should see "--imports, -i the name of the libraries to include in the generated source"
And I should see "--model, -m src | emit (.NET only) - indicates how you want the model code created"
And I should see "--imports, -imp the name of the libraries to include in the generated source"
And I should see "--model, -m src - indicates how you want the model code created"
And I should see "--model-output-dir, -mod the name of the directory to place the model source/dll"
And I should see "--quite, -q runs the script without writing output"

Expand Down
4 changes: 2 additions & 2 deletions features/generate_code.feature
Expand Up @@ -25,7 +25,7 @@ Feature: Generate source/assembly from supported data sources
| ruby | ../../spec/generator/data/Allstar_with_headers.txt | true | src | ../spec/generator/out | ../spec/generator/out | allstar_txt.rb | allstar_txt_service.rb |
| ruby | ../../spec/generator/data/Allstar_with_headers.txt | false | src | ../spec/generator/out | | allstar_txt.rb | |
| ruby | ../../spec/generator/data/Allstar_with_headers.txt | true | src | ../spec/generator/out | | allstar_txt.rb | |
| c_sharp | ../../spec/generator/data/allstar.txt | false | src | ../spec/generator/out | ../spec/generator/out | AllstarTxt.cs | AllstartxtService.cs |
| c_sharp | ../../spec/generator/data/Allstar_with_headers.txt | true | src | ../spec/generator/out | ../spec/generator/out | AllstarTxt.cs | AllstartxtService.cs |
| c_sharp | ../../spec/generator/data/allstar.txt | false | src | ../spec/generator/out | ../spec/generator/out | AllstarTxt.cs | AllstarTxtService.cs |
| c_sharp | ../../spec/generator/data/Allstar_with_headers.txt | true | src | ../spec/generator/out | ../spec/generator/out | AllstarTxt.cs | AllstarTxtService.cs |
| c_sharp | ../../spec/generator/data/Allstar_with_headers.txt | false | src | ../spec/generator/out | | AllstarTxt.cs | |
| c_sharp | ../../spec/generator/data/Allstar_with_headers.txt | true | src | ../spec/generator/out | | AllstarTxt.cs | |
12 changes: 12 additions & 0 deletions features/step_definitions/cli_steps.rb
Expand Up @@ -18,12 +18,24 @@
cmd.run args
end

When /^I start a generation job with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" and no "([^"]*)" "([^"]*)"$/ do |cmd1, val1, cmd2, val2, cmd3, val3 |
args = [cmd1, val1, cmd2, val2, cmd3, val3]
cmd = Generator::CmdLine.new(output)
cmd.run args
end

When /^I start a generation job with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$/ do |cmd1, val1, cmd2, val2, cmd3, val3|
args = [cmd1, val1, cmd2, val2, cmd3, val3]
cmd = Generator::CmdLine.new(output)
cmd.run args
end

When /^I start a generation job with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$/ do |cmd1, val1, cmd2, val2, cmd3, val3, cmd4, val4|
args = [cmd1, val1, cmd2, val2, cmd3, val3, cmd4, val4]
cmd = Generator::CmdLine.new(output)
cmd.run args
end

When /^I start a generation job with "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)" "([^"]*)"$/ do |cmd1, val1, cmd2, val2, cmd3|
args = [cmd1, val1, cmd2, val2, cmd3]
cmd = Generator::CmdLine.new(output)
Expand Down
11 changes: 9 additions & 2 deletions features/step_definitions/url_source_step_definitions.rb
Expand Up @@ -6,7 +6,6 @@

When /^I have a model output dir of "([^"]*)"$/ do |mod|
@mod_output_dir = "#{mod}"

@args << "-mod"
@args << mod
end
Expand All @@ -17,14 +16,22 @@
@args << sod
end

When /^I run the generator to create a model and service class in the language "([^"]*)"$/ do |language|
When /^I run the generator to create a model and service class in the language "([^"]*)" with the name "([^"]*)"$/ do |language, service_class_name|
@args << "-l"
@args << language
@args << "-sc"
@args << service_class_name
@args << "-mc"
@args << @model_class_name

cmd = Generator::CmdLine.new(output)
cmd.run @args
end

Then /^I have a model class file with the name "([^"]*)"$/ do |mod_class_name|
@model_class_name = mod_class_name.slice(0...-3)
end

Then /^I should see a model class file with the name "([^"]*)"$/ do |mod_class_name|
File.exists?(File.join(@mod_output_dir, mod_class_name)).should == true
end
Expand Down
11 changes: 7 additions & 4 deletions features/url_source_to_create_code.feature
Expand Up @@ -8,12 +8,15 @@ Feature: Create Code from a URL Source
Scenario Outline: Read data from a URL that returns JSON
Given the source "<url>"
And I have a model output dir of "<model_output_dir>"
And I have a model class file with the name "<model_file_name>"
And I have a service output dir of "<service_output_dir>"
When I run the generator to create a model and service class in the language "<language>"
When I run the generator to create a model and service class in the language "<language>" with the name "<service_class_name>"
Then I should see a model class file with the name "<model_file_name>"
And a service class file with the name "<service_file_name>"

Scenarios: valid options
| url | language | model_file_name | model_output_dir | service_file_name | service_output_dir | model_output |
| http://localhost:8098/riak/era_percentile/1979_AL | ruby | seasonal_era_percentile.rb | /tmp | seasonal_era_percentile_service.rb | /tmp | src |
| http://localhost:8098/riak/era_percentile/1979_AL | c_sharp | SeasonalEraPercentile.cs | /tmp | SeasonalEraPercentileService.cs | /tmp | src |
| url | language | service_class_name | model_file_name | model_output_dir | service_file_name | service_output_dir | model_output |
| http://localhost:8098/riak/era_percentile/1979_AL | ruby | SeasonalEraPercentileService | seasonal_era_percentile.rb | /tmp | seasonal_era_percentile_service.rb | /tmp/ruby/service | src |
| http://localhost:3000/percentiles/era_season/1979_AL | ruby | SeasonalEraPercentileService | seasonal_era_percentile.rb | /tmp | seasonal_era_percentile_service.rb | /tmp/ruby/service | src |
| http://localhost:8098/riak/era_percentile/1979_AL | c_sharp | SeasononalEraPercentileService | SeasonalEraPercentile.cs | /tmp | SeasonalEraPercentileService.cs | /tmp | src |
| http://localhost:3000/percentiles/era_season/1979_AL | c_sharp | SeasononalEraPercentileService | SeasonalEraPercentile.cs | /tmp | SeasonalEraPercentileService.cs | /tmp | src |

0 comments on commit 94eb53e

Please sign in to comment.