aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJamie Winsor <jamie@enmasse.com>2011-08-04 15:39:04 -0700
committerJamie Winsor <jamie@enmasse.com>2011-08-04 15:39:04 -0700
commitee215655cba5820c3ffe0c665ea71c11f15f3bf9 (patch)
treeaa1da7816aecf14c2033dff124cf867f30b7581b
parent8bd056e3e8baa108b2e10e460ceeeed3ec7c4c86 (diff)
downloadrefinerycms-blog-ee215655cba5820c3ffe0c665ea71c11f15f3bf9.tar.gz
refinerycms-blog-ee215655cba5820c3ffe0c665ea71c11f15f3bf9.tar.bz2
refinerycms-blog-ee215655cba5820c3ffe0c665ea71c11f15f3bf9.zip
Replace cucumber tag features with rspec request tests
Remove cucumber support from project
-rw-r--r--Guardfile8
-rw-r--r--config/cucumber.yml10
-rw-r--r--config/environment.rb3
-rw-r--r--features/step_definitions/tags_steps.rb13
-rw-r--r--features/step_definitions/user_steps.rb42
-rw-r--r--features/step_definitions/web_steps.rb196
-rw-r--r--features/support/env.rb51
-rw-r--r--features/support/paths.rb18
-rw-r--r--features/support/selectors.rb39
-rw-r--r--features/tags.feature26
-rw-r--r--spec/requests/blog_posts_spec.rb18
-rw-r--r--spec/requests/manage_blog_posts_spec.rb22
12 files changed, 41 insertions, 405 deletions
diff --git a/Guardfile b/Guardfile
index 91d89e0..4de3a30 100644
--- a/Guardfile
+++ b/Guardfile
@@ -19,13 +19,7 @@ guard 'rspec', :version => 2 do
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
end
-guard 'cucumber' do
- watch(%r{^features/.+\.feature$})
- watch(%r{^features/support/.+$}) { 'features' }
- watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
-end
-
-guard 'spork', :wait => 60, :cucumber_env => { 'RAILS_ENV' => 'test' }, :rspec_env => { 'RAILS_ENV' => 'test' } do
+guard 'spork', :wait => 60, :cucumber => false, :rspec_env => { 'RAILS_ENV' => 'test' } do
watch('config/application.rb')
watch('config/environment.rb')
watch(%r{^config/environments/.+\.rb$})
diff --git a/config/cucumber.yml b/config/cucumber.yml
deleted file mode 100644
index 368422a..0000000
--- a/config/cucumber.yml
+++ /dev/null
@@ -1,10 +0,0 @@
-<%
-ENV["RAILS_ENV"] ||= "test"
-require ::File.expand_path('../spec/dummy/config/environment', __FILE__)
-rerun = IO.read('rerun.txt') if File.file?('rerun.txt')
-rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
-std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} --strict --tags ~@wip -r features"
-%>
-default: <%= std_opts %>
-wip: --tags @wip:3 --wip features
-rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip \ No newline at end of file
diff --git a/config/environment.rb b/config/environment.rb
deleted file mode 100644
index 5cdbfa5..0000000
--- a/config/environment.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-# TODO: Remove this when you figure out how to get Cucumber to look for the
-# environment file in the dummy app instead of within the project root
-require File.expand_path('../../spec/dummy/config/environment', __FILE__)
diff --git a/features/step_definitions/tags_steps.rb b/features/step_definitions/tags_steps.rb
deleted file mode 100644
index d16f758..0000000
--- a/features/step_definitions/tags_steps.rb
+++ /dev/null
@@ -1,13 +0,0 @@
-Given /^there is a blog post titled "([^"]*)" and tagged "([^"]*)"$/ do |title, tag_name|
- @blog_post = Factory.create(:blog_post, :title => title, :tag_list => tag_name)
-end
-
-When /^I visit the tagged posts page for "([^"]*)"$/ do |tag_name|
- @blog_post ||= Factory.create(:blog_post, :tag_list => tag_name)
- tag = ::Refinery::BlogPost.tag_counts_on(:tags).first
- visit tagged_posts_path(tag.id, tag_name.parameterize)
-end
-
-Then /^the blog post should have the tags "([^"]*)"$/ do |tag_list|
- ::Refinery::BlogPost.last.tag_list == tag_list.split(', ')
-end
diff --git a/features/step_definitions/user_steps.rb b/features/step_definitions/user_steps.rb
deleted file mode 100644
index 002fa7d..0000000
--- a/features/step_definitions/user_steps.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-def login(options = {})
- options = {:user => @refinery_user}.merge(options)
- visit new_refinery_user_session_path
- fill_in("refinery_user_login", :with => options[:user].email)
- fill_in("refinery_user_password", :with => 'greenandjuicy')
- click_button("submit_button")
-end
-
-Given /^I am a logged in refinery user$/i do
- @refinery_user ||= Factory(:refinery_user)
- login(:user => @refinery_user)
-end
-
-Given /^I am a logged in refinery translator$/i do
- @refinery_translator ||= Factory(:refinery_translator)
- login(:user => @refinery_translator)
-end
-
-Given /^I am a logged in customer$/i do
- @user ||= Factory(:user)
- login(:user => @user)
-end
-
-Given /^A Refinery user exists$/i do
- @refinery_user ||= Factory(:refinery_user)
-end
-
-Given /^I have a user named "(.*)"$/ do |name|
- @user = Factory(:user, :username => name)
-end
-
-Given /^I have a refinery user named "(.*)"$/i do |name|
- @refinery_user = Factory(:refinery_user, :username => name)
-end
-
-Given /^I have no users$/ do
- ::Refinery::User.delete_all
-end
-
-Then /^I should have ([0-9]+) users?$/ do |count|
- ::Refinery::User.count.should == count.to_i
-end
diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb
deleted file mode 100644
index 22abbf6..0000000
--- a/features/step_definitions/web_steps.rb
+++ /dev/null
@@ -1,196 +0,0 @@
-# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
-# It is recommended to regenerate this file in the future when you upgrade to a
-# newer version of cucumber-rails. Consider adding your own code to a new file
-# instead of editing this one. Cucumber will automatically load all features/**/*.rb
-# files.
-
-require 'uri'
-require 'cgi'
-require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "paths"))
-require File.expand_path(File.join(File.dirname(__FILE__), "..", "support", "selectors"))
-
-module WithinHelpers
- def with_scope(locator)
- locator ? within(*selector_for(locator)) { yield } : yield
- end
-end
-World(WithinHelpers)
-
-# Single-line step scoper
-When /^(.*) within (.*[^:])$/ do |step, parent|
- with_scope(parent) { When step }
-end
-
-# Multi-line step scoper
-When /^(.*) within (.*[^:]):$/ do |step, parent, table_or_string|
- with_scope(parent) { When "#{step}:", table_or_string }
-end
-
-Given /^(?:|I )am on (.+)$/ do |page_name|
- visit path_to(page_name)
-end
-
-When /^(?:|I )go to (.+)$/ do |page_name|
- visit path_to(page_name)
-end
-
-When /^(?:|I )press "([^"]*)"$/ do |button|
- click_button(button)
-end
-
-When /^(?:|I )follow "([^"]*)"$/ do |link|
- click_link(link)
-end
-
-When /^(?:|I )fill in "([^"]*)" with "([^"]*)"$/ do |field, value|
- fill_in(field, :with => value)
-end
-
-When /^(?:|I )fill in "([^"]*)" for "([^"]*)"$/ do |value, field|
- fill_in(field, :with => value)
-end
-
-# Use this to fill in an entire form with data from a table. Example:
-#
-# When I fill in the following:
-# | Account Number | 5002 |
-# | Expiry date | 2009-11-01 |
-# | Note | Nice guy |
-# | Wants Email? | |
-#
-# TODO: Add support for checkbox, select og option
-# based on naming conventions.
-#
-When /^(?:|I )fill in the following:$/ do |fields|
- fields.rows_hash.each do |name, value|
- When %{I fill in "#{name}" with "#{value}"}
- end
-end
-
-When /^(?:|I )select "([^"]*)" from "([^"]*)"$/ do |value, field|
- select(value, :from => field)
-end
-
-When /^(?:|I )check "([^"]*)"$/ do |field|
- check(field)
-end
-
-When /^(?:|I )uncheck "([^"]*)"$/ do |field|
- uncheck(field)
-end
-
-When /^(?:|I )choose "([^"]*)"$/ do |field|
- choose(field)
-end
-
-When /^(?:|I )attach the file "([^"]*)" to "([^"]*)"$/ do |path, field|
- attach_file(field, File.expand_path(path))
-end
-
-Then /^(?:|I )should see "([^"]*)"$/ do |text|
- if page.respond_to? :should
- page.should have_content(text)
- else
- assert page.has_content?(text)
- end
-end
-
-Then /^(?:|I )should see \/([^\/]*)\/$/ do |regexp|
- regexp = Regexp.new(regexp)
-
- if page.respond_to? :should
- page.should have_xpath('//*', :text => regexp)
- else
- assert page.has_xpath?('//*', :text => regexp)
- end
-end
-
-Then /^(?:|I )should not see "([^"]*)"$/ do |text|
- if page.respond_to? :should
- page.should have_no_content(text)
- else
- assert page.has_no_content?(text)
- end
-end
-
-Then /^(?:|I )should not see \/([^\/]*)\/$/ do |regexp|
- regexp = Regexp.new(regexp)
-
- if page.respond_to? :should
- page.should have_no_xpath('//*', :text => regexp)
- else
- assert page.has_no_xpath?('//*', :text => regexp)
- end
-end
-
-Then /^the "([^"]*)" field(?: within (.*))? should contain "([^"]*)"$/ do |field, parent, value|
- with_scope(parent) do
- field = find_field(field)
- field_value = (field.tag_name == 'textarea') ? field.text : field.value
- if field_value.respond_to? :should
- field_value.should =~ /#{value}/
- else
- assert_match(/#{value}/, field_value)
- end
- end
-end
-
-Then /^the "([^"]*)" field(?: within (.*))? should not contain "([^"]*)"$/ do |field, parent, value|
- with_scope(parent) do
- field = find_field(field)
- field_value = (field.tag_name == 'textarea') ? field.text : field.value
- if field_value.respond_to? :should_not
- field_value.should_not =~ /#{value}/
- else
- assert_no_match(/#{value}/, field_value)
- end
- end
-end
-
-Then /^the "([^"]*)" checkbox(?: within (.*))? should be checked$/ do |label, parent|
- with_scope(parent) do
- field_checked = find_field(label)['checked']
- if field_checked.respond_to? :should
- field_checked.should be_true
- else
- assert field_checked
- end
- end
-end
-
-Then /^the "([^"]*)" checkbox(?: within (.*))? should not be checked$/ do |label, parent|
- with_scope(parent) do
- field_checked = find_field(label)['checked']
- if field_checked.respond_to? :should
- field_checked.should be_false
- else
- assert !field_checked
- end
- end
-end
-
-Then /^(?:|I )should be on (.+)$/ do |page_name|
- current_path = URI.parse(current_url).path
- if current_path.respond_to? :should
- current_path.should == path_to(page_name)
- else
- assert_equal path_to(page_name), current_path
- end
-end
-
-Then /^(?:|I )should have the following query string:$/ do |expected_pairs|
- query = URI.parse(current_url).query
- actual_params = query ? CGI.parse(query) : {}
- expected_params = {}
- expected_pairs.rows_hash.each_pair{|k,v| expected_params[k] = v.split(',')}
-
- if actual_params.respond_to? :should
- actual_params.should == expected_params
- else
- assert_equal expected_params, actual_params
- end
-end
-
-Then /^show me the page$/ do
- save_and_open_page
-end
diff --git a/features/support/env.rb b/features/support/env.rb
deleted file mode 100644
index 4bc2cc2..0000000
--- a/features/support/env.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-require 'rubygems'
-require 'bundler/setup'
-require 'spork'
-
-Spork.prefork do
- require 'cucumber/rails'
- require 'capybara/rails'
- require 'capybara/cucumber'
- require 'capybara/session'
-
- require 'refinery/testing/factories'
-
- require 'database_cleaner'
- require 'database_cleaner/cucumber'
-
- Dir[File.expand_path("../../../spec/factories/*.rb", __FILE__)].each {|f| require f}
-
- include ::Devise::Controllers::UrlHelpers
-
- # Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
- # order to ease the transition to Capybara we set the default here. If you'd
- # prefer to use XPath just remove this line and adjust any selectors in your
- # steps to use the XPath syntax.
- Capybara.default_selector = :css
-
- # By default, any exception happening in your Rails application will bubble up
- # to Cucumber so that your scenario will fail. This is a different from how
- # your application behaves in the production environment, where an error page will
- # be rendered instead.
- #
- # Sometimes we want to override this default behaviour and allow Rails to rescue
- # exceptions and display an error page (just like when the app is running in production).
- # Typical scenarios where you want to do this is when you test your error pages.
- # There are two ways to allow Rails to rescue exceptions:
- #
- # 1) Tag your scenario (or feature) with @allow-rescue
- #
- # 2) Set the value below to true. Beware that doing this globally is not
- # recommended as it will mask a lot of errors for you!
- #
- ActionController::Base.allow_rescue = false
-
- DatabaseCleaner.strategy = :truncation
-
- Before { DatabaseCleaner.start }
- After { DatabaseCleaner.clean }
-end
-
-Spork.each_run do
- # This code will be run each time you run your specs.
-end
diff --git a/features/support/paths.rb b/features/support/paths.rb
deleted file mode 100644
index f69b8fe..0000000
--- a/features/support/paths.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-def path_to(page_name)
- case page_name
- when /the list of blog posts/
- refinery_admin_blog_posts_path
- when /the new blog posts? form/
- new_refinery_admin_blog_post_path
- else
- begin
- if page_name =~ /the blog post titled "?([^\"]*)"?/ and (page = BlogPost.find_by_title($1)).present?
- self.url_for(page.url)
- else
- nil
- end
- rescue
- nil
- end
- end
-end
diff --git a/features/support/selectors.rb b/features/support/selectors.rb
deleted file mode 100644
index 44e34a4..0000000
--- a/features/support/selectors.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-module HtmlSelectorsHelpers
- # Maps a name to a selector. Used primarily by the
- #
- # When /^(.+) within (.+)$/ do |step, scope|
- #
- # step definitions in web_steps.rb
- #
- def selector_for(locator)
- case locator
-
- when "the page"
- "html > body"
-
- # Add more mappings here.
- # Here is an example that pulls values out of the Regexp:
- #
- # when /^the (notice|error|info) flash$/
- # ".flash.#{$1}"
-
- # You can also return an array to use a different selector
- # type, like:
- #
- # when /the header/
- # [:xpath, "//header"]
-
- # This allows you to provide a quoted selector as the scope
- # for "within" steps as was previously the default for the
- # web steps:
- when /^"(.+)"$/
- $1
-
- else
- raise "Can't find mapping from \"#{locator}\" to a selector.\n" +
- "Now, go and add a mapping in #{__FILE__}"
- end
- end
-end
-
-World(HtmlSelectorsHelpers)
diff --git a/features/tags.feature b/features/tags.feature
deleted file mode 100644
index 24dff2a..0000000
--- a/features/tags.feature
+++ /dev/null
@@ -1,26 +0,0 @@
-@blog @blog_tags
-Feature: Blog Post Tags
- Blog posts can be assigned tags
-
- Background:
- Given I am a logged in refinery user
-
- Scenario: The blog post new/edit form has tag_list
- When I am on the new blog post form
- Then I should see "Tags"
-
- Scenario: The blog post new/edit form saves tag_list
- When I am on the new blog post form
- And I fill in "Title" with "This is my blog post"
- And I fill in "blog_post_body" with "And I love it"
- And I fill in "Tags" with "chicago, bikes, beers, babes"
- And I press "Save"
-
- Then there should be 1 blog post
- And the blog post should have the tags "chicago, bikes, beers, babes"
-
- Scenario: The blog has a "tagged" route & view
- Given there is a blog post titled "I love my city" and tagged "chicago"
- When I visit the tagged posts page for "chicago"
- Then I should see "Chicago"
- And I should see "I love my city" \ No newline at end of file
diff --git a/spec/requests/blog_posts_spec.rb b/spec/requests/blog_posts_spec.rb
index 1eaf27a..d7d2a9f 100644
--- a/spec/requests/blog_posts_spec.rb
+++ b/spec/requests/blog_posts_spec.rb
@@ -17,4 +17,22 @@ describe "blog posts" do
response.content_type.should eq("application/rss+xml")
end
end
+
+ describe "list tagged posts" do
+ context "when has tagged blog posts" do
+ before(:each) do
+ @tag_name = "chicago"
+ @blog_post = Factory.create(:blog_post,
+ :title => "I Love my city",
+ :tag_list => @tag_name)
+ tag = ::Refinery::BlogPost.tag_counts_on(:tags).first
+ visit tagged_posts_path(tag.id, @tag_name.parameterize)
+ end
+
+ it "should have one tagged post" do
+ page.should have_content(@tag_name)
+ page.should have_content(@blog_post.title)
+ end
+ end
+ end
end
diff --git a/spec/requests/manage_blog_posts_spec.rb b/spec/requests/manage_blog_posts_spec.rb
index 12b7b8f..6d6f734 100644
--- a/spec/requests/manage_blog_posts_spec.rb
+++ b/spec/requests/manage_blog_posts_spec.rb
@@ -55,6 +55,28 @@ describe "manage blog posts" do
::Refinery::BlogPost.last.categories.first.title.should eq(blog_category.title)
end
end
+
+ describe "create blog post with tags" do
+ before(:each) do
+ @tag_list = "chicago, bikes, beers, babes"
+ fill_in "Title", :with => "This is a tagged blog post"
+ fill_in "blog_post_body", :with => "And I also love it"
+ fill_in "Tags", :with => @tag_list
+ click_button "Save"
+ end
+
+ it "should succeed" do
+ page.should have_content("was successfully added.")
+ end
+
+ it "should be the only blog post" do
+ ::Refinery::BlogPost.all.size.should eq(1)
+ end
+
+ it "should have the specified tags" do
+ ::Refinery::BlogPost.last.tag_list.should eq(@tag_list.split(', '))
+ end
+ end
end
end