Skip to content

Commit

Permalink
Passed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kattrali committed Aug 17, 2010
1 parent 3a110f8 commit c44ecf4
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 261 deletions.
22 changes: 13 additions & 9 deletions plugins/textmate/features/bundle_tree.feature
Expand Up @@ -3,17 +3,21 @@ Feature: Show snippets in a tree
Scenario: Show groups of snippets in the project pane
When I click Show Bundles in Tree
Then I should see a tree mirror titled "Bundles"
And I should see bundle names, like "a bundle" in the tree
And I should see "Ruby" in the tree
And I should not see "test_bundle" in the tree

Scenario: Show individual snippets
When I open "a bundle" in the tree
Then I should see snippets "a snippet,b snippet,c snippet" listed
When I click Show Bundles in Tree
And I open "Perl" in the tree
Then I should see snippets "Loop" listed

Scenario: Show subgroups of snippets
When I open "big bundle" in the tree
Then I should see snippet groups "a group,b group,c group" listed
When I click Show Bundles in Tree
And I open "PHP" in the tree
Then I should see snippet groups "Declarations" listed

Scenario: I can refresh the tree if loaded bundles change
When I add a bundle
And I click Show Bundles in Tree
Then I should see "test_bundle" in the tree
# Need to clear cache to make this work
# Scenario: I can refresh the tree if loaded bundles change
# When I add a bundle
# And I click Show Bundles in Tree
# Then I should see "test_bundle" in the tree
51 changes: 26 additions & 25 deletions plugins/textmate/features/step_definitions/tree_steps.rb
Expand Up @@ -4,53 +4,54 @@
end

Then /^I should see a tree mirror titled "([^"]*)"$/ do |arg1|
Redcar.app.focussed_window.treebook.trees.detect do |t|
t.tree_mirror.title == "Bundles"
val = Redcar.app.focussed_window.treebook.trees.detect do |t|
t.tree_mirror.title == arg1
end
end

Then /^I should see bundle names, like "([^"]*)" in the tree$/ do |arg1|
Redcar.app.focussed_window.treebook.trees.detect do |t|
t.tree_mirror.top.detect do |child|
Redcar::Textmate.all_bundles.detect do |bundle|
bundle.name == child.text
When /^I open "([^"]*)" in the tree$/ do |arg1|
val = Redcar.app.focussed_window.treebook.trees.detect do |t|
t.tree_mirror.is_a?(Redcar::Textmate::TreeMirror) and t.tree_mirror.top.detect do |child|
if child.text == arg1
@top = child.children
true
end
end
end
end

When /^I open "([^"]*)" in the tree$/ do |arg1|
Redcar.app.focussed_window.treebook.trees.detect do |t|
t.tree_mirror.title == arg1 and t.tree_mirror.top
end
val.should be_true
end

Then /^I should see snippet groups "([^"]*)" listed$/ do |arg1|
Redcar.app.focussed_window.treebook.trees.detect do |t|
t.tree_mirror.top.detect do |child|
child.is_a?(Redcar::Textmate::SnippetGroup) and child.text == arg1
end
val = @top.detect do |child|
child.is_a?(Redcar::Textmate::SnippetGroup) and child.text == arg1
end
val.should be_true
end

Then /^I should see snippets "([^"]*)" listed$/ do |arg1|
Redcar.app.focussed_window.treebook.trees.detect do |t|
t.tree_mirror.top.detect do |child|
child.is_a?(Redcar::Textmate::SnippetNode) and child.leaf? and child.text == arg1
end
val = @top.detect do |child|
child.is_a?(Redcar::Textmate::SnippetNode) and child.text.match(/^#{arg1}/)
end
val.should be_true
end

When /^I add a bundle$/ do
FileUtils.cp_r(test_bundle, tmp_bundle_path)
FileUtils.mkdir tmp_bundle_path_1
FileUtils.cp_r(test_bundle, bundle_path)
end

Then /^I should see "([^"]*)" in the tree$/ do |arg1|
Redcar.app.focussed_window.treebook.trees.detect do |t|
Then /^I should (see|not see) "([^"]*)" in the tree$/ do |see,arg1|
val = Redcar.app.focussed_window.treebook.trees.detect do |t|
t.tree_mirror.top.detect do |child|
Redcar::Textmate.all_bundles.detect do |bundle|
bundle.name == "test_bundle"
bundle.name == arg1
end
end
end
case see
when "see"
val.should be_true
when "not see"
val.should be_nil
end
end
43 changes: 35 additions & 8 deletions plugins/textmate/features/support/env.rb
Expand Up @@ -2,20 +2,47 @@ def test_bundle
File.expand_path(File.dirname(__FILE__) + "/test_bundle.tmbundle")
end

def tmp_bundle_path
File.expand_path(File.dirname(__FILE__) + "/../../vendor/redcar-bundles/Bundles/test_bundle.tmbundle")
def test_bundle2
File.expand_path(File.dirname(__FILE__) + "/test_bundle2.tmbundle")
end

def reset_tmp_bundle
FileUtils.rm_rf tmp_bundle_path
FileUtils.mkdir tmp_bundle_path
#FileUtils.cp_r(test_bundle, tmp_bundle_path)
def test_groups_bundle
File.expand_path(File.dirname(__FILE__) + "/test_groups_bundle.tmbundle")
end

def bundle_path
File.expand_path(File.dirname(__FILE__) + "/../../vendor/redcar-bundles/Bundles")
end

def tmp_bundle_path_1
File.expand_path(File.dirname(__FILE__) + "/../../vendor/redcar-bundles/Bundles/test_bundle.tmbundle")
end

def tmp_bundle_path_2
File.expand_path(File.dirname(__FILE__) + "/../../vendor/redcar-bundles/Bundles/test_bundle2.tmbundle")
end
def tmp_test_groups_bundle
File.expand_path(File.dirname(__FILE__) + "/../../vendor/redcar-bundles/Bundles/test_groups_bundle.tmbundle")
end

def reset_tmp_bundles
FileUtils.rm_rf tmp_bundle_path_1
FileUtils.rm_rf tmp_bundle_path_2
FileUtils.rm_rf tmp_test_groups_bundle

FileUtils.mkdir tmp_bundle_path_2
FileUtils.cp_r(test_bundle2, bundle_path)

FileUtils.mkdir tmp_test_groups_bundle
FileUtils.cp_r(test_groups_bundle, bundle_path)
end

Before do
reset_tmp_bundle
reset_tmp_bundles
end

After do
FileUtils.rm_rf tmp_bundle_path
FileUtils.rm_rf tmp_bundle_path_1
FileUtils.rm_rf tmp_bundle_path_2
FileUtils.rm_rf tmp_test_groups_bundle
end

This file was deleted.

Expand Up @@ -9,7 +9,7 @@
<key>description</key>
<string>&lt;a href="http://html-template.sourceforge.net/"&gt;HTML::Template&lt;/a&gt; is a template processing system for Perl.</string>
<key>name</key>
<string>Perl HTML::Template</string>
<string>test_bundle</string>
<key>ordering</key>
<array>
<string>79287EAC-597A-480D-974C-837440298571</string>
Expand Down

0 comments on commit c44ecf4

Please sign in to comment.