diff --git a/cucumber-rails.gemspec b/cucumber-rails.gemspec index f737c556..336dfe12 100644 --- a/cucumber-rails.gemspec +++ b/cucumber-rails.gemspec @@ -25,7 +25,7 @@ Gem::Specification.new do |s| s.add_development_dependency('mongoid', Cucumber::Rails::DEPS['mongoid']) s.add_development_dependency('bson_ext', Cucumber::Rails::DEPS['bson_ext']) - s.rubygems_version = "1.3.7" + s.rubygems_version = ">= 1.6.1" s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } diff --git a/features/inspect_query_string.feature b/features/inspect_query_string.feature new file mode 100644 index 00000000..677c3916 --- /dev/null +++ b/features/inspect_query_string.feature @@ -0,0 +1,36 @@ +Feature: Inspect query string + + Scenario: Inspect query string + Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support + And I successfully run "rails generate cucumber:feature post title:string body:text published:boolean" + And I successfully run "rails generate scaffold post title:string body:text published:boolean" + And I successfully run "rails generate scaffold cukes name:string" + And I overwrite "app/controllers/cukes_controller.rb" with: + """ + class CukesController < ApplicationController + def index + redirect_to cuke_path(10, {:name => 'cucumber', :what => 'vegetable'}) + end + + def show + render :text => "Cuke #{params[:id]}" + end + end + """ + And I write to "features/tests.feature" with: + """ + Feature: Tests + Scenario: Tests + When I go to the cukes page + Then I should have the following query string: + | name | cucumber | + | what | vegetable | + And I should see "Cuke 10" + """ + And I run "bundle exec rake db:migrate cucumber" + Then it should pass with: + """ + 3 scenarios (3 passed) + 14 steps (14 passed) + """ + diff --git a/features/install_cucumber_rails.feature b/features/install_cucumber_rails.feature new file mode 100644 index 00000000..327bc0e1 --- /dev/null +++ b/features/install_cucumber_rails.feature @@ -0,0 +1,16 @@ +Feature: Rails 3 + In order to take over the world + Cucumber-Rails should work on major versions + of Rails 3 and Ruby, with Capybara, Spork and DatabaseCleaner + + Scenario: Install Cucumber-Rails + Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support + Then the following files should exist: + | config/cucumber.yml | + | script/cucumber | + | features/step_definitions/web_steps.rb | + | features/support/env.rb | + | features/support/paths.rb | + | features/support/selectors.rb | + | lib/tasks/cucumber.rake | + And the file "features/support/env.rb" should contain "require 'cucumber/rails'" \ No newline at end of file diff --git a/features/named_selectors.feature b/features/named_selectors.feature new file mode 100644 index 00000000..d7152444 --- /dev/null +++ b/features/named_selectors.feature @@ -0,0 +1,33 @@ +Feature: Named Selectors + + Scenario: Look within named selector + Given a project without ActiveRecord + And a cukes resource + And I write to "app/views/cukes/index.html.erb" with: + """ +
foo
+
bar
+ """ + And I write to "features/tests.feature" with: + """ + Feature: Tests + Scenario: Tests + When I go to the cukes page + Then I should see "foo" within the foo div + And I should not see "bar" within the foo div + """ + And I overwrite "features/support/selectors.rb" with: + """ + module HtmlSelectorsHelpers + def selector_for(locator) + return '.foo' if locator == 'the foo div' + end + end + World(HtmlSelectorsHelpers) + """ + And I run "rake cucumber" + Then it should pass with: + """ + 1 scenario (1 passed) + 3 steps (3 passed) + """ diff --git a/features/no_database.feature b/features/no_database.feature new file mode 100644 index 00000000..5d131342 --- /dev/null +++ b/features/no_database.feature @@ -0,0 +1,69 @@ +Feature: No Database + Allow Cucumber to work with a Rails app without a database + + Scenario: No ActiveRecord and DatabaseCleaner + Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support + # Turn off ActiveRecord + And I write to "config/application.rb" with: + """ + require File.expand_path('../boot', __FILE__) + + require 'action_controller/railtie' + require 'action_mailer/railtie' + require 'active_resource/railtie' + require 'rails/test_unit/railtie' + + Bundler.require(:default, Rails.env) if defined?(Bundler) + + module Rails3App + class Application < Rails::Application + config.encoding = "utf-8" + config.filter_parameters += [:password] + end + end + """ + And I remove the file "config/database.yml" + And I overwrite "features/support/env.rb" with: + """ + require 'cucumber/rails' + """ + # Remove DatabaseCleaner and SQLite + And I write to "Gemfile" with: + """ + source 'http://rubygems.org' + gem 'rails' + gem "cucumber-rails", :group => :test, :path => "../../.." + gem "capybara", :group => :test + gem "rspec-rails", :group => :test + """ + And I write to "app/controllers/posts_controller.rb" with: + """ + class PostsController < ApplicationController + def index + raise "There is an error in index" + end + end + """ + And I write to "config/routes.rb" with: + """ + Rails3App::Application.routes.draw do + resources :posts + end + """ + And I write to "features/posts.feature" with: + """ + Feature: posts + Scenario: See them + When I do it + """ + And I write to "features/step_definitions/posts_steps.rb" with: + """ + When /^I do it$/ do + visit '/posts' + end + """ + And I run "bundle exec rake cucumber" + Then it should fail with: + """ + There is an error in index + """ diff --git a/features/rails3.feature b/features/rails3.feature deleted file mode 100644 index 22978995..00000000 --- a/features/rails3.feature +++ /dev/null @@ -1,194 +0,0 @@ -Feature: Rails 3 - In order to take over the world - Cucumber-Rails should work on major versions - of Rails 3 and Ruby, with Capybara, Spork and DatabaseCleaner - - Scenario: Install Cucumber-Rails - Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support - Then the following files should exist: - | config/cucumber.yml | - | script/cucumber | - | features/step_definitions/web_steps.rb | - | features/support/env.rb | - | features/support/paths.rb | - | features/support/selectors.rb | - | lib/tasks/cucumber.rake | - And the file "features/support/env.rb" should contain "require 'cucumber/rails'" - - Scenario: Inspect query string - Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support - And I successfully run "rails generate cucumber:feature post title:string body:text published:boolean" - And I successfully run "rails generate scaffold post title:string body:text published:boolean" - And I successfully run "rails generate scaffold cukes name:string" - And I overwrite "app/controllers/cukes_controller.rb" with: - """ - class CukesController < ApplicationController - def index - redirect_to cuke_path(10, {:name => 'cucumber', :what => 'vegetable'}) - end - - def show - render :text => "Cuke #{params[:id]}" - end - end - """ - And I write to "features/tests.feature" with: - """ - Feature: Tests - Scenario: Tests - When I go to the cukes page - Then I should have the following query string: - | name | cucumber | - | what | vegetable | - And I should see "Cuke 10" - """ - And I run "bundle exec rake db:migrate cucumber" - Then it should pass with: - """ - 3 scenarios (3 passed) - 14 steps (14 passed) - """ - - Scenario: No ActiveRecord and DatabaseCleaner - Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support - # Turn off ActiveRecord - And I write to "config/application.rb" with: - """ - require File.expand_path('../boot', __FILE__) - - require 'action_controller/railtie' - require 'action_mailer/railtie' - require 'active_resource/railtie' - require 'rails/test_unit/railtie' - - Bundler.require(:default, Rails.env) if defined?(Bundler) - - module Rails3App - class Application < Rails::Application - config.encoding = "utf-8" - config.filter_parameters += [:password] - end - end - """ - And I remove the file "config/database.yml" - And I overwrite "features/support/env.rb" with: - """ - require 'cucumber/rails' - """ - # Remove DatabaseCleaner and SQLite - And I write to "Gemfile" with: - """ - source 'http://rubygems.org' - gem 'rails' - gem "cucumber-rails", :group => :test, :path => "../../.." - gem "capybara", :group => :test - gem "rspec-rails", :group => :test - """ - And I write to "app/controllers/posts_controller.rb" with: - """ - class PostsController < ApplicationController - def index - raise "There is an error in index" - end - end - """ - And I write to "config/routes.rb" with: - """ - Rails3App::Application.routes.draw do - resources :posts - end - """ - And I write to "features/posts.feature" with: - """ - Feature: posts - Scenario: See them - When I do it - """ - And I write to "features/step_definitions/posts_steps.rb" with: - """ - When /^I do it$/ do - visit '/posts' - end - """ - And I run "bundle exec rake cucumber" - Then it should fail with: - """ - There is an error in index - """ - - Scenario: Compare JSON - Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support - And I write to "app/controllers/posts_controller.rb" with: - """ - class PostsController < ApplicationController - def index - render :json => {'hello' => 'world'}.to_json - end - end - """ - And I write to "config/routes.rb" with: - """ - Rails3App::Application.routes.draw do - resources :posts - end - """ - And I write to "features/posts.feature" with: - """ - Feature: posts - Scenario: See them - When the client requests GET /posts - Then the response should be JSON: - \"\"\" - { - "hello": "world" - } - \"\"\" - """ - And I write to "features/step_definitions/rest_steps.rb" with: - """ - When /^the client requests GET (.*)$/ do |path| - get(path) - end - - Then /^the response should be JSON:$/ do |json| - JSON.parse(last_response.body).should == JSON.parse(json) - end - """ - And I run "bundle exec rake db:migrate cucumber" - Then it should pass with: - """ - 1 scenario (1 passed) - 2 steps (2 passed) - """ - - Scenario: Look within named selector - Given a project without ActiveRecord - And a cukes resource - And I write to "app/views/cukes/index.html.erb" with: - """ -
foo
-
bar
- """ - And I write to "features/tests.feature" with: - """ - Feature: Tests - Scenario: Tests - When I go to the cukes page - Then I should see "foo" within the foo div - And I should not see "bar" within the foo div - """ - And I overwrite "features/support/selectors.rb" with: - """ - module HtmlSelectorsHelpers - def selector_for(locator) - return '.foo' if locator == 'the foo div' - end - end - World(HtmlSelectorsHelpers) - """ - And I run "rake cucumber" - Then it should pass with: - """ - 1 scenario (1 passed) - 3 steps (3 passed) - """ diff --git a/features/rest_api.feature b/features/rest_api.feature new file mode 100644 index 00000000..1fe145a0 --- /dev/null +++ b/features/rest_api.feature @@ -0,0 +1,46 @@ +Feature: REST API + + Scenario: Compare JSON + Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support + And I write to "app/controllers/posts_controller.rb" with: + """ + class PostsController < ApplicationController + def index + render :json => {'hello' => 'world'}.to_json + end + end + """ + And I write to "config/routes.rb" with: + """ + Rails3App::Application.routes.draw do + resources :posts + end + """ + And I write to "features/posts.feature" with: + """ + Feature: posts + Scenario: See them + When the client requests GET /posts + Then the response should be JSON: + \"\"\" + { + "hello": "world" + } + \"\"\" + """ + And I write to "features/step_definitions/rest_steps.rb" with: + """ + When /^the client requests GET (.*)$/ do |path| + get(path) + end + + Then /^the response should be JSON:$/ do |json| + JSON.parse(last_response.body).should == JSON.parse(json) + end + """ + And I run "bundle exec rake db:migrate cucumber" + Then it should pass with: + """ + 1 scenario (1 passed) + 2 steps (2 passed) + """ diff --git a/features/select_dates.feature b/features/select_dates.feature index ff190f9d..a035ef3a 100644 --- a/features/select_dates.feature +++ b/features/select_dates.feature @@ -1,4 +1,4 @@ -Feature: Allow Cucumber to rescue exceptions +Feature: Select dates Background: A simple calendar app Given I have created a new Rails 3 app "rails-3-app" with cucumber-rails support diff --git a/lib/cucumber/rails/version.rb b/lib/cucumber/rails/version.rb index f650f80e..22033fe5 100644 --- a/lib/cucumber/rails/version.rb +++ b/lib/cucumber/rails/version.rb @@ -2,19 +2,20 @@ module Cucumber module Rails VERSION = '0.4.0' DEPS = { + 'aruba' => '>= 0.3.3', + 'cucumber' => '>= 0.10.0', + 'bundler' => '>= 1.0.10', - 'cucumber' => '~> 0.10', - 'rack-test' => '~> 0.5', - 'nokogiri' => '~> 1.4.4', - 'rails' => '~> 3.0', - 'capybara' => '~> 0.4', - 'webrat' => '~> 0.7', - 'rspec-rails' => '~> 2.2', - 'database_cleaner' => '~> 0.6', - 'sqlite3-ruby' => '~> 1.3', - 'aruba' => '~> 0.3', + 'rack-test' => '>= 0.5.7', + 'nokogiri' => '>= 1.4.4', + 'rails' => '>= 3.0.3', + 'capybara' => '>= 0.4.1', + 'webrat' => '>= 0.7.3', + 'rspec-rails' => '>= 2.2.0', + 'database_cleaner' => '>= 0.6.0', + 'sqlite3-ruby' => '>= 1.3.3', 'mongoid' => '>= 1.9', - 'bson_ext' => '~> 1.2' + 'bson_ext' => '>= 1.2.4' } end end \ No newline at end of file