Skip to content

Commit

Permalink
adding generator feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tevio committed Dec 15, 2010
1 parent 326e05e commit 0c3e521
Show file tree
Hide file tree
Showing 12 changed files with 679 additions and 34 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ gemspec

group :test do
#gem 'rails', '3.0.1'
gem 'rspec'
gem 'aruba'
gem 'rspec', '~> 2.3.0'
gem 'aruba', '~> 0.2.7'
end
51 changes: 51 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
PATH
remote: .
specs:
recurs (0.0.4.1)
actic
ri_cal (>= 0.8.7)

GEM
remote: http://rubygems.org/
specs:
actic (0.0.2)
ri_cal (>= 0.8.7)
aruba (0.2.7)
background_process
cucumber (~> 0.10.0)
background_process (1.2)
builder (3.0.0)
cucumber (0.10.0)
builder (>= 2.1.2)
diff-lcs (~> 1.1.2)
gherkin (~> 2.3.2)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
diff-lcs (1.1.2)
gherkin (2.3.2)
json (~> 1.4.6)
term-ansicolor (~> 1.0.5)
json (1.4.6)
rake (0.8.7)
ri_cal (0.8.7)
rspec (2.3.0)
rspec-core (~> 2.3.0)
rspec-expectations (~> 2.3.0)
rspec-mocks (~> 2.3.0)
rspec-core (2.3.0)
rspec-expectations (2.3.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.3.0)
term-ansicolor (1.0.5)

PLATFORMS
ruby

DEPENDENCIES
actic
aruba (~> 0.2.7)
cucumber
rake
recurs!
ri_cal (>= 0.8.7)
rspec (~> 2.3.0)
11 changes: 8 additions & 3 deletions features/generators.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,21 @@ Feature:
source "http://rubygems.org"
gem 'rails', '3.0.0'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'recurs', :path => '../../../'
gem 'recurs' #, :path => '../../../'
"""
And I run "bundle install"
And I run "rails generate recurs_widget Event"
And I run "rake db:migrate"
Then the output should contain:
"""
create app/models/event.rb
"""
And the following files should exist:
| app/models/event.rb |
| app/views/events/index.html.haml |
| app/views/events/new.html.haml |
| app/views/events/edit.html.haml |
| app/views/events/_form.html.haml |
| app/views/events/schemes/_form.html.haml |
And the following files should not exist:
| test/fixtures/users.yml |
And I run "rake db:migrate"
283 changes: 268 additions & 15 deletions features/step_definitions/aruba_steps.rb
Original file line number Diff line number Diff line change
@@ -1,24 +1,277 @@
When /^I do aruba (.*)$/ do |aruba_step|
begin
When(aruba_step)
rescue => e
@aruba_exception = e
require 'aruba/api'
#require 'aruba/cucumber'
#=begin
World(Aruba::Api)

Before('@disable-bundler') do
unset_bundler_env_vars
end

Before do
@__aruba_original_paths = (ENV['PATH'] || '').split(File::PATH_SEPARATOR)
ENV['PATH'] = ([File.expand_path('bin')] + @__aruba_original_paths).join(File::PATH_SEPARATOR)
end

After do
ENV['PATH'] = @__aruba_original_paths.join(File::PATH_SEPARATOR)
end

Before do
FileUtils.rm_rf(current_dir)
end

Before('@puts') do
@puts = true
end

Before('@announce-cmd') do
@announce_cmd = true
end

Before('@announce-stdout') do
@announce_stdout = true
end

Before('@announce-stderr') do
@announce_stderr = true
end

Before('@announce-dir') do
@announce_dir = true
end

Before('@announce-env') do
@announce_env = true
end

Before('@announce') do
@announce_stdout = true
@announce_stderr = true
@announce_cmd = true
@announce_dir = true
@announce_env = true
end

After do
restore_env
end

Given /^I'm using a clean gemset "([^"]*)"$/ do |gemset|
use_clean_gemset(gemset)
end

Given /^a directory named "([^"]*)"$/ do |dir_name|
create_dir(dir_name)
end

Given /^a file named "([^"]*)" with:$/ do |file_name, file_content|
create_file(file_name, file_content)
end

Given /^an empty file named "([^"]*)"$/ do |file_name|
create_file(file_name, "")
end

When /^I write to "([^"]*)" with:$/ do |file_name, file_content|
create_file(file_name, file_content, false)
end

When /^I overwrite "([^"]*)" with:$/ do |file_name, file_content|
create_file(file_name, file_content, true)
end

When /^I append to "([^"]*)" with:$/ do |file_name, file_content|
append_to_file(file_name, file_content)
end

When /^I remove the file "([^"]*)"$/ do |file_name|
remove_file(file_name)
end

When /^I cd to "([^"]*)"$/ do |dir|
cd(dir)
end

When /^I run "(.*)"$/ do |cmd|
run_simple(unescape(cmd), false)
# sleep(5)
end

When /^I successfully run "(.*)"$/ do |cmd|
run_simple(unescape(cmd))
end

When /^I run "([^"]*)" interactively$/ do |cmd|
run_interactive(unescape(cmd))
end

When /^I type "([^"]*)"$/ do |input|
write_interactive(ensure_newline(input))
end

Then /^the output should contain "([^"]*)"$/ do |partial_output|
assert_partial_output(unescape(partial_output))
end

Then /^the output from "([^"]*)" should contain "([^"]*)"$/ do |cmd, partial_output|
output_from(cmd).should include(unescape(partial_output))
end

Then /^the output from "([^"]*)" should not contain "([^"]*)"$/ do |cmd, partial_output|
output_from(cmd).should_not include(unescape(partial_output))
end

Then /^the output should not contain "([^"]*)"$/ do |partial_output|
all_output.should_not include(unescape(partial_output))
end

Then /^the output should contain:$/ do |partial_output|
all_output.should include(unescape(partial_output))
end

Then /^the output should not contain:$/ do |partial_output|
all_output.should_not include(unescape(partial_output))
end

Then /^the output should contain exactly "([^"]*)"$/ do |exact_output|
all_output.should == unescape(exact_output)
end

Then /^the output should contain exactly:$/ do |exact_output|
all_output.should == unescape(exact_output)
end

# "the output should match" allows regex in the partial_output, if
# you don't need regex, use "the output should contain" instead since
# that way, you don't have to escape regex characters that
# appear naturally in the output
Then /^the output should match \/([^\/]*)\/$/ do |partial_output|
all_output.should =~ /#{partial_output}/
end

Then /^the output should match:$/ do |partial_output|
all_output.should =~ /#{partial_output}/m
end

Then /^the exit status should be (\d+)$/ do |exit_status|
@last_exit_status.should == exit_status.to_i
end

Then /^the exit status should not be (\d+)$/ do |exit_status|
@last_exit_status.should_not == exit_status.to_i
end

Then /^it should (pass|fail) with:$/ do |pass_fail, partial_output|
self.__send__("assert_#{pass_fail}ing_with", partial_output)
end

Then /^it should (pass|fail) with exactly:$/ do |pass_fail, exact_output|
assert_exit_status_and_output(pass_fail == "pass", exact_output, true)
end

Then /^it should (pass|fail) with regexp?:$/ do |pass_fail, partial_output|
Then "the output should match:", partial_output
if pass_fail == 'pass'
@last_exit_status.should == 0
else
@last_exit_status.should_not == 0
end
end

# Useful for debugging timing problems
When /^sleep (\d+)$/ do |time|
sleep time.to_i
Then /^the stderr should contain "([^"]*)"$/ do |partial_output|
all_stderr.should include(unescape(partial_output))
end

Then /^the stderr should contain exactly:$/ do |exact_output|
all_stderr.should == exact_output
end

Then /^the stdout should contain "([^"]*)"$/ do |partial_output|
all_stdout.should include(unescape(partial_output))
end

Then /^the stdout should contain exactly:$/ do |exact_output|
all_stdout.should == exact_output
end

Then /^the stderr should not contain "([^"]*)"$/ do |partial_output|
all_stderr.should_not include(unescape(partial_output))
end

Then /^the stdout should not contain "([^"]*)"$/ do |partial_output|
all_stdout.should_not include(unescape(partial_output))
end

Then /^the stdout from "([^"]*)" should contain "([^"]*)"$/ do |cmd, partial_output|
stdout_from(cmd).should include(unescape(partial_output))
end

Then /^the stdout from "([^"]*)" should not contain "([^"]*)"$/ do |cmd, partial_output|
stdout_from(cmd).should_not include(unescape(partial_output))
end

Then /^the stderr from "([^"]*)" should contain "([^"]*)"$/ do |cmd, partial_output|
stderr_from(cmd).should include(unescape(partial_output))
end

Then /^the stderr from "([^"]*)" should not contain "([^"]*)"$/ do |cmd, partial_output|
stderr_from(cmd).should_not include(unescape(partial_output))
end

Then /^the file "([^"]*)" should not exist$/ do |file_name|
check_file_presence([file_name], false)
end

Then /^the following files should exist:$/ do |files|
check_file_presence(files.raw.map{|file_row| file_row[0]}, true)
end

Then /^the following files should not exist:$/ do |files|
check_file_presence(files.raw.map{|file_row| file_row[0]}, false)
end

Then /^a file named "([^"]*)" should exist$/ do |file|
check_file_presence([file], true)
end

Then /^a file named "([^"]*)" should not exist$/ do |file|
check_file_presence([file], false)
end

Then /^the following directories should exist:$/ do |directories|
check_directory_presence(directories.raw.map{|directory_row| directory_row[0]}, true)
end

Then /^the following directories should not exist:$/ do |directories|
check_directory_presence(directories.raw.map{|directory_row| directory_row[0]}, false)
end

Then /^a directory named "([^"]*)" should exist$/ do |directory|
check_directory_presence([directory], true)
end

Then /^a directory named "([^"]*)" should not exist$/ do |directory|
check_directory_presence([directory], false)
end

Then /^the file "([^"]*)" should contain "([^"]*)"$/ do |file, partial_content|
check_file_content(file, partial_content, true)
end

Then /^the file "([^"]*)" should not contain "([^"]*)"$/ do |file, partial_content|
check_file_content(file, partial_content, false)
end

Then /^the file "([^"]*)" should contain exactly:$/ do |file, exact_content|
check_exact_file_content(file, exact_content)
end

Then /^aruba should fail with "([^"]*)"$/ do |error_message|
@aruba_exception.message.should include(unescape(error_message))
Then /^the file "([^"]*)" should match \/([^\/]*)\/$/ do |file, partial_content|
check_file_content(file, /#{partial_content}/, true)
end

Then /^the following step should fail with Spec::Expectations::ExpectationNotMetError:$/ do |multiline_step|
proc {steps multiline_step}.should raise_error(RSpec::Expectations::ExpectationNotMetError)
Then /^the file "([^"]*)" should not match \/([^\/]*)\/$/ do |file, partial_content|
check_file_content(file, /#{partial_content}/, false)
end

Then /^the output should be (\d+) bytes long$/ do |length|
all_output.chomp.length.should == length.to_i
end
#=end
Loading

0 comments on commit 0c3e521

Please sign in to comment.