tracks/vendor/plugins/rspec/spec/spec/extensions/main_spec.rb
Luke Melia 35ae5fc431 Next step in upgrading Tracks to Rails 2.2. Some highlights:
* Ran rake rails:update
* Added old actionwebservice framework
* Updated RSpec and RSpec-Rails
* Removed asset_packager plugin (not compatible, Scott no longer maintaining), and replaced with bundle_fu. See the bundle_fu README for more info.
* Hacks to UJS and ARTS plugins, which are no longer supported. Probably should move off both UJS and RJS.
* Hack to flashobject_helper plugin (upgrade to Rails 2.2-compatible version if/when it comes out.)
* Hack to skinny-spec plugin, for Rails 2.2 compatibility. Should check for official release.
* Hacks to resource_feeder plugin, for Rails 2.2 compatibility. Should check for official release (not likely) or move off it.
* Addressed some deprecation warnings. More to come.
* My mobile mime type hackery is no longer necessary with new Rails features. Yay!
* Updated environment.rb.tmpl with changes

TODO:
* Restore view specs marked pending
* Fix failing integration tests.
* Try selenium tests.
* Investigate OpenID support.
* Address deprecation warnings.
* Consider moving parts of environment.rb to initializers
* Address annoying config.gem warning about highline gem
2008-11-30 00:34:15 -05:00

71 lines
No EOL
2.3 KiB
Ruby

require File.dirname(__FILE__) + '/../../spec_helper.rb'
module Spec
module Extensions
describe Main do
include SandboxedOptions
before(:each) do
@main = Class.new do; include Main; end
end
after(:each) do
$rspec_story_steps = @original_rspec_story_steps
end
specify {@main.should respond_to(:describe)}
specify {@main.should respond_to(:context)}
it "should raise when no block given to describe" do
lambda { @main.describe "foo" }.should raise_error(ArgumentError)
end
it "should raise when no description given to describe" do
lambda { @main.describe do; end }.should raise_error(ArgumentError)
end
it "should registered ExampleGroups by default" do
example_group = @main.describe("The ExampleGroup") do end
Spec::Runner.options.example_groups.should include(example_group)
end
it "should not run unregistered ExampleGroups" do
example_group = @main.describe("The ExampleGroup") do
unregister
end
Spec::Runner.options.example_groups.should_not include(example_group)
end
it "should create a shared ExampleGroup with share_examples_for" do
group = @main.share_examples_for "all things" do end
group.should be_an_instance_of(Spec::Example::SharedExampleGroup)
end
describe "#share_as" do
before(:each) do
$share_as_examples_example_module_number ||= 1
$share_as_examples_example_module_number += 1
t = Time.new.to_i
@group_name = "Group#{$share_as_examples_example_module_number}"
end
it "should create a shared ExampleGroup" do
group = @main.share_as @group_name do end
group.should be_an_instance_of(Spec::Example::SharedExampleGroup)
end
it "should create a constant that points to a Module" do
group = @main.share_as @group_name do end
Object.const_get(@group_name).should equal(group)
end
it "should bark if you pass it something not-constantizable" do
lambda do
@group = @main.share_as "Non Constant" do end
end.should raise_error(NameError, /The first argument to share_as must be a legal name for a constant/)
end
end
end
end
end