Created
September 10, 2009 19:21
-
-
Save darrinholst/184755 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
# This file is loaded before Cucumber is loaded. | |
require 'java' | |
import 'cuke4duke.Table' | |
import 'cuke4duke.internal.language.StepMother' | |
# Workaround to make the java code have access to the same Ruby | |
# interpreter as the one that is used to run this script. | |
# org.jruby.Main uses a different instance than what | |
# org.jruby.Ruby.getGlobalRuntime() returns. It might be considered | |
# a JRuby bug. | |
Java.cuke4duke.internal.JRuby.setRuntime(JRuby.runtime) | |
class java::util::HashMap | |
alias_method :keys, :keySet | |
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
@When("I add a table") | |
public void iAddATable(Table table) { | |
List<List<String>> diffList = new ArrayList<List<String>>(); | |
diffList.add(Arrays.asList("a", "b")); | |
diffList.add(Arrays.asList("1", "2")); | |
table.diffLists(diffList); | |
List<Map<String, String>> hashes = new ArrayList<Map<String, String>>(table.hashes()); | |
Map<String, String> newRow = hashes.get(0); | |
hashes.add(newRow); | |
Map<String, Boolean> hashesMap = new HashMap<String, Boolean>(); | |
hashesMap.put("surplus_row", false); | |
table.diffHashes(hashes, hashesMap); | |
hashes = new ArrayList<Map<String, String>>(); | |
newRow = new HashMap<String, String>(); | |
newRow.put("a", "1"); | |
newRow.put("b", "2"); | |
hashes.add(newRow); | |
table.diffHashes(hashes); | |
} |
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
def ensure_table(table_or_array) #:nodoc: | |
return table_or_array if Table === table_or_array | |
table_or_array = hashes_to_array(table_or_array) if table_or_array[0].respond_to? :keys | |
table_or_array = enumerable_to_array(table_or_array) unless Array == table_or_array[0] | |
Table.new(table_or_array) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment