cowboycoded 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cowboycoded}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["John McAliley"]
12
- s.date = %q{2011-05-20}
12
+ s.date = %q{2011-05-23}
13
13
  s.description = %q{helps you code quicker}
14
14
  s.email = %q{john.mcaliley@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,12 +26,13 @@ Gem::Specification.new do |s|
26
26
  "cowboycoded.gemspec",
27
27
  "lib/core_ext/string.rb",
28
28
  "lib/cowboycoded.rb",
29
- "lib/cowboycoded/cucumber_steps/browser.rb",
30
- "lib/cowboycoded/cucumber_steps/file.rb",
31
29
  "lib/cowboycoded/railtie.rb",
32
30
  "lib/generators/cowboycoded/common_app/USAGE",
33
31
  "lib/generators/cowboycoded/common_app/common_app_generator.rb",
32
+ "lib/generators/cowboycoded/cucumber_step/cucumber_step_generator.rb",
33
+ "lib/generators/cowboycoded/cucumber_step/templates/features/step_definitions/file_steps.rb",
34
34
  "lib/generators/cowboycoded/engine/engine_generator.rb",
35
+ "lib/generators/cowboycoded/javascripts/cowboycoded.js",
35
36
  "lib/generators/cowboycoded/railtie/railtie_generator.rb",
36
37
  "lib/generators/cowboycoded/test_group/USAGE",
37
38
  "lib/generators/cowboycoded/test_group/templates/Gemfile",
@@ -50,6 +51,7 @@ Gem::Specification.new do |s|
50
51
  "test_app/config.ru",
51
52
  "test_app/config/application.rb",
52
53
  "test_app/config/boot.rb",
54
+ "test_app/config/cucumber.yml",
53
55
  "test_app/config/database.yml",
54
56
  "test_app/config/environment.rb",
55
57
  "test_app/config/environments/development.rb",
@@ -63,7 +65,13 @@ Gem::Specification.new do |s|
63
65
  "test_app/config/locales/en.yml",
64
66
  "test_app/config/routes.rb",
65
67
  "test_app/db/seeds.rb",
68
+ "test_app/features/cucumber_steps.feature",
69
+ "test_app/features/step_definitions/web_steps.rb",
70
+ "test_app/features/support/env.rb",
71
+ "test_app/features/support/paths.rb",
72
+ "test_app/features/support/selectors.rb",
66
73
  "test_app/lib/tasks/.gitkeep",
74
+ "test_app/lib/tasks/cucumber.rake",
67
75
  "test_app/public/404.html",
68
76
  "test_app/public/422.html",
69
77
  "test_app/public/500.html",
@@ -78,6 +86,7 @@ Gem::Specification.new do |s|
78
86
  "test_app/public/javascripts/rails.js",
79
87
  "test_app/public/robots.txt",
80
88
  "test_app/public/stylesheets/.gitkeep",
89
+ "test_app/script/cucumber",
81
90
  "test_app/script/rails",
82
91
  "test_app/test/performance/browsing_test.rb",
83
92
  "test_app/test/test_helper.rb",
@@ -2,8 +2,4 @@ require 'cowboycoded/railtie'
2
2
  require 'core_ext/string'
3
3
 
4
4
  module Cowboycoded
5
- module CucumberSteps
6
- autoload :BrowserSteps, 'cucumber_steps/browser_steps'
7
- autoload :FileSteps, 'cucumber_steps/file_steps'
8
- end
9
5
  end
@@ -0,0 +1,13 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Cowboycoded
5
+ class CucumberStepGenerator < Rails::Generators::Base
6
+ TEMPLATES_DIR = File.join(File.dirname(__FILE__), 'templates')
7
+ source_root TEMPLATES_DIR
8
+
9
+ def steps
10
+ directory 'features'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ Given /^a working directory$/ do
2
+ @working_dir = File.dirname(__FILE__)+"/../../"
3
+ end
4
+
5
+ Then /^a timestamped file named "([^"]*)" is created in the "([^"]*)" directory$/ do |file,dir|
6
+ full_dir = @working_dir+dir
7
+ Dir.entries(full_dir).each do |timestamped_file|
8
+ file = timestamped_file if timestamped_file.include? file
9
+ end
10
+ assert File.exists?(full_dir+file), "#{file} expected to exist, but did not"
11
+ assert File.file?(full_dir+file), "#{file} expected to be a file, but is not"
12
+ end
13
+
14
+ When /^I run the "([^"]*)" generator$/ do |generator|
15
+ @generator_output = systemu("rails g #{generator}")
16
+ end
17
+
18
+ Then /^a file named "([^"]*)" is created in the "([^"]*)" directory$/ do |file,dir|
19
+ full_dir = @working_dir+dir
20
+ assert File.exists?(full_dir+file), "#{file} expected to exist, but did not"
21
+ assert File.file?(full_dir+file), "#{file} expected to be a file, but is not"
22
+ end
23
+
24
+ Then /^the file "([^"]*)" contains "([^"]*)"$/ do |file, text|
25
+ path = @working_dir+file
26
+ file_content = IO.read(path)
27
+ assert file_content.match(/#{text}/), "#{text} expected in #{path}"
28
+ end
@@ -0,0 +1,3 @@
1
+ function isNumber(n) {
2
+ return !isNaN(parseFloat(n)) && isFinite(n);
3
+ }
@@ -0,0 +1,8 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip"
5
+ %>
6
+ default: <%= std_opts %> features
7
+ wip: --tags @wip:3 --wip features
8
+ rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip
@@ -9,7 +9,7 @@ development:
9
9
  # Warning: The database defined as "test" will be erased and
10
10
  # re-generated from your development database when you run "rake".
11
11
  # Do not set this db to the same as development or production.
12
- test:
12
+ test: &test
13
13
  adapter: sqlite3
14
14
  database: db/test.sqlite3
15
15
  pool: 5
@@ -20,3 +20,6 @@ production:
20
20
  database: db/production.sqlite3
21
21
  pool: 5
22
22
  timeout: 5000
23
+
24
+ cucumber:
25
+ <<: *test
@@ -0,0 +1,10 @@
1
+ Feature: cucumber steps
2
+ In order to use cuc steps in cowboycoded
3
+ A user should be able to
4
+ generate cucumber steps
5
+
6
+ Scenario: run cucumber steps generator
7
+ Given a working directory
8
+ And I run the "cowboycoded:cucumber_step" generator
9
+ Then a file named "file_steps.rb" is created in the "/features/step_definitions/" directory
10
+ And I cleanup the generated cucumber step files
@@ -0,0 +1,71 @@
1
+ # TL;DR: YOU SHOULD DELETE THIS FILE
2
+ #
3
+ # This file was generated by Cucumber-Rails and is only here to get you a head start
4
+ # These step definitions are thin wrappers around the Capybara/Webrat API that lets you
5
+ # visit pages, interact with widgets and make assertions about page content.
6
+ #
7
+ # If you use these step definitions as basis for your features you will quickly end up
8
+ # with features that are:
9
+ #
10
+ # * Hard to maintain
11
+ # * Verbose to read
12
+ #
13
+ # A much better approach is to write your own higher level step definitions, following
14
+ # the advice in the following blog posts:
15
+ #
16
+ # * http://benmabey.com/2008/05/19/imperative-vs-declarative-scenarios-in-user-stories.html
17
+ # * http://dannorth.net/2011/01/31/whose-domain-is-it-anyway/
18
+ # * http://elabs.se/blog/15-you-re-cuking-it-wrong
19
+ #
20
+
21
+
22
+ require 'uri'
23
+ require 'cgi'
24
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
25
+ require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
26
+
27
+ module WithinHelpers
28
+ def with_scope(locator)
29
+ locator ? within(*selector_for(locator)) { yield } : yield
30
+ end
31
+ end
32
+ World(WithinHelpers)
33
+
34
+ Then /^show me the page$/ do
35
+ save_and_open_page
36
+ end
37
+
38
+
39
+ Given /^a working directory$/ do
40
+ @working_dir = File.dirname(__FILE__)+"/../../"
41
+ end
42
+
43
+ Then /^a timestamped file named "([^"]*)" is created in the "([^"]*)" directory$/ do |file,dir|
44
+ full_dir = @working_dir+dir
45
+ Dir.entries(full_dir).each do |timestamped_file|
46
+ file = timestamped_file if timestamped_file.include? file
47
+ end
48
+ assert File.exists?(full_dir+file), "#{file} expected to exist, but did not"
49
+ assert File.file?(full_dir+file), "#{file} expected to be a file, but is not"
50
+ end
51
+
52
+ When /^I run the "([^"]*)" generator$/ do |generator|
53
+ @generator_output = systemu("rails g #{generator}")
54
+ end
55
+
56
+ Then /^a file named "([^"]*)" is created in the "([^"]*)" directory$/ do |file,dir|
57
+ full_dir = @working_dir+dir
58
+ assert File.exists?(full_dir+file), "#{file} expected to exist, but did not"
59
+ assert File.file?(full_dir+file), "#{file} expected to be a file, but is not"
60
+ end
61
+
62
+ Then /^the file "([^"]*)" contains "([^"]*)"$/ do |file, text|
63
+ path = @working_dir+file
64
+ file_content = IO.read(path)
65
+ assert file_content.match(/#{text}/), "#{text} expected in #{path}"
66
+ end
67
+
68
+ Given /^I cleanup the generated cucumber step files$/ do
69
+ FileUtils.rm(@working_dir+"features/step_definitions/file_steps.rb") rescue nil
70
+ FileUtils.rm(@working_dir+"features/step_definitions/browser_steps.rb") rescue nil
71
+ end
@@ -0,0 +1,51 @@
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
+ require 'cucumber/rails'
8
+
9
+ require 'capybara'
10
+ # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
11
+ # order to ease the transition to Capybara we set the default here. If you'd
12
+ # prefer to use XPath just remove this line and adjust any selectors in your
13
+ # steps to use the XPath syntax.
14
+ Capybara.default_selector = :css
15
+
16
+ # By default, any exception happening in your Rails application will bubble up
17
+ # to Cucumber so that your scenario will fail. This is a different from how
18
+ # your application behaves in the production environment, where an error page will
19
+ # be rendered instead.
20
+ #
21
+ # Sometimes we want to override this default behaviour and allow Rails to rescue
22
+ # exceptions and display an error page (just like when the app is running in production).
23
+ # Typical scenarios where you want to do this is when you test your error pages.
24
+ # There are two ways to allow Rails to rescue exceptions:
25
+ #
26
+ # 1) Tag your scenario (or feature) with @allow-rescue
27
+ #
28
+ # 2) Set the value below to true. Beware that doing this globally is not
29
+ # recommended as it will mask a lot of errors for you!
30
+ #
31
+ ActionController::Base.allow_rescue = false
32
+
33
+ # Remove/comment out the lines below if your app doesn't have a database.
34
+ # For some databases (like MongoDB and CouchDB) you may need to use :truncation instead.
35
+ begin
36
+ DatabaseCleaner.strategy = :transaction
37
+ rescue NameError
38
+ raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it."
39
+ end
40
+
41
+ # You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios.
42
+ # See the DatabaseCleaner documentation for details. Example:
43
+ #
44
+ # Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do
45
+ # DatabaseCleaner.strategy = :truncation, :except => %w[widgets]
46
+ # end
47
+ #
48
+ # Before('~@no-txn', '~@selenium', '~@culerity', '~@celerity', '~@javascript') do
49
+ # DatabaseCleaner.strategy = :transaction
50
+ # end
51
+ #
@@ -0,0 +1,33 @@
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
+ else
21
+ begin
22
+ page_name =~ /^the (.*) page$/
23
+ path_components = $1.split(/\s+/)
24
+ self.send(path_components.push('path').join('_').to_sym)
25
+ rescue NoMethodError, ArgumentError
26
+ raise "Can't find mapping from \"#{page_name}\" to a path.\n" +
27
+ "Now, go and add a mapping in #{__FILE__}"
28
+ end
29
+ end
30
+ end
31
+ end
32
+
33
+ World(NavigationHelpers)
@@ -0,0 +1,39 @@
1
+ module HtmlSelectorsHelpers
2
+ # Maps a name to a selector. Used primarily by the
3
+ #
4
+ # When /^(.+) within (.+)$/ do |step, scope|
5
+ #
6
+ # step definitions in web_steps.rb
7
+ #
8
+ def selector_for(locator)
9
+ case locator
10
+
11
+ when "the page"
12
+ "html > body"
13
+
14
+ # Add more mappings here.
15
+ # Here is an example that pulls values out of the Regexp:
16
+ #
17
+ # when /^the (notice|error|info) flash$/
18
+ # ".flash.#{$1}"
19
+
20
+ # You can also return an array to use a different selector
21
+ # type, like:
22
+ #
23
+ # when /the header/
24
+ # [:xpath, "//header"]
25
+
26
+ # This allows you to provide a quoted selector as the scope
27
+ # for "within" steps as was previously the default for the
28
+ # web steps:
29
+ when /^"(.+)"$/
30
+ $1
31
+
32
+ else
33
+ raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
34
+ "Now, go and add a mapping in #{__FILE__}"
35
+ end
36
+ end
37
+ end
38
+
39
+ World(HtmlSelectorsHelpers)
@@ -0,0 +1,57 @@
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
+ unless ARGV.any? {|a| a =~ /^gems/} # Don't load anything when running the gems:* tasks
9
+
10
+ vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
11
+ $LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + '/../lib') unless vendored_cucumber_bin.nil?
12
+
13
+ begin
14
+ require 'cucumber/rake/task'
15
+
16
+ namespace :cucumber do
17
+ Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
18
+ t.binary = vendored_cucumber_bin # If nil, the gem's binary is used.
19
+ t.fork = true # You may get faster startup if you set this to false
20
+ t.profile = 'default'
21
+ end
22
+
23
+ Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
24
+ t.binary = vendored_cucumber_bin
25
+ t.fork = true # You may get faster startup if you set this to false
26
+ t.profile = 'wip'
27
+ end
28
+
29
+ Cucumber::Rake::Task.new({:rerun => 'db:test:prepare'}, 'Record failing features and run only them if any exist') do |t|
30
+ t.binary = vendored_cucumber_bin
31
+ t.fork = true # You may get faster startup if you set this to false
32
+ t.profile = 'rerun'
33
+ end
34
+
35
+ desc 'Run all features'
36
+ task :all => [:ok, :wip]
37
+ end
38
+ desc 'Alias for cucumber:ok'
39
+ task :cucumber => 'cucumber:ok'
40
+
41
+ task :default => :cucumber
42
+
43
+ task :features => :cucumber do
44
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
45
+ end
46
+
47
+ # In case we don't have ActiveRecord, append a no-op task that we can depend upon.
48
+ task 'db:test:prepare' do
49
+ end
50
+ rescue LoadError
51
+ desc 'cucumber rake task not available (cucumber not installed)'
52
+ task :cucumber do
53
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
54
+ end
55
+ end
56
+
57
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first
4
+ if vendored_cucumber_bin
5
+ load File.expand_path(vendored_cucumber_bin)
6
+ else
7
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
8
+ require 'cucumber'
9
+ load Cucumber::BINARY
10
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - John McAliley
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-05-20 00:00:00 -04:00
17
+ date: 2011-05-23 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -92,12 +92,13 @@ files:
92
92
  - cowboycoded.gemspec
93
93
  - lib/core_ext/string.rb
94
94
  - lib/cowboycoded.rb
95
- - lib/cowboycoded/cucumber_steps/browser.rb
96
- - lib/cowboycoded/cucumber_steps/file.rb
97
95
  - lib/cowboycoded/railtie.rb
98
96
  - lib/generators/cowboycoded/common_app/USAGE
99
97
  - lib/generators/cowboycoded/common_app/common_app_generator.rb
98
+ - lib/generators/cowboycoded/cucumber_step/cucumber_step_generator.rb
99
+ - lib/generators/cowboycoded/cucumber_step/templates/features/step_definitions/file_steps.rb
100
100
  - lib/generators/cowboycoded/engine/engine_generator.rb
101
+ - lib/generators/cowboycoded/javascripts/cowboycoded.js
101
102
  - lib/generators/cowboycoded/railtie/railtie_generator.rb
102
103
  - lib/generators/cowboycoded/test_group/USAGE
103
104
  - lib/generators/cowboycoded/test_group/templates/Gemfile
@@ -116,6 +117,7 @@ files:
116
117
  - test_app/config.ru
117
118
  - test_app/config/application.rb
118
119
  - test_app/config/boot.rb
120
+ - test_app/config/cucumber.yml
119
121
  - test_app/config/database.yml
120
122
  - test_app/config/environment.rb
121
123
  - test_app/config/environments/development.rb
@@ -129,7 +131,13 @@ files:
129
131
  - test_app/config/locales/en.yml
130
132
  - test_app/config/routes.rb
131
133
  - test_app/db/seeds.rb
134
+ - test_app/features/cucumber_steps.feature
135
+ - test_app/features/step_definitions/web_steps.rb
136
+ - test_app/features/support/env.rb
137
+ - test_app/features/support/paths.rb
138
+ - test_app/features/support/selectors.rb
132
139
  - test_app/lib/tasks/.gitkeep
140
+ - test_app/lib/tasks/cucumber.rake
133
141
  - test_app/public/404.html
134
142
  - test_app/public/422.html
135
143
  - test_app/public/500.html
@@ -144,6 +152,7 @@ files:
144
152
  - test_app/public/javascripts/rails.js
145
153
  - test_app/public/robots.txt
146
154
  - test_app/public/stylesheets/.gitkeep
155
+ - test_app/script/cucumber
147
156
  - test_app/script/rails
148
157
  - test_app/test/performance/browsing_test.rb
149
158
  - test_app/test/test_helper.rb
@@ -162,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
162
171
  requirements:
163
172
  - - ">="
164
173
  - !ruby/object:Gem::Version
165
- hash: 1825801507247575179
174
+ hash: -1798423215571927082
166
175
  segments:
167
176
  - 0
168
177
  version: "0"
@@ -1,6 +0,0 @@
1
- module CowboyCoded
2
- module CucumberSteps
3
- module Browser
4
- end
5
- end
6
- end
@@ -1,35 +0,0 @@
1
- module CowboyCoded
2
- module CucumberSteps
3
- module File
4
- Given /^a working directory$/ do
5
- @working_dir = File.dirname(__FILE__)+"/../../"
6
- end
7
-
8
- Then /^a timestamped file named "([^"]*)" is created in the "([^"]*)" directory$/ do |file,dir|
9
- full_dir = @working_dir+dir
10
- Dir.entries(full_dir).each do |timestamped_file|
11
- file = timestamped_file if timestamped_file.include? file
12
- end
13
- assert File.exists?(full_dir+file), "#{file} expected to exist, but did not"
14
- assert File.file?(full_dir+file), "#{file} expected to be a file, but is not"
15
- end
16
-
17
- When /^I run the "([^"]*)" generator$/ do |generator|
18
- @generator_output = systemu("rails g #{generator}")
19
- end
20
-
21
- Then /^a file named "([^"]*)" is created in the "([^"]*)" directory$/ do |file,dir|
22
- full_dir = @working_dir+dir
23
- assert File.exists?(full_dir+file), "#{file} expected to exist, but did not"
24
- assert File.file?(full_dir+file), "#{file} expected to be a file, but is not"
25
- end
26
-
27
- Then /^the file "([^"]*)" contains "([^"]*)"$/ do |file, text|
28
- path = @working_dir+file
29
- file_content = IO.read(path)
30
- assert file_content.match(/#{text}/), "#{text} expected in #{path}"
31
- end
32
- end
33
- end
34
- end
35
-