Last active
December 11, 2015 01:58
-
-
Save jccarbonfive/4526691 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Feature: Pig Latin | |
In order to amuse others or conceal the meaning of some text | |
As a user | |
I want to be able to translate from English to Pig Latin | |
Scenario: Translating English to Pig Latin | |
Given a file of English text | |
When I ask to translate it to Pig Latin | |
Then I should see it in Pig Latin |
This file contains hidden or 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
$ cucumber features/pig_latin.feature | |
Using the default profile... | |
UUU | |
1 scenario (1 undefined) | |
3 steps (3 undefined) | |
0m0.002s | |
You can implement step definitions for undefined steps with these snippets: | |
Given /^a file of English text$/ do | |
pending # express the regexp above with the code you wish you had | |
end | |
When /^I ask to translate it to Pig Latin$/ do | |
pending # express the regexp above with the code you wish you had | |
end | |
Then /^I should see it in Pig Latin$/ do | |
pending # express the regexp above with the code you wish you had | |
end |
This file contains hidden or 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
$ cucumber features/pig_latin.feature | |
Using the default profile... | |
.F- | |
(::) failed steps (::) | |
Exit status was 1 but expected it to be 0. Output: | |
/Users/jared/Projects/translator/lib/translator.rb:12:in `initialize': wrong number of arguments (0 for 1) (ArgumentError) |
This file contains hidden or 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
Given /^a file of English text$/ do | |
write_file 'english.txt', <<-EOS | |
The quick brown fox | |
jumps over the lazy dog. | |
EOS | |
end | |
When /^I ask to translate it to Pig Latin$/ do | |
run_simple 'translator english.txt' | |
end | |
Then /^I should see it in Pig Latin$/ do | |
assert_exact_output <<-EOS, all_stdout | |
Ethay ickquay ownbray oxfay | |
umpsjay overay ethay azylay ogday. | |
EOS | |
end |
This file contains hidden or 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
$ cucumber features/pig_latin.feature | |
Using the default profile... | |
.F- | |
(::) failed steps (::) | |
No such file or directory - translator (Aruba::LaunchError) | |
./features/step_definitions/pig_latin_steps.rb:9:in `/^I ask to translate it to Pig Latin$/' | |
features/pig_latin.feature:8:in `When I ask to translate it to Pig Latin' | |
Failing Scenarios: | |
cucumber features/pig_latin.feature:6 # Scenario: Translating English to Pig Latin |
This file contains hidden or 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
$ touch bin/translator | |
$ chmod +x bin/translator | |
$ cucumber features/pig_latin.feature | |
Using the default profile... | |
..F | |
(::) failed steps (::) | |
expected: "Ethay ickquay ownbray oxfay umpsjay overay ethay azylay ogday.\n" | |
got: "" (using ==) |
This file contains hidden or 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
#!/usr/bin/env ruby | |
$: << File.join(File.dirname(__FILE__), '..', 'lib') | |
require 'translator' | |
Translator.pig_latin ARGF, STDOUT |
This file contains hidden or 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
$ cucumber features/pig_latin.feature | |
Using the default profile... | |
.F- | |
(::) failed steps (::) | |
Exit status was 1 but expected it to be 0. Output: | |
/Users/jared/Projects/translator/bin/translator:6:in `<main>': undefined method `pig_latin' for Translator:Module (NoMethodError) |
This file contains hidden or 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
require 'translator/version' | |
module Translator | |
def self.pig_latin(request, response) | |
end | |
end |
This file contains hidden or 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
$ cucumber features/pig_latin.feature | |
Using the default profile... | |
..F | |
(::) failed steps (::) | |
expected: "Ethay ickquay ownbray oxfay umpsjay overay ethay azylay ogday.\n" | |
got: "" (using ==) |
This file contains hidden or 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
require 'translator/version' | |
module Translator | |
def self.pig_latin(request, response) | |
view = PigLatinView.new | |
view.render_on response | |
end | |
class PigLatinView | |
attr_reader :pig_latin | |
def initialize(pig_latin) | |
@pig_latin = pig_latin | |
end | |
def render_on(io) | |
pig_latin.each_line do |line| | |
io.puts line | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment