netzke-core 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/.autotest +1 -1
  2. data/.gitignore +4 -2
  3. data/CHANGELOG.rdoc +37 -15
  4. data/README.rdoc +93 -28
  5. data/Rakefile +5 -7
  6. data/TODO +24 -3
  7. data/app/controllers/netzke_controller.rb +70 -0
  8. data/app/models/netzke_preference.rb +170 -0
  9. data/autotest/discover.rb +2 -3
  10. data/features/actions.feature +13 -0
  11. data/features/basic.feature +7 -0
  12. data/features/client-server.feature +15 -0
  13. data/features/complex_component.feature +18 -0
  14. data/features/component.feature +13 -0
  15. data/features/component_loader.feature +31 -0
  16. data/features/composition.feature +32 -0
  17. data/features/custom_css.feature +17 -0
  18. data/features/file_inclusion.feature +13 -0
  19. data/features/inheritance.feature +19 -0
  20. data/features/persistence.feature +16 -0
  21. data/features/scopes.feature +17 -0
  22. data/features/step_definitions/custom_css_steps.rb +7 -0
  23. data/features/step_definitions/generic_steps.rb +15 -0
  24. data/features/step_definitions/web_steps.rb +219 -0
  25. data/features/support/env.rb +62 -0
  26. data/features/support/paths.rb +45 -0
  27. data/generators/netzke_core/USAGE +3 -3
  28. data/generators/netzke_core/netzke_core_generator.rb +8 -0
  29. data/install.rb +1 -1
  30. data/javascripts/core.js +542 -499
  31. data/lib/generators/migration_helper.rb +32 -0
  32. data/lib/generators/netzke/USAGE +9 -0
  33. data/lib/generators/netzke/core_generator.rb +24 -0
  34. data/lib/netzke/actions.rb +102 -0
  35. data/lib/netzke/base.rb +77 -529
  36. data/lib/netzke/composition.rb +251 -0
  37. data/lib/netzke/configuration.rb +134 -0
  38. data/lib/netzke/core/masquerading.rb +34 -0
  39. data/lib/netzke/core/session.rb +30 -0
  40. data/lib/netzke/core/version.rb +11 -0
  41. data/lib/netzke/core.rb +53 -0
  42. data/lib/netzke/core_ext/array.rb +30 -0
  43. data/lib/netzke/core_ext/hash.rb +84 -0
  44. data/lib/netzke/core_ext/string.rb +26 -0
  45. data/lib/netzke/core_ext/symbol.rb +13 -0
  46. data/lib/netzke/core_ext/time_with_zone.rb +7 -0
  47. data/lib/netzke/core_ext.rb +5 -141
  48. data/lib/netzke/embedding.rb +21 -0
  49. data/lib/netzke/ext_component.rb +25 -0
  50. data/lib/netzke/javascript.rb +248 -0
  51. data/lib/netzke/persistence.rb +118 -0
  52. data/lib/netzke/rails/action_view_ext.rb +103 -0
  53. data/lib/netzke/{controller_extensions.rb → rails/controller_extensions.rb} +7 -2
  54. data/lib/netzke/rails/routes.rb +7 -0
  55. data/lib/netzke/services.rb +68 -0
  56. data/lib/netzke/session.rb +35 -0
  57. data/lib/netzke/stylesheets.rb +52 -0
  58. data/lib/netzke-core.rb +28 -29
  59. data/netzke-core.gemspec +253 -0
  60. data/spec/component/actions_spec.rb +94 -0
  61. data/spec/component/base_spec.rb +25 -0
  62. data/spec/component/composition_spec.rb +132 -0
  63. data/spec/component/javascript_spec.rb +15 -0
  64. data/spec/core_ext_spec.rb +16 -0
  65. data/spec/spec.opt +2 -0
  66. data/spec/spec_helper.rb +35 -0
  67. data/{test/app_root/db/migrate/20081222035855_create_netzke_preferences.rb → templates/core/create_netzke_preferences.rb} +4 -4
  68. data/test/rails_app/.gitignore +4 -0
  69. data/test/rails_app/Gemfile +36 -0
  70. data/test/rails_app/Gemfile.lock +137 -0
  71. data/test/rails_app/README +15 -0
  72. data/test/rails_app/Rakefile +7 -0
  73. data/test/rails_app/app/components/border_layout_panel.rb +4 -0
  74. data/test/rails_app/app/components/component_loader.rb +59 -0
  75. data/test/rails_app/app/components/component_with_actions.rb +58 -0
  76. data/test/rails_app/app/components/component_with_custom_css.rb +8 -0
  77. data/test/rails_app/app/components/component_with_included_js.rb +16 -0
  78. data/test/rails_app/app/components/component_with_session_persistence.rb +25 -0
  79. data/test/rails_app/app/components/custom.css +3 -0
  80. data/test/rails_app/app/components/deprecated/server_caller.rb +20 -0
  81. data/test/rails_app/app/components/extended_component_with_actions.rb +5 -0
  82. data/test/rails_app/app/components/extended_server_caller.rb +18 -0
  83. data/test/rails_app/app/components/included.js +5 -0
  84. data/test/rails_app/app/components/kinda_complex_component/basic_stuff.rb +35 -0
  85. data/test/rails_app/app/components/kinda_complex_component/extra_stuff.rb +16 -0
  86. data/test/rails_app/app/components/kinda_complex_component.rb +7 -0
  87. data/test/rails_app/app/components/loader_of_component_with_custom_css.rb +15 -0
  88. data/test/rails_app/app/components/scoped_components/deep_scoped_components/some_deep_scoped_component.rb +7 -0
  89. data/test/rails_app/app/components/scoped_components/extended_scoped_component.rb +5 -0
  90. data/test/rails_app/app/components/scoped_components/some_scoped_component.rb +5 -0
  91. data/test/rails_app/app/components/server_caller.rb +21 -0
  92. data/test/rails_app/app/components/simple_component.rb +5 -0
  93. data/test/rails_app/app/components/simple_tab_panel.rb +27 -0
  94. data/test/rails_app/app/components/simple_window.rb +3 -0
  95. data/test/rails_app/app/components/some_composite.rb +65 -0
  96. data/test/rails_app/app/components/some_ext_component.rb +8 -0
  97. data/test/{app_root → rails_app}/app/controllers/application_controller.rb +1 -0
  98. data/test/rails_app/app/controllers/components_controller.rb +12 -0
  99. data/test/rails_app/app/controllers/multiple_components_controller.rb +2 -0
  100. data/test/rails_app/app/controllers/welcome_controller.rb +5 -0
  101. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  102. data/test/rails_app/app/views/layouts/application.html.erb +13 -0
  103. data/test/rails_app/app/views/multiple_components/set_one.html.erb +3 -0
  104. data/test/rails_app/config/application.rb +45 -0
  105. data/test/rails_app/config/boot.rb +13 -0
  106. data/test/rails_app/config/database.yml +22 -0
  107. data/test/rails_app/config/environment.rb +6 -0
  108. data/test/rails_app/config/environments/development.rb +22 -0
  109. data/test/rails_app/config/environments/production.rb +49 -0
  110. data/test/rails_app/config/environments/test.rb +35 -0
  111. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  112. data/test/rails_app/config/initializers/inflections.rb +10 -0
  113. data/test/rails_app/config/initializers/mime_types.rb +5 -0
  114. data/test/rails_app/config/initializers/netzke.rb +3 -0
  115. data/test/rails_app/config/initializers/secret_token.rb +7 -0
  116. data/test/rails_app/config/initializers/session_store.rb +8 -0
  117. data/test/rails_app/config/locales/en.yml +5 -0
  118. data/test/rails_app/config/routes.rb +64 -0
  119. data/test/rails_app/config.ru +4 -0
  120. data/test/rails_app/db/development_structure.sql +4 -0
  121. data/{generators/netzke_core/templates/create_netzke_preferences.rb → test/rails_app/db/migrate/20100905214933_create_netzke_preferences.rb} +1 -3
  122. data/test/rails_app/db/schema.rb +24 -0
  123. data/test/rails_app/db/seeds.rb +7 -0
  124. data/test/{app_root/config/environments/in_memory.rb → rails_app/lib/tasks/.gitkeep} +0 -0
  125. data/test/rails_app/public/404.html +26 -0
  126. data/test/rails_app/public/422.html +26 -0
  127. data/test/rails_app/public/500.html +26 -0
  128. data/test/{app_root/config/environments/mysql.rb → rails_app/public/favicon.ico} +0 -0
  129. data/test/rails_app/public/images/rails.png +0 -0
  130. data/test/rails_app/public/robots.txt +5 -0
  131. data/test/rails_app/script/rails +6 -0
  132. data/test/{app_root/config/environments/postgresql.rb → rails_app/vendor/plugins/.gitkeep} +0 -0
  133. data/test/unit/netzke_core_test.rb +74 -75
  134. data/test/unit/netzke_preference_test.rb +2 -2
  135. metadata +176 -48
  136. data/lib/app/controllers/netzke_controller.rb +0 -46
  137. data/lib/app/models/netzke_preference.rb +0 -171
  138. data/lib/netzke/action_view_ext.rb +0 -81
  139. data/lib/netzke/base_js.rb +0 -339
  140. data/lib/netzke/routing.rb +0 -9
  141. data/test/app_root/app/models/role.rb +0 -3
  142. data/test/app_root/app/models/user.rb +0 -3
  143. data/test/app_root/config/boot.rb +0 -115
  144. data/test/app_root/config/database.yml +0 -31
  145. data/test/app_root/config/environment.rb +0 -14
  146. data/test/app_root/config/environments/sqlite.rb +0 -0
  147. data/test/app_root/config/environments/sqlite3.rb +0 -0
  148. data/test/app_root/config/routes.rb +0 -4
  149. data/test/app_root/db/migrate/20090423214303_create_roles.rb +0 -11
  150. data/test/app_root/db/migrate/20090423222114_create_users.rb +0 -12
  151. data/test/app_root/lib/console_with_fixtures.rb +0 -4
  152. data/test/app_root/script/console +0 -7
@@ -0,0 +1,31 @@
1
+ Feature: Component loader
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @selenium
7
+ Scenario: Component loader should be able to load an component
8
+ Given I am on the ComponentLoader test page
9
+ When I press "Load component"
10
+ Then I should see "Inner text"
11
+ And I should see "Simple Component"
12
+
13
+ When I press "Load in window"
14
+ Then I should see "Component loaded in window"
15
+
16
+ @selenium
17
+ Scenario: Component loader should invoke a callback
18
+ Given I am on the ComponentLoader test page
19
+ When I press "Load with feedback"
20
+ Then I should see "Callback invoked!"
21
+
22
+
23
+ @selenium
24
+ Scenario: Component loader should load a window component with another component in it
25
+ Given I am on the ComponentLoader test page
26
+ When I press "Load window with simple component"
27
+ Then I should see "Simple Component Inside Window"
28
+ And I should see "Inner text"
29
+
30
+
31
+
@@ -0,0 +1,32 @@
1
+ Feature: Composition
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @javascript
7
+ Scenario: The SomeComposite component should have 2 components rendered properly
8
+ When I go to the SomeComposite test page
9
+ Then I should see "Server Caller"
10
+ And I should see "Extended Server Caller"
11
+
12
+ @javascript
13
+ Scenario: The components in the SomeComposite should both work properly
14
+ Given I am on the SomeComposite test page
15
+ When I press "Call server" within "#some_composite__center_panel"
16
+ Then I should see "All quiet here on the server"
17
+ And I should not see "All quiet here on the server, shiny weather"
18
+
19
+ When I press "Call server" within "#some_composite__west_panel"
20
+ Then I should see "All quiet here on the server, shiny weather"
21
+
22
+ @javascript
23
+ Scenario: Server should be able to address (deeply) nested components
24
+ Given I am on the SomeComposite test page
25
+ When I press "Update west from server"
26
+ Then I should see "Here's an update for west panel"
27
+
28
+ When I press "Update east south from server"
29
+ Then I should see "Here's an update for south panel in east panel"
30
+
31
+
32
+
@@ -0,0 +1,17 @@
1
+ Feature: Custom css
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @javascript
7
+ Scenario: A component with a hidden body should not show show its body
8
+ When I go to the ComponentWithCustomCss test page
9
+ Then I should see "ComponentWithCustomCss"
10
+ But the body of ComponentWithCustomCss component should not be invisible
11
+
12
+ @javascript
13
+ Scenario: A dynamically loaded component with a hidden body should not display its body
14
+ When I go to the LoaderOfComponentWithCustomCss test page
15
+ And I press "Load ComponentWithCustomCss"
16
+ Then I should see "ComponentWithCustomCss"
17
+ But the body of LoaderOfComponentWithCustomCss/ComponentWithCustomCss component should not be invisible
@@ -0,0 +1,13 @@
1
+ Feature: File inclusion
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @javascript
7
+ Scenario: A component with external JS file included
8
+ Given I am on the ComponentWithIncludedJs test page
9
+ When I press "Print message"
10
+ Then I should see "Some message shown in the body"
11
+
12
+
13
+
@@ -0,0 +1,19 @@
1
+ Feature: Inheritance
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @javascript
7
+ Scenario: Inherited component should successfully call parent methods in Ruby and JavaScript
8
+ When I go to the ExtendedServerCaller test page
9
+ Then I should see "Extended Server Caller"
10
+ When I press "Call server"
11
+ Then I should see "All quiet here on the server, shiny weather"
12
+ And I should see "Added by extended Server Caller"
13
+
14
+ @javascript
15
+ Scenario: Extended scoped components should render
16
+ Given I am on the ScopedComponents::ExtendedScopedComponent test page
17
+ Then I should see "Extended Scoped Component Title"
18
+ And I should see "Extended Scoped Component HTML"
19
+
@@ -0,0 +1,16 @@
1
+ Feature: Persistence
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @javascript
7
+ Scenario: The component with persistence should be able to store and retrieve a persistence setting
8
+ When I go to the ComponentWithSessionPersistence test page
9
+ Then I should see "No Title (yet!)"
10
+
11
+ When I press "Tell server to store new title"
12
+ And I go to the ComponentWithSessionPersistence test page
13
+ Then I should see "New Title!"
14
+
15
+
16
+
@@ -0,0 +1,17 @@
1
+ Feature: Scopes
2
+ In order to value
3
+ As a role
4
+ I want feature
5
+
6
+ @javascript
7
+ Scenario: Scoped components should render
8
+ Given I am on the ScopedComponents::SomeScopedComponent test page
9
+ Then I should see "Some Scoped Component Title"
10
+ And I should see "Some Scoped Component HTML"
11
+
12
+ When I go to the ScopedComponents::DeepScopedComponents::SomeDeepScopedComponent test page
13
+ Then I should see "Some Deep Scoped Component Title"
14
+ And I should see "Some Deep Scoped Component HTML"
15
+
16
+
17
+
@@ -0,0 +1,7 @@
1
+ Then /^the body of (.+) component should not be invisible$/ do |component|
2
+ component_id = component.split("/").map{ |klass| klass.underscore }.join("__")
3
+ page.wait_until{ page.evaluate_script("!Ext.Ajax.isLoading()") }
4
+ page.execute_script(<<-JS).should == false
5
+ return Ext.getCmp('#{component_id}').body.isVisible();
6
+ JS
7
+ end
@@ -0,0 +1,15 @@
1
+ Then /^Netzke should be initialized$/ do
2
+ Netzke::Base.should be
3
+ end
4
+
5
+ When /^I execute "([^\"]*)"$/ do |script|
6
+ page.driver.browser.execute_script(script)
7
+ end
8
+
9
+ Then /^button "([^\"]*)" should be disabled$/ do |arg1|
10
+ pending
11
+ end
12
+
13
+ When /^I sleep 1 second$/ do
14
+ sleep 1
15
+ end
@@ -0,0 +1,219 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+
8
+ require 'uri'
9
+ require 'cgi'
10
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
11
+
12
+ module WithinHelpers
13
+ def with_scope(locator)
14
+ locator ? within(locator) { yield } : yield
15
+ end
16
+ end
17
+ World(WithinHelpers)
18
+
19
+ Given /^(?:|I )am on (.+)$/ do |page_name|
20
+ visit path_to(page_name)
21
+ end
22
+
23
+ When /^(?:|I )go to (.+)$/ do |page_name|
24
+ visit path_to(page_name)
25
+ end
26
+
27
+ When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
28
+ with_scope(selector) do
29
+ click_button(button)
30
+ end
31
+ end
32
+
33
+ When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
34
+ with_scope(selector) do
35
+ click_link(link)
36
+ end
37
+ end
38
+
39
+ When /^(?:|I )fill in "([^"]*)" with "([^"]*)"(?: within "([^"]*)")?$/ do |field, value, selector|
40
+ with_scope(selector) do
41
+ fill_in(field, :with => value)
42
+ end
43
+ end
44
+
45
+ When /^(?:|I )fill in "([^"]*)" for "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
46
+ with_scope(selector) do
47
+ fill_in(field, :with => value)
48
+ end
49
+ end
50
+
51
+ # Use this to fill in an entire form with data from a table. Example:
52
+ #
53
+ # When I fill in the following:
54
+ # | Account Number | 5002 |
55
+ # | Expiry date | 2009-11-01 |
56
+ # | Note | Nice guy |
57
+ # | Wants Email? | |
58
+ #
59
+ # TODO: Add support for checkbox, select og option
60
+ # based on naming conventions.
61
+ #
62
+ When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
63
+ with_scope(selector) do
64
+ fields.rows_hash.each do |name, value|
65
+ When %{I fill in "#{name}" with "#{value}"}
66
+ end
67
+ end
68
+ end
69
+
70
+ When /^(?:|I )select "([^"]*)" from "([^"]*)"(?: within "([^"]*)")?$/ do |value, field, selector|
71
+ with_scope(selector) do
72
+ select(value, :from => field)
73
+ end
74
+ end
75
+
76
+ When /^(?:|I )check "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
77
+ with_scope(selector) do
78
+ check(field)
79
+ end
80
+ end
81
+
82
+ When /^(?:|I )uncheck "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
83
+ with_scope(selector) do
84
+ uncheck(field)
85
+ end
86
+ end
87
+
88
+ When /^(?:|I )choose "([^"]*)"(?: within "([^"]*)")?$/ do |field, selector|
89
+ with_scope(selector) do
90
+ choose(field)
91
+ end
92
+ end
93
+
94
+ When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"(?: within "([^"]*)")?$/ do |path, field, selector|
95
+ with_scope(selector) do
96
+ attach_file(field, path)
97
+ end
98
+ end
99
+
100
+ Then /^(?:|I )should see JSON:$/ do |expected_json|
101
+ require 'json'
102
+ expected = JSON.pretty_generate(JSON.parse(expected_json))
103
+ actual = JSON.pretty_generate(JSON.parse(response.body))
104
+ expected.should == actual
105
+ end
106
+
107
+ Then /^(?:|I )should see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
108
+ with_scope(selector) do
109
+ if page.respond_to? :should
110
+ page.should have_content(text)
111
+ else
112
+ assert page.has_content?(text)
113
+ end
114
+ end
115
+ end
116
+
117
+ Then /^(?:|I )should see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
118
+ regexp = Regexp.new(regexp)
119
+ with_scope(selector) do
120
+ if page.respond_to? :should
121
+ page.should have_xpath('//*', :text => regexp)
122
+ else
123
+ assert page.has_xpath?('//*', :text => regexp)
124
+ end
125
+ end
126
+ end
127
+
128
+ Then /^(?:|I )should not see "([^"]*)"(?: within "([^"]*)")?$/ do |text, selector|
129
+ with_scope(selector) do
130
+ if page.respond_to? :should
131
+ page.should have_no_content(text)
132
+ else
133
+ assert page.has_no_content?(text)
134
+ end
135
+ end
136
+ end
137
+
138
+ Then /^(?:|I )should not see \/([^\/]*)\/(?: within "([^"]*)")?$/ do |regexp, selector|
139
+ regexp = Regexp.new(regexp)
140
+ with_scope(selector) do
141
+ if page.respond_to? :should
142
+ page.should have_no_xpath('//*', :text => regexp)
143
+ else
144
+ assert page.has_no_xpath?('//*', :text => regexp)
145
+ end
146
+ end
147
+ end
148
+
149
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should contain "([^"]*)"$/ do |field, selector, value|
150
+ with_scope(selector) do
151
+ field = find_field(field)
152
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
153
+ if field_value.respond_to? :should
154
+ field_value.should =~ /#{value}/
155
+ else
156
+ assert_match(/#{value}/, field_value)
157
+ end
158
+ end
159
+ end
160
+
161
+ Then /^the "([^"]*)" field(?: within "([^"]*)")? should not contain "([^"]*)"$/ do |field, selector, value|
162
+ with_scope(selector) do
163
+ field = find_field(field)
164
+ field_value = (field.tag_name == 'textarea') ? field.text : field.value
165
+ if field_value.respond_to? :should_not
166
+ field_value.should_not =~ /#{value}/
167
+ else
168
+ assert_no_match(/#{value}/, field_value)
169
+ end
170
+ end
171
+ end
172
+
173
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should be checked$/ do |label, selector|
174
+ with_scope(selector) do
175
+ field_checked = find_field(label)['checked']
176
+ if field_checked.respond_to? :should
177
+ field_checked.should be_true
178
+ else
179
+ assert field_checked
180
+ end
181
+ end
182
+ end
183
+
184
+ Then /^the "([^"]*)" checkbox(?: within "([^"]*)")? should not be checked$/ do |label, selector|
185
+ with_scope(selector) do
186
+ field_checked = find_field(label)['checked']
187
+ if field_checked.respond_to? :should
188
+ field_checked.should be_false
189
+ else
190
+ assert !field_checked
191
+ end
192
+ end
193
+ end
194
+
195
+ Then /^(?:|I )should be on (.+)$/ do |page_name|
196
+ current_path = URI.parse(current_url).path
197
+ if current_path.respond_to? :should
198
+ current_path.should == path_to(page_name)
199
+ else
200
+ assert_equal path_to(page_name), current_path
201
+ end
202
+ end
203
+
204
+ Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
205
+ query = URI.parse(current_url).query
206
+ actual_params = query ? CGI.parse(query) : {}
207
+ expected_params = {}
208
+ expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
209
+
210
+ if actual_params.respond_to? :should
211
+ actual_params.should == expected_params
212
+ else
213
+ assert_equal expected_params, actual_params
214
+ end
215
+ end
216
+
217
+ Then /^show me the page$/ do
218
+ save_and_open_page
219
+ end
@@ -0,0 +1,62 @@
1
+ # IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
2
+ # It is recommended to regenerate this file in the future when you upgrade to a
3
+ # newer version of cucumber-rails. Consider adding your own code to a new file
4
+ # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5
+ # files.
6
+
7
+ ENV["RAILS_ENV"] ||= "test"
8
+ # require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
9
+ require File.expand_path(File.dirname(__FILE__) + '/../../test/rails_app/config/environment')
10
+ # require File.expand_path(File.dirname(__FILE__) + '/../../lib/netzke-core')
11
+
12
+
13
+ require 'cucumber/formatter/unicode' # Remove this line if you don't want Cucumber Unicode support
14
+ require 'cucumber/rails/rspec'
15
+ require 'cucumber/rails/world'
16
+ require 'cucumber/rails/active_record'
17
+ require 'cucumber/web/tableish'
18
+
19
+ require 'capybara/rails'
20
+ require 'capybara/cucumber'
21
+ require 'capybara/session'
22
+ require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
23
+
24
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
25
+ # order to ease the transition to Capybara we set the default here. If you'd
26
+ # prefer to use XPath just remove this line and adjust any selectors in your
27
+ # steps to use the XPath syntax.
28
+ Capybara.default_selector = :css
29
+
30
+ # If you set this to false, any error raised from within your app will bubble
31
+ # up to your step definition and out to cucumber unless you catch it somewhere
32
+ # on the way. You can make Rails rescue errors and render error pages on a
33
+ # per-scenario basis by tagging a scenario or feature with the @allow-rescue tag.
34
+ #
35
+ # If you set this to true, Rails will rescue all errors and render error
36
+ # pages, more or less in the same way your application would behave in the
37
+ # default production environment. It's not recommended to do this for all
38
+ # of your scenarios, as this makes it hard to discover errors in your application.
39
+ ActionController::Base.allow_rescue = false
40
+
41
+ # If you set this to true, each scenario will run in a database transaction.
42
+ # You can still turn off transactions on a per-scenario basis, simply tagging
43
+ # a feature or scenario with the @no-txn tag. If you are using Capybara,
44
+ # tagging with @culerity or @javascript will also turn transactions off.
45
+ #
46
+ # If you set this to false, transactions will be off for all scenarios,
47
+ # regardless of whether you use @no-txn or not.
48
+ #
49
+ # Beware that turning transactions off will leave data in your database
50
+ # after each scenario, which can lead to hard-to-debug failures in
51
+ # subsequent scenarios. If you do this, we recommend you create a Before
52
+ # block that will explicitly put your database in a known state.
53
+ Cucumber::Rails::World.use_transactional_fixtures = true
54
+ # How to clean your database when transactions are turned off. See
55
+ # http://github.com/bmabey/database_cleaner for more info.
56
+ if defined?(ActiveRecord::Base)
57
+ begin
58
+ require 'database_cleaner'
59
+ DatabaseCleaner.strategy = :truncation
60
+ rescue LoadError => ignore_if_database_cleaner_not_present
61
+ end
62
+ end
@@ -0,0 +1,45 @@
1
+ module NavigationHelpers
2
+ # Maps a name to a path. Used by the
3
+ #
4
+ # When /^I go to (.+)$/ do |page_name|
5
+ #
6
+ # step definition in web_steps.rb
7
+ #
8
+ def path_to(page_name)
9
+ case page_name
10
+
11
+ when /the home\s?page/
12
+ '/'
13
+
14
+ # Add more mappings here.
15
+ # Here is an example that pulls values out of the Regexp:
16
+ #
17
+ # when /^(.*)'s profile page$/i
18
+ # user_profile_path(User.find_by_login($1))
19
+
20
+ when /the simple panel page/
21
+ '/panel/simple'
22
+
23
+ when /the server caller page/
24
+ '/panel/server_caller'
25
+
26
+ when /the component loader page/
27
+ '/panel/component_loader'
28
+
29
+ when /the (.*) test page/
30
+ components_path(:component => $1)
31
+
32
+ else
33
+ begin
34
+ page_name =~ /the (.*) page/
35
+ path_components = $1.split(/\s+/)
36
+ self.send(path_components.push('path').join('_').to_sym)
37
+ rescue Object => e
38
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
39
+ "Now, go and add a mapping in #{__FILE__}"
40
+ end
41
+ end
42
+ end
43
+ end
44
+
45
+ World(NavigationHelpers)
@@ -1,8 +1,8 @@
1
1
  Description:
2
- Explain the generator
2
+ Generates a netzke preferences migration
3
3
 
4
4
  Example:
5
- ./script/generate netzke-core Thing
5
+ ./script/generate netzke-core
6
6
 
7
7
  This will create:
8
- what/will/it/create
8
+ A netzke preferences migration
@@ -7,4 +7,12 @@ class NetzkeCoreGenerator < Rails::Generator::Base
7
7
  }, :migration_file_name => "create_netzke_preferences"
8
8
  end
9
9
  end
10
+
11
+ def self.gem_root
12
+ File.expand_path('../../../', __FILE__)
13
+ end
14
+
15
+ def self.source_root
16
+ File.join(gem_root, 'templates', 'core')
17
+ end
10
18
  end
data/install.rb CHANGED
@@ -1 +1 @@
1
- # Install hook code here
1
+ # Install hook code here