Permalink
Browse files

Passing rake

  • Loading branch information...
1 parent f2f243d commit 865d8f13e80021d03f5d707dbe88cdf5e76eb5da @mike-burns mike-burns committed with jyurek Jul 27, 2012
Showing with 20 additions and 11 deletions.
  1. +0 −1 features/regenerating_styles.feature
  2. +18 −10 features/step_definitions/mvc_steps.rb
  3. +2 −0 features/support/rails.rb
View
1 features/regenerating_styles.feature
@@ -3,7 +3,6 @@ Feature: Regenerating styles
Scenario: Adding a new style
Given I generate a new rails application
And I have made a simple avatar on the user model
- And I start the rails application
And I upload an avatar to the user model
When I add the following style to the user avatar:
"""
View
28 features/step_definitions/mvc_steps.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/string'
+
Given /^I have made a simple avatar on the user model$/ do
run_simple(%{bundle exec #{generator_command} scaffold user})
run_simple(%{bundle exec #{generator_command} paperclip user avatar})
@@ -48,20 +50,23 @@ class User < ActiveRecord::Base
end
Then /^I see a missing large avatar on the user show page$/ do
- user = User.last
- user.should_not be_nil
- visit "/users/#{user.to_param}"
+ visit '/users'
+ click_link 'Show'
page.source =~ %r{img src="/([^"]+large[^"]+)\?.*"}
image_path = $1
image_path.should_not be_blank
- File.should_not be_exist(Rails.root.join('public',image_path))
+ in_current_dir do
+ File.should_not be_exist(File.join('public',image_path))
+ end
end
When /^I generate the "(.*?)" migration as follows:$/ do |migration_name, code|
run_simple(%{bundle exec ./script/rails generate migration #{migration_name}})
- migration_filename = Dir[Rails.root.join('db', 'migrate', "*#{migration_name}.rb")].first
+ migration_filename = in_current_dir do
+ Dir[File.join('db', 'migrate', "*#{migration_name}.rb")].first
+ end
write_file(migration_filename, <<-MIGRATION)
class #{migration_name.classify} < ActiveRecord::Migration
#{code}
@@ -74,21 +79,24 @@ class #{migration_name.classify} < ActiveRecord::Migration
end
When /^I run the down database migration$/ do
- migration_filename = Dir[Rails.root.join('db', 'migrate', '*')].sort.last
+ migration_filename = in_current_dir do
+ Dir[File.join('db', 'migrate', '*')].sort.last
+ end
migration_filename =~ %r{.*/(\d+)_[^/]+.rb}
version = $1
version.should_not be_blank
run_simple("bundle exec rake db:migrate:down VERSION=#{version}")
end
Then /^I see the large avatar on the user show page$/ do
- user = User.last
- user.should_not be_nil
- visit "/users/#{user.to_param}"
+ visit '/users'
+ click_link 'Show'
page.source =~ %r{img src="/([^"]+large[^"]+)\?.*"}
image_path = $1
image_path.should_not be_blank
- File.should be_exist(Rails.root.join('public',image_path))
+ in_current_dir do
+ File.should be_exist(File.join('public',image_path))
+ end
end
View
2 features/support/rails.rb
@@ -11,6 +11,8 @@
end
After do
+ RailsServer.stop
+
ORIGINAL_BUNDLE_VARS.each_pair do |key, value|
ENV[key] = value
end

0 comments on commit 865d8f1

Please sign in to comment.