From 4ea2a4c830c7cfab08838a524693099fa99052d8 Mon Sep 17 00:00:00 2001 From: andyw8 Date: Sat, 6 Nov 2010 12:35:38 +0000 Subject: [PATCH] First commit --- Manifest | 10 + README.rdoc | 8 + Rakefile | 13 + TODO | 11 + lib/generators/cucumber_scaffold/USAGE | 31 ++ .../cucumber_scaffold_feature_generator.rb | 192 ++++++++++++ .../cucumber_scaffold_install_generator.rb | 13 + .../templates/feature.feature | 282 ++++++++++++++++++ .../templates/shared/web_steps_additional.rb | 40 +++ .../cucumber_scaffold/templates/steps.rb | 40 +++ pkg/cucumber_scaffold-0.1.0.gem | Bin 0 -> 8704 bytes pkg/cucumber_scaffold-0.1.0.tar.gz | Bin 0 -> 6331 bytes pkg/cucumber_scaffold-0.1.0/Manifest | 10 + pkg/cucumber_scaffold-0.1.0/README.rdoc | 8 + pkg/cucumber_scaffold-0.1.0/Rakefile | 13 + pkg/cucumber_scaffold-0.1.0/TODO | 11 + .../cucumber_scaffold.gemspec | 30 ++ .../lib/generators/cucumber_scaffold/USAGE | 31 ++ .../cucumber_scaffold_feature_generator.rb | 192 ++++++++++++ .../cucumber_scaffold_install_generator.rb | 13 + .../templates/feature.feature | 282 ++++++++++++++++++ .../templates/shared/web_steps_additional.rb | 40 +++ .../cucumber_scaffold/templates/steps.rb | 40 +++ 23 files changed, 1310 insertions(+) create mode 100644 Manifest create mode 100644 README.rdoc create mode 100644 Rakefile create mode 100644 TODO create mode 100644 lib/generators/cucumber_scaffold/USAGE create mode 100644 lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb create mode 100644 lib/generators/cucumber_scaffold/cucumber_scaffold_install_generator.rb create mode 100644 lib/generators/cucumber_scaffold/templates/feature.feature create mode 100644 lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb create mode 100644 lib/generators/cucumber_scaffold/templates/steps.rb create mode 100644 pkg/cucumber_scaffold-0.1.0.gem create mode 100644 pkg/cucumber_scaffold-0.1.0.tar.gz create mode 100644 pkg/cucumber_scaffold-0.1.0/Manifest create mode 100644 pkg/cucumber_scaffold-0.1.0/README.rdoc create mode 100644 pkg/cucumber_scaffold-0.1.0/Rakefile create mode 100644 pkg/cucumber_scaffold-0.1.0/TODO create mode 100644 pkg/cucumber_scaffold-0.1.0/cucumber_scaffold.gemspec create mode 100644 pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/USAGE create mode 100644 pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb create mode 100644 pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/cucumber_scaffold_install_generator.rb create mode 100644 pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/feature.feature create mode 100644 pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb create mode 100644 pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/steps.rb diff --git a/Manifest b/Manifest new file mode 100644 index 0000000..2f299c4 --- /dev/null +++ b/Manifest @@ -0,0 +1,10 @@ +Manifest +README.rdoc +Rakefile +TODO +lib/generators/cucumber_scaffold/USAGE +lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb +lib/generators/cucumber_scaffold/cucumber_scaffold_install_generator.rb +lib/generators/cucumber_scaffold/templates/feature.feature +lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb +lib/generators/cucumber_scaffold/templates/steps.rb diff --git a/README.rdoc b/README.rdoc new file mode 100644 index 0000000..c67ee94 --- /dev/null +++ b/README.rdoc @@ -0,0 +1,8 @@ +== Installation + + $ gem install cucumber_scaffold + +== Usage + + $ rails generate nifty_cucumber_install + $ rails generate nifty_cucumber_feature Post name:string body:text \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..077e126 --- /dev/null +++ b/Rakefile @@ -0,0 +1,13 @@ +require 'rubygems' +require 'rake' +require 'echoe' + +Echoe.new('cucumber_scaffold', '0.1.0') do |p| + p.description = "Generate scaffolding for Cucumber features and steps definitions" + p.url = "http://github.com/andyw8/cucumber_scaffold" + p.author = "Andy Waite" + p.email = "andy@andywaite.com" + p.development_dependencies = [] +end + +Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext } \ No newline at end of file diff --git a/TODO b/TODO new file mode 100644 index 0000000..d541ff2 --- /dev/null +++ b/TODO @@ -0,0 +1,11 @@ +* Test with webrat as well as capybara +* Test with Rails 2.x +* Test with Formtastic +* Test with inherited_resources +* Test with with inherited_resources_views +* Add support for booleans (checkboxes) +* Add support for date/time fields +* Add support for belongs_to associations +* Test for model names containing more than one word (e.g. DocumentCategory) +* Add automated test suite +* Prevent excess whitespace in generated files \ No newline at end of file diff --git a/lib/generators/cucumber_scaffold/USAGE b/lib/generators/cucumber_scaffold/USAGE new file mode 100644 index 0000000..4fbb0a8 --- /dev/null +++ b/lib/generators/cucumber_scaffold/USAGE @@ -0,0 +1,31 @@ +Description: + Scaffolding for Cucumber features + +Example: + + For first time use: + + rails generate cucumber_scaffold_install + + This will create: + features/shared/web_steps_additional.rb + + Then for a feature: + + rails generate cucumber_scaffold_feature Post title:string body:text + + This will create: + features/manage_posts.rb + features/step_definitions/post_steps.rb + + and will modify: + features/support/paths.rb + +Options: + + --nifty + Generate features and steps which match the scaffold created by nifty-generators + ( https://github.com/ryanb/nifty-generators ) + + --tags + Include Cucumbers @tags matching each scenario to one or more controller actions \ No newline at end of file diff --git a/lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb b/lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb new file mode 100644 index 0000000..e3aea4a --- /dev/null +++ b/lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb @@ -0,0 +1,192 @@ +class CucumberScaffoldFeatureGenerator < Rails::Generators::NamedBase + + INDENT = " " + LINE_BREAK_WITH_INDENT = "\n#{INDENT}" + LINE_BREAK_WITH_INDENT_COMMENTED = "\n#{INDENT}# " + + argument :model_name, :type => :string + + source_root File.expand_path('../templates', __FILE__) + + def initialize(args, *options) + # copied setup from + # http://apidock.com/rails/Rails/Generators/NamedBase/new/class + args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen? + super + assign_names!(self.name) + parse_attributes! if respond_to?(:attributes) + args.shift + @args = args + end + + def do_it + @attributes = [] + @args.each do |param_pair| + name, type = param_pair.split(':') + @attributes << { name => type } + end + + template('feature.feature', "features/manage_#{plural}.feature") + template('steps.rb', "features/step_definitions/#{singular}_steps.rb") + + extra_paths = < :string + + source_root File.expand_path('../templates', __FILE__) + + def do_it + + template('shared/web_steps_additional.rb', 'features/step_definitions/web_steps_additional.rb') + + end + +end \ No newline at end of file diff --git a/lib/generators/cucumber_scaffold/templates/feature.feature b/lib/generators/cucumber_scaffold/templates/feature.feature new file mode 100644 index 0000000..e8220ba --- /dev/null +++ b/lib/generators/cucumber_scaffold/templates/feature.feature @@ -0,0 +1,282 @@ +<%= generated_by %> +<% +update_button_title = 'Update' +create_button_title = 'Create' + +if nifty? + successful_update_message = "Successfully updated #{singular}." + successful_create_message = "Successfully created #{singular}." + successful_destroy_message = "Successfully destroyed #{singular}." + new_heading = "New #{singular_title}" + edit_heading = "Edit #{singular_title}" + index_heading = plural_title + show_heading = singular_title + new_title = new_heading + edit_title = edit_heading + index_title = index_heading + show_title = show_heading + back_to_all = 'Back to List' + problems_intro = 'Correct the following errors and try again.' +else + problems_intro = + successful_update_message = "#{singular_title} was successfully updated." + successful_create_message = "#{singular_title} was successfully created." + index_heading = "Listing #{plural}" + edit_heading = "Editing #{singular}" + new_heading = "New #{singular}" + back_to_all = 'Back' + problems_intro = "prohibited this post from being saved:" +end + +pending_explanation_1 = "You should use this scenario as the basis for scenarios involving ActiveRecord validations, or delete it if it's not required" +pending_explanation_2 = "[You should add checks for specific errors here. It may be appropriate to add extra scenarios.]" +-%> + +Feature: Manage <%= plural_title %> + In order to [goal] + [stakeholder] + wants [behaviour] + + <%= tags('@index') %> + Scenario: List all <%= plural %> + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the <%= plural %> page + Then I should see the following <%= plural %>: + <%= html_table_header_row %> + <%= html_table_row(1) %> + <%= html_table_row(2) %> + <%= html_table_row(3) %> + + <%= tags('@show') %> + Scenario: View a <%= singular %> + Given the following <%= singular %>: + <%= activerecord_single_resource %> + When I go to the page for that <%= singular %> + Then I should see the following <%= singular %>: + <%= html_single_resource %> + + <%= tags('@edit') %> + Scenario: Edit a <%= singular %> + Given the following <%= singular %>: + <%= activerecord_single_resource %> + When I go to the edit page for that <%= singular %> + Then I should see the following form field values: + <%= form_single_resource %> + + <%= tags('@index @destroy') %> + Scenario: Delete a <%= singular %> via the index page + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the <%= plural %> page + And I click "Destroy" in the 2nd row + Then I should see the following <%= plural %>: + <%= html_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(3) %> + And I should be on the <%= plural %> page + <% if successful_destroy_message %> + And I should see "<%= successful_destroy_message %>" + <% end -%> + + <% if nifty? %> + <%= tags('@show @destroy @index') %> + Scenario: Delete a <%= singular %> via the show page + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the page for the 2nd post + And I follow "Destroy" + Then I should see the following <%= plural %>: + <%= html_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(3) %> + And I should be on the <%= plural %> page + And I should see "<%= successful_destroy_message %>" + <% end -%> + + <%= tags('@new @create @show') %> + Scenario: Create a new <%= singular %> + Pending + # Given I am on the new <%= singular %> page + # When I fill in the following: + # <%= form_single_resource_commented %> + # And I press "<%= create_button_title %>" + # Then I should see "<%= successful_create_message %>" + # And I should see the following <%= singular %>: + # <%= html_single_resource_commented %> + # + # In order to confirm that the user is redirected to the correct page + # after create, you'll need to add an entry to paths.rb to uniquely + # find a <%= singular %>, e.g.: + # + # when /page for the <%= singular %> with name "([^"]*)"$/ + # conditions = { :conditions => {:name => $1} } + # matches = <%= singular_title %>.all(conditions) + # if matches.size == 0 + # raise "Could not find any <%= plural %> using criteria #{conditions.inspect}" + # elsif matches.size > 1 + # raise "Could not find a unique <%= singular %> using criteria #{conditions.inspect} (#{matches.size} matches)" + # end + # <%= singular %>_path(matches.first) + # + # Then add a step such as this to the scenario: + # + # And I should be on the page for the <%= singular %> with name "..." + + <%= tags('@new @create') %> + Scenario: Attempt to create a new <%= singular %> with invalid input + Pending + # <%= pending_explanation_1 %> + # Given I am on the new <%= singular %> page + # When I fill in the following: + # <%= form_single_resource_commented %> + # And I press "<%= create_button_title %>" + # Then I should see "<%= problems_intro %>" + # + # <%= pending_explanation_2 %> + # + # And I should be on the <%= plural %> page + # And I should see the following form field values: + # <%= html_single_resource_commented %> + + <%= tags('@edit @update') %> + Scenario: Attempt to update a <%= singular %> with invalid input + Pending + # <%= pending_explanation_1 %> + # Given a <%= singular %> exists + # When I go to the edit page for that <%= singular %> + # And I fill in the following: + # <%= form_single_resource_commented %> + # And I press "<%= update_button_title %>" + # Then I should see "<%= problems_intro %>" + # + # <%= pending_explanation_2 %> + # + # And I should be on the page for that <%= singular %> + # And I should see the following form field values: + # <%= html_single_resource_commented %> + + <%= tags('@edit @update @show') %> + Scenario: Update a <%= singular %> + Given a <%= singular %> exists + When I go to the edit page for that <%= singular %> + And I fill in the following: + <%= form_single_resource_updated %> + And I press "<%= update_button_title %>" + Then I should be on the page for that <%= singular %> + And I should see "<%= successful_update_message %>" + And I should see the following <%= singular %>: + <%= html_single_resource_updated %> + + <%= tags('@index @new') %> + Scenario: Navigate from the <%= plural %> page to the new <%= singular %> page + Given I am on the <%= plural %> page + When I follow "New <%= singular_title %>" + Then I should be on the new <%= singular %> page + + <%= tags('@index @show') %> + Scenario: Navigate from <%= plural %> page to the show <%= singular %> page + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the <%= plural %> page + And I click "Show" in the 2nd row + Then I should be on the page for the 2nd <%= singular %> + + <%= tags('@index @edit') %> + Scenario: Navigate from <%= plural %> page to the edit <%= singular %> page + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the <%= plural %> page + And I click "Edit" in the 2nd row + Then I should be on the edit page for the 2nd <%= singular %> + + <%= tags('@new @index') %> + Scenario: Navigate from new <%= singular %> page to <%= plural %> page + Given I am on the new <%= singular %> page + When I follow "<%= back_to_all %>" + Then I should be on the <%= plural %> page + + <%= tags('@edit @show') %> + Scenario: Navigate from the edit <%= singular %> page to the show <%= singular %> page + Given a <%= singular %> exists + When I go to the edit page for that <%= singular %> + And I follow "Show" + Then I should be on the page for that <%= singular %> + + <%= tags('@edit @index') %> + Scenario: Navigate from edit <%= singular %> page to the <%= plural %> page + Given a <%= singular %> exists + When I go to the edit page for that <%= singular %> + And I follow "<%= back_to_all %>" + Then I should be on the <%= plural %> page + + <%= tags('@show @edit') %> + Scenario: Navigate from show <%= singular %> page to edit <%= singular %> page + Given a <%= singular %> exists + When I go to the page for that <%= singular %> + And I follow "Edit" + Then I should be on the edit page for that <%= singular %> + + <%= tags('@show @index') %> + Scenario: Navigate from show <%= singular %> page to <%= plural %> page + Given a <%= singular %> exists + And I am on the page for that <%= singular %> + <% if nifty? %> + And I follow "View All" + <% else %> + And I follow "Back" + <% end %> + Then I should be on the <%= plural %> page + + <%= tags('@index') %> + Scenario: <%= plural_title %> page title + When I go to the <%= plural %> page + Then the heading should be "<%= index_heading %>" + <% if index_title %> + And the title should be "<%= index_title %>" + <% end -%> + + <%= tags('@show') %> + <% if show_heading || index_title %> + Scenario: <%= singular_title %> page title + Given a <%= singular %> exists + When I go to the page for that <%= singular %> + <% if show_heading %> + Then the heading should be "<%= show_heading %>" + <% end %> + <% if index_title %> + And the title should be "<%= show_title %>" + <% end -%> + <% end -%> + + <%= tags('@new') %> + Scenario: New <%= singular %> page title + When I go to the new <%= singular %> page + Then the heading should be "<%= new_heading %>" + <% if index_title %> + And the title should be "<%= new_title %>" + <% end -%> + + <%= tags('@edit') %> + Scenario: Edit <%= singular %> page title + Given a <%= singular %> exists + When I go to the edit page for that <%= singular %> + Then the heading should be "<%= edit_heading %>" + <% if index_title %> + And the title should be "<%= edit_title %>" + <% end -%> diff --git a/lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb b/lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb new file mode 100644 index 0000000..81aa8c2 --- /dev/null +++ b/lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb @@ -0,0 +1,40 @@ +<%= generated_by %> + +When /^I click "([^"]*)" in the (\d+)(?:st|nd|rd|th) row$/ do |link, pos| + within("table tr:nth-child(#{pos.to_i+1})") do + click_link link + end +end + +Then /^the heading should be "([^"]*)"$/ do |heading| + Then %{I should see "#{heading}" within "h1"} +end + +Then /^the title should be "([^"]*)"$/ do |title| + Then %{I should see "#{title}" within "title"} +end + +When /^I should see the following form field values:$/ do |table| + form_fields = tableish('form label', lambda{ |label| [label, form_field_for_label(label)]}) + form_fields_hash = {} + form_fields.each do |form_field| + attr_name = form_field[0] + attr_value = form_field[1] + form_fields_hash[attr_name] = attr_value + end + assert_equal table.rows_hash, form_fields_hash +end + +def form_field_for_label(label) + input_tags = label.parent.css('input,textarea') + return if input_tags.size == 0 + if input_tags.size > 1 + raise "Wrong number of input tags while parsing form (found #{input_tags.size})" + end + input_tag = input_tags.first + if input_tag.name == 'textarea' + input_tag.inner_html + elsif input_tag.name == 'input' + input_tag['value'] + end +end diff --git a/lib/generators/cucumber_scaffold/templates/steps.rb b/lib/generators/cucumber_scaffold/templates/steps.rb new file mode 100644 index 0000000..419883d --- /dev/null +++ b/lib/generators/cucumber_scaffold/templates/steps.rb @@ -0,0 +1,40 @@ +<%= generated_by %> + +Given /^a <%= singular %> exists$/ do + @<%= singular %> = <%= singular_title %>.create!(valid_<%= singular %>_attributes) +end + +Then /^I should see the following <%= singular %>:$/ do |expected_table| + + <% if nifty? %> + show_fields_css_query = 'body p strong' + <% else %> + show_fields_css_query = 'body p b' + <% end %> + + actual_table = tableish(show_fields_css_query, lambda{|label| [label, label.next]}) + actual = {} + actual_table.each do |form_entry| + attr_name = form_entry[0] + attr_value = form_entry[1] + actual[attr_name] = attr_value + end + assert_equal actual, expected_table.rows_hash +end + +Then /^I should see the following <%= plural %>:$/ do |expected_table| + expected_table.diff!(tableish('table tr', 'td,th')) +end + +Given /^the following <%= plural %>:$/ do |table| + @<%= plural %> = <%= singular_title %>.create!(table.hashes) +end + +Given /^the following <%= singular %>:$/ do |table| + @<%= singular %> = <%= singular_title %>.create!(table.rows_hash) +end + +def valid_<%= singular %>_attributes + # You may want to a factory for this + {} +end diff --git a/pkg/cucumber_scaffold-0.1.0.gem b/pkg/cucumber_scaffold-0.1.0.gem new file mode 100644 index 0000000000000000000000000000000000000000..397714eb959caae9fbbbb3231c7e0fbd256f1dd4 GIT binary patch literal 8704 zcmeHsRZtvCw=MyKy9NmEu7lg4fx#g_a33H9*O|dBSO^jb?k>SKxCfWuF2MaTMi_V=>7dsTO@^>x*%?yqeuJuP`WE!}y*5TySU`2K>hkPy

|gjd z%P#;B6#0K+|K;Zw6ci9aqT~Bd1@!lIy*&QP{;%zQ>}_qG{_gm<_W#fSe^dKga{o5{ ze`}XE1_Mb+^`{yV%8Ar_kCmpn{rZ5H93n+?%gM~F6BO#1%EToL9vOv6g{PTrrg%(p zWSVR`TYaD2A9t;8xCbsRnIge-3lkR|G{;B!iCPv-xyT-n-*jwd3ldvi$G`vXy|vs0 zO?~ct``F$tvka2feQ@N3|=cqB32aZbB{h|w99H=@#Zq9;}iCe6G|zyhMA*%-dN=vx+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v$mYWs8h!54Zj8y1&xU>#ubo6re&9RC@Yo$UHe$Pl`(#`q(ljJQ-zF} zRH>)xx+K>0G%nxP6H00S{A4D$)g99q{5zD-{$sM-+umIg<=&o_kY+Wy?bL5!dSiJ% z#K&jYM)R+6)n_Fi50CjiV>t@HG3cf~@2S;+^kYG^NZEM0HAF312|KW>oq@qXi?%NI zJj!UZ+1W!Z2i!4SG%nln{CS`YJ0+2-FA^x%TJBeX2fQcH*cPxK&O#Hu#ws!-g1ss$#FR+pnAxWABtSjR=Y&=W@B_a_Lz5Z|POkq*oGMR$G>#lHYlEbRPXd;o^>6xT8 z?2^h7Me-WtYd+P{al#A@OzUxHl_ zK>kkY>GG0go(uA8c^Yqh(aeZ6+cSpM9^tNc9d>qT;@}m3IBw}N`G?T7Be1!*%v^Fw z@zLdkNqP1Nxbuo|#z7d`qH2Jj1^0sC z+$ZRF#7f1)Z(Ca_7Su?Piqy#So;-C1YDqD8ABfv|BXS!pZCm}pm+J`B|Ej7;{0$hv X|0=Qn;2#G5Vc;JI{$b$1%fSBuUaUmB literal 0 HcmV?d00001 diff --git a/pkg/cucumber_scaffold-0.1.0.tar.gz b/pkg/cucumber_scaffold-0.1.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..1193de013111f34c1cc021d00c159d5b3a9f0a3b GIT binary patch literal 6331 zcmV;s7)0kEiwFQlO4UpN1MNLcbKA&ra#CAKcz?O2YL>E>BGfm`D1N)qsp$m zWqa2zrPZQ9VkqJn1h@bwSu639Lq7jNQuPkGzjLbclAPW@NX|K?@+)#kchBIH00GJr zy&sseOk&W}Gt<-E(>>EO983q(ai2S?JJ5zh+tjyPN?U0)H&&Qht=9hTE~C%AJ^E~Q zcEqPltli$(+wJV^wp)9w)!yyyv^Uu9DjSiNrmm+s&=k$mFIo%W0Bks1@Lu*K`23Ni zLB{yc`wUL8g&3Y_I7qM$G^MR?#9Qz)9LQ+Z?Hwfv9k0tAOB6Z{qZ*A*1*;c z>$JzF-f;Ua=2a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_j!XF&uta4@h1UgWx%IrKrB;jcN_aa6ZEqs5PkUVSEWAkM%{9u+ssXXV;p-+VOgq z5xNA;W#xF6R-QOka2p#>+u-pTJjFs`X>16?Y6IsBH_t#YU_!+DzO`AImQAbk{}eUj zYL2CT|GBk?=YMzF?ehMY^`x6S|Npy<)t&!u$AAB=TY3O1N~@FqEa}g;|2wVyg#35+ z_RIS}*OF50|JS}jCL;*^@NYkepq}>YMqpq_Qw471h#_8-MNg%eQjP! zh*?!OlT}CU>TIs6xn<=%yCeIvF)8NzOwp z@GV%;9Gkgwum+f z=Fo+f@B$iCn26|A>3*sM>5EN3=UJWtu3NoEueb1$Fv!&Ccj#aWn>v=*ukg#pPAjCm z@y`*+(*v*32W6JHe9e~Nw7-LQcA1=ht1n=W`p}+QI{nT;4C|~B-YOrwqI(|#FggX0 zXp$mE>_GhX0(Fbp76KR+C=C_E8Y}*(h?LTll_+{#qcN+UL= 1.2") if s.respond_to? :required_rubygems_version= + s.authors = ["Andy Waite"] + s.date = %q{2010-11-06} + s.description = %q{Generate scaffolding for Cucumber features and steps definitions} + s.email = %q{andy@andywaite.com} + s.extra_rdoc_files = ["README.rdoc", "TODO", "lib/generators/cucumber_scaffold/USAGE", "lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb", "lib/generators/cucumber_scaffold/cucumber_scaffold_install_generator.rb", "lib/generators/cucumber_scaffold/templates/feature.feature", "lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb", "lib/generators/cucumber_scaffold/templates/steps.rb"] + s.files = ["Manifest", "README.rdoc", "Rakefile", "TODO", "lib/generators/cucumber_scaffold/USAGE", "lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb", "lib/generators/cucumber_scaffold/cucumber_scaffold_install_generator.rb", "lib/generators/cucumber_scaffold/templates/feature.feature", "lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb", "lib/generators/cucumber_scaffold/templates/steps.rb", "cucumber_scaffold.gemspec"] + s.homepage = %q{http://github.com/andyw8/cucumber_scaffold} + s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Cucumber_scaffold", "--main", "README.rdoc"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{cucumber_scaffold} + s.rubygems_version = %q{1.3.7} + s.summary = %q{Generate scaffolding for Cucumber features and steps definitions} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/USAGE b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/USAGE new file mode 100644 index 0000000..4fbb0a8 --- /dev/null +++ b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/USAGE @@ -0,0 +1,31 @@ +Description: + Scaffolding for Cucumber features + +Example: + + For first time use: + + rails generate cucumber_scaffold_install + + This will create: + features/shared/web_steps_additional.rb + + Then for a feature: + + rails generate cucumber_scaffold_feature Post title:string body:text + + This will create: + features/manage_posts.rb + features/step_definitions/post_steps.rb + + and will modify: + features/support/paths.rb + +Options: + + --nifty + Generate features and steps which match the scaffold created by nifty-generators + ( https://github.com/ryanb/nifty-generators ) + + --tags + Include Cucumbers @tags matching each scenario to one or more controller actions \ No newline at end of file diff --git a/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb new file mode 100644 index 0000000..e3aea4a --- /dev/null +++ b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/cucumber_scaffold_feature_generator.rb @@ -0,0 +1,192 @@ +class CucumberScaffoldFeatureGenerator < Rails::Generators::NamedBase + + INDENT = " " + LINE_BREAK_WITH_INDENT = "\n#{INDENT}" + LINE_BREAK_WITH_INDENT_COMMENTED = "\n#{INDENT}# " + + argument :model_name, :type => :string + + source_root File.expand_path('../templates', __FILE__) + + def initialize(args, *options) + # copied setup from + # http://apidock.com/rails/Rails/Generators/NamedBase/new/class + args[0] = args[0].dup if args[0].is_a?(String) && args[0].frozen? + super + assign_names!(self.name) + parse_attributes! if respond_to?(:attributes) + args.shift + @args = args + end + + def do_it + @attributes = [] + @args.each do |param_pair| + name, type = param_pair.split(':') + @attributes << { name => type } + end + + template('feature.feature', "features/manage_#{plural}.feature") + template('steps.rb', "features/step_definitions/#{singular}_steps.rb") + + extra_paths = < :string + + source_root File.expand_path('../templates', __FILE__) + + def do_it + + template('shared/web_steps_additional.rb', 'features/step_definitions/web_steps_additional.rb') + + end + +end \ No newline at end of file diff --git a/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/feature.feature b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/feature.feature new file mode 100644 index 0000000..e8220ba --- /dev/null +++ b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/feature.feature @@ -0,0 +1,282 @@ +<%= generated_by %> +<% +update_button_title = 'Update' +create_button_title = 'Create' + +if nifty? + successful_update_message = "Successfully updated #{singular}." + successful_create_message = "Successfully created #{singular}." + successful_destroy_message = "Successfully destroyed #{singular}." + new_heading = "New #{singular_title}" + edit_heading = "Edit #{singular_title}" + index_heading = plural_title + show_heading = singular_title + new_title = new_heading + edit_title = edit_heading + index_title = index_heading + show_title = show_heading + back_to_all = 'Back to List' + problems_intro = 'Correct the following errors and try again.' +else + problems_intro = + successful_update_message = "#{singular_title} was successfully updated." + successful_create_message = "#{singular_title} was successfully created." + index_heading = "Listing #{plural}" + edit_heading = "Editing #{singular}" + new_heading = "New #{singular}" + back_to_all = 'Back' + problems_intro = "prohibited this post from being saved:" +end + +pending_explanation_1 = "You should use this scenario as the basis for scenarios involving ActiveRecord validations, or delete it if it's not required" +pending_explanation_2 = "[You should add checks for specific errors here. It may be appropriate to add extra scenarios.]" +-%> + +Feature: Manage <%= plural_title %> + In order to [goal] + [stakeholder] + wants [behaviour] + + <%= tags('@index') %> + Scenario: List all <%= plural %> + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the <%= plural %> page + Then I should see the following <%= plural %>: + <%= html_table_header_row %> + <%= html_table_row(1) %> + <%= html_table_row(2) %> + <%= html_table_row(3) %> + + <%= tags('@show') %> + Scenario: View a <%= singular %> + Given the following <%= singular %>: + <%= activerecord_single_resource %> + When I go to the page for that <%= singular %> + Then I should see the following <%= singular %>: + <%= html_single_resource %> + + <%= tags('@edit') %> + Scenario: Edit a <%= singular %> + Given the following <%= singular %>: + <%= activerecord_single_resource %> + When I go to the edit page for that <%= singular %> + Then I should see the following form field values: + <%= form_single_resource %> + + <%= tags('@index @destroy') %> + Scenario: Delete a <%= singular %> via the index page + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the <%= plural %> page + And I click "Destroy" in the 2nd row + Then I should see the following <%= plural %>: + <%= html_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(3) %> + And I should be on the <%= plural %> page + <% if successful_destroy_message %> + And I should see "<%= successful_destroy_message %>" + <% end -%> + + <% if nifty? %> + <%= tags('@show @destroy @index') %> + Scenario: Delete a <%= singular %> via the show page + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the page for the 2nd post + And I follow "Destroy" + Then I should see the following <%= plural %>: + <%= html_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(3) %> + And I should be on the <%= plural %> page + And I should see "<%= successful_destroy_message %>" + <% end -%> + + <%= tags('@new @create @show') %> + Scenario: Create a new <%= singular %> + Pending + # Given I am on the new <%= singular %> page + # When I fill in the following: + # <%= form_single_resource_commented %> + # And I press "<%= create_button_title %>" + # Then I should see "<%= successful_create_message %>" + # And I should see the following <%= singular %>: + # <%= html_single_resource_commented %> + # + # In order to confirm that the user is redirected to the correct page + # after create, you'll need to add an entry to paths.rb to uniquely + # find a <%= singular %>, e.g.: + # + # when /page for the <%= singular %> with name "([^"]*)"$/ + # conditions = { :conditions => {:name => $1} } + # matches = <%= singular_title %>.all(conditions) + # if matches.size == 0 + # raise "Could not find any <%= plural %> using criteria #{conditions.inspect}" + # elsif matches.size > 1 + # raise "Could not find a unique <%= singular %> using criteria #{conditions.inspect} (#{matches.size} matches)" + # end + # <%= singular %>_path(matches.first) + # + # Then add a step such as this to the scenario: + # + # And I should be on the page for the <%= singular %> with name "..." + + <%= tags('@new @create') %> + Scenario: Attempt to create a new <%= singular %> with invalid input + Pending + # <%= pending_explanation_1 %> + # Given I am on the new <%= singular %> page + # When I fill in the following: + # <%= form_single_resource_commented %> + # And I press "<%= create_button_title %>" + # Then I should see "<%= problems_intro %>" + # + # <%= pending_explanation_2 %> + # + # And I should be on the <%= plural %> page + # And I should see the following form field values: + # <%= html_single_resource_commented %> + + <%= tags('@edit @update') %> + Scenario: Attempt to update a <%= singular %> with invalid input + Pending + # <%= pending_explanation_1 %> + # Given a <%= singular %> exists + # When I go to the edit page for that <%= singular %> + # And I fill in the following: + # <%= form_single_resource_commented %> + # And I press "<%= update_button_title %>" + # Then I should see "<%= problems_intro %>" + # + # <%= pending_explanation_2 %> + # + # And I should be on the page for that <%= singular %> + # And I should see the following form field values: + # <%= html_single_resource_commented %> + + <%= tags('@edit @update @show') %> + Scenario: Update a <%= singular %> + Given a <%= singular %> exists + When I go to the edit page for that <%= singular %> + And I fill in the following: + <%= form_single_resource_updated %> + And I press "<%= update_button_title %>" + Then I should be on the page for that <%= singular %> + And I should see "<%= successful_update_message %>" + And I should see the following <%= singular %>: + <%= html_single_resource_updated %> + + <%= tags('@index @new') %> + Scenario: Navigate from the <%= plural %> page to the new <%= singular %> page + Given I am on the <%= plural %> page + When I follow "New <%= singular_title %>" + Then I should be on the new <%= singular %> page + + <%= tags('@index @show') %> + Scenario: Navigate from <%= plural %> page to the show <%= singular %> page + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the <%= plural %> page + And I click "Show" in the 2nd row + Then I should be on the page for the 2nd <%= singular %> + + <%= tags('@index @edit') %> + Scenario: Navigate from <%= plural %> page to the edit <%= singular %> page + Given the following <%= plural %>: + <%= activerecord_table_header_row %> + <%= activerecord_table_row(1) %> + <%= activerecord_table_row(2) %> + <%= activerecord_table_row(3) %> + When I go to the <%= plural %> page + And I click "Edit" in the 2nd row + Then I should be on the edit page for the 2nd <%= singular %> + + <%= tags('@new @index') %> + Scenario: Navigate from new <%= singular %> page to <%= plural %> page + Given I am on the new <%= singular %> page + When I follow "<%= back_to_all %>" + Then I should be on the <%= plural %> page + + <%= tags('@edit @show') %> + Scenario: Navigate from the edit <%= singular %> page to the show <%= singular %> page + Given a <%= singular %> exists + When I go to the edit page for that <%= singular %> + And I follow "Show" + Then I should be on the page for that <%= singular %> + + <%= tags('@edit @index') %> + Scenario: Navigate from edit <%= singular %> page to the <%= plural %> page + Given a <%= singular %> exists + When I go to the edit page for that <%= singular %> + And I follow "<%= back_to_all %>" + Then I should be on the <%= plural %> page + + <%= tags('@show @edit') %> + Scenario: Navigate from show <%= singular %> page to edit <%= singular %> page + Given a <%= singular %> exists + When I go to the page for that <%= singular %> + And I follow "Edit" + Then I should be on the edit page for that <%= singular %> + + <%= tags('@show @index') %> + Scenario: Navigate from show <%= singular %> page to <%= plural %> page + Given a <%= singular %> exists + And I am on the page for that <%= singular %> + <% if nifty? %> + And I follow "View All" + <% else %> + And I follow "Back" + <% end %> + Then I should be on the <%= plural %> page + + <%= tags('@index') %> + Scenario: <%= plural_title %> page title + When I go to the <%= plural %> page + Then the heading should be "<%= index_heading %>" + <% if index_title %> + And the title should be "<%= index_title %>" + <% end -%> + + <%= tags('@show') %> + <% if show_heading || index_title %> + Scenario: <%= singular_title %> page title + Given a <%= singular %> exists + When I go to the page for that <%= singular %> + <% if show_heading %> + Then the heading should be "<%= show_heading %>" + <% end %> + <% if index_title %> + And the title should be "<%= show_title %>" + <% end -%> + <% end -%> + + <%= tags('@new') %> + Scenario: New <%= singular %> page title + When I go to the new <%= singular %> page + Then the heading should be "<%= new_heading %>" + <% if index_title %> + And the title should be "<%= new_title %>" + <% end -%> + + <%= tags('@edit') %> + Scenario: Edit <%= singular %> page title + Given a <%= singular %> exists + When I go to the edit page for that <%= singular %> + Then the heading should be "<%= edit_heading %>" + <% if index_title %> + And the title should be "<%= edit_title %>" + <% end -%> diff --git a/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb new file mode 100644 index 0000000..81aa8c2 --- /dev/null +++ b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/shared/web_steps_additional.rb @@ -0,0 +1,40 @@ +<%= generated_by %> + +When /^I click "([^"]*)" in the (\d+)(?:st|nd|rd|th) row$/ do |link, pos| + within("table tr:nth-child(#{pos.to_i+1})") do + click_link link + end +end + +Then /^the heading should be "([^"]*)"$/ do |heading| + Then %{I should see "#{heading}" within "h1"} +end + +Then /^the title should be "([^"]*)"$/ do |title| + Then %{I should see "#{title}" within "title"} +end + +When /^I should see the following form field values:$/ do |table| + form_fields = tableish('form label', lambda{ |label| [label, form_field_for_label(label)]}) + form_fields_hash = {} + form_fields.each do |form_field| + attr_name = form_field[0] + attr_value = form_field[1] + form_fields_hash[attr_name] = attr_value + end + assert_equal table.rows_hash, form_fields_hash +end + +def form_field_for_label(label) + input_tags = label.parent.css('input,textarea') + return if input_tags.size == 0 + if input_tags.size > 1 + raise "Wrong number of input tags while parsing form (found #{input_tags.size})" + end + input_tag = input_tags.first + if input_tag.name == 'textarea' + input_tag.inner_html + elsif input_tag.name == 'input' + input_tag['value'] + end +end diff --git a/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/steps.rb b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/steps.rb new file mode 100644 index 0000000..419883d --- /dev/null +++ b/pkg/cucumber_scaffold-0.1.0/lib/generators/cucumber_scaffold/templates/steps.rb @@ -0,0 +1,40 @@ +<%= generated_by %> + +Given /^a <%= singular %> exists$/ do + @<%= singular %> = <%= singular_title %>.create!(valid_<%= singular %>_attributes) +end + +Then /^I should see the following <%= singular %>:$/ do |expected_table| + + <% if nifty? %> + show_fields_css_query = 'body p strong' + <% else %> + show_fields_css_query = 'body p b' + <% end %> + + actual_table = tableish(show_fields_css_query, lambda{|label| [label, label.next]}) + actual = {} + actual_table.each do |form_entry| + attr_name = form_entry[0] + attr_value = form_entry[1] + actual[attr_name] = attr_value + end + assert_equal actual, expected_table.rows_hash +end + +Then /^I should see the following <%= plural %>:$/ do |expected_table| + expected_table.diff!(tableish('table tr', 'td,th')) +end + +Given /^the following <%= plural %>:$/ do |table| + @<%= plural %> = <%= singular_title %>.create!(table.hashes) +end + +Given /^the following <%= singular %>:$/ do |table| + @<%= singular %> = <%= singular_title %>.create!(table.rows_hash) +end + +def valid_<%= singular %>_attributes + # You may want to a factory for this + {} +end