Skip to content

Commit

Permalink
[merb-action-args] RSpec 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ngollan committed Apr 20, 2011
1 parent a96c365 commit 5f7b0b4
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 21 deletions.
4 changes: 4 additions & 0 deletions merb-action-args/.rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
--color
--format progress
--format html
--out rspec_results.html
16 changes: 7 additions & 9 deletions merb-action-args/Rakefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
require 'rubygems'
require 'rake'
require 'rake/rdoctask'

# Load this library's version information
require File.expand_path('../lib/merb-action-args/version', __FILE__)

require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.spec_opts << '--options' << 'spec/spec.opts' if File.exists?('spec/spec.opts')
spec.libs << 'lib' << 'spec'
spec.spec_files = FileList['spec/**/*_spec.rb']
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = "spec/**/*_spec.rb"
spec.fail_on_error = false
end

Spec::Rake::SpecTask.new(:rcov) do |spec|
spec.libs << 'lib' << 'spec'
spec.pattern = 'spec/**/*_spec.rb'
RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.pattern = "spec/**/*_spec.rb"
spec.fail_on_error = false
spec.rcov = true
end

Expand Down
2 changes: 1 addition & 1 deletion merb-action-args/merb-action-args.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ Gem::Specification.new do |gem|
gem.add_dependency 'ParseTree', '>= 2.1.1'

# Development dependencies
gem.add_development_dependency 'rspec', '>= 1.2.9'
gem.add_development_dependency 'rspec', '>= 2.5'
end
13 changes: 8 additions & 5 deletions merb-action-args/spec/action_args_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require 'spec_helper'
require 'stringio'

Merb.logger.set_log(StringIO.new)

describe "ActionArgs" do

Expand Down Expand Up @@ -35,15 +38,15 @@
end

it "should be able to accept multiple Action Arguments" do
dispatch_to(ActionArgs, :multi, :foo => "bar", :bar => "baz").body.should == "bar baz"
dispatch_to(ActionArgs, :multi, :foo => "para_foo", :bar => "para_bar").body.should == "para_foo para_bar"
end

it "should be able to handle defaults in Action Arguments" do
dispatch_to(ActionArgs, :defaults, :foo => "bar").body.should == "bar bar"
dispatch_to(ActionArgs, :defaults, :foo => "para_foo").body.should == "para_foo bar"
end

it "should be able to handle out of order defaults" do
dispatch_to(ActionArgs, :defaults_mixed, :foo => "bar", :baz => "bar").body.should == "bar bar bar"
dispatch_to(ActionArgs, :defaults_mixed, :foo => "para_foo", :baz => "para_baz").body.should == "para_foo bar para_baz"
end

it "should throw a BadRequest if the arguments are not provided" do
Expand All @@ -63,7 +66,7 @@
end

it "should be able to handle [] defaults" do
dispatch_to(ActionArgs, :with_default_array, :foo => "bar").body.should == "bar []"
dispatch_to(ActionArgs, :with_default_array, :foo => "para_foo").body.should == "para_foo []"
end

it "should print out the missing parameters if all are required" do
Expand All @@ -73,7 +76,7 @@

it "should only print out missing parameters" do
lambda { dispatch_to(ActionArgs, :multi, :foo => "Hello") }.should raise_error(
Merb::ControllerExceptions::BadRequest, /were missing bar/)
Merb::ControllerExceptions::BadRequest, /were missing bar/)
end

end
2 changes: 0 additions & 2 deletions merb-action-args/spec/spec.opts

This file was deleted.

8 changes: 4 additions & 4 deletions merb-action-args/spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
require "merb-action-args"

# Satisfies Autotest and anyone else not using the Rake tasks
require 'spec'
require 'rspec'

# Additional files required for specs
require "controllers/action-args"

Merb.start :environment => 'test'

Spec::Runner.configure do |config|
config.include Merb::Test::RequestHelper
end
RSpec.configure do |config|
config.include Merb::Test::RequestHelper
end

0 comments on commit 5f7b0b4

Please sign in to comment.