This repository has been archived by the owner on Jul 24, 2018. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wrap specs in class; introduce 'let' block
After watching a video on Boston Ruby, it is better to wrap your files in a class, so I've done that. Nothing else changed in that instance. Also, minitest 2.6.0 introduced the let syntax to mimic a behavior in RSpec, so I made a change for @session to be a let :session block instead. Not sure about performance on it, but if I can get mocking to work with these tests, it might not matter.
- Loading branch information
Nick Klauer (a03182)
committed
Sep 15, 2011
1 parent
bfd370c
commit 55c8a36
Showing
5 changed files
with
155 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,103 +1,108 @@ | ||
require_relative 'spec_helper' | ||
|
||
class ConfigTests < MiniTest::Unit::TestCase | ||
|
||
describe Mantis::Config do | ||
describe Mantis::Config do | ||
|
||
before do | ||
@session = create_session | ||
@configs = %w{ statuses priorities severities reproducibilities | ||
let :session do | ||
create_session | ||
end | ||
|
||
before do | ||
@configs = %w{ statuses priorities severities reproducibilities | ||
projections etas resolutions access_levels | ||
project_statuses project_view_states view_states | ||
custom_field_types } | ||
end | ||
|
||
describe " config" do | ||
it "should retrieve statuses, priorities, severities, and more" do | ||
@configs.each { |w| | ||
@session.config.send(w).size.must_be :>=, 1 | ||
} | ||
end | ||
|
||
describe " config" do | ||
it "should retrieve statuses, priorities, severities, and more" do | ||
@configs.each { |w| | ||
session.config.send(w).size.must_be :>=, 1 | ||
} | ||
end | ||
it "should return an array for all config types" do | ||
@configs.each { |c| | ||
assert_instance_of Array, @session.config.send(c) | ||
} | ||
@configs.each { |c| | ||
assert_instance_of Array, session.config.send(c) | ||
} | ||
end | ||
it "should get the statuses of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.statuses, "acknowledged") | ||
end | ||
it "should get the priorities of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.priorities, "none") | ||
end | ||
it "should get the severities of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.severities, "feature") | ||
end | ||
it "should get the reproducibilities of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.reproducibilities, "always") | ||
end | ||
it "should get the version of Mantis we're connecting to" do | ||
@session.config.version.wont_be_nil | ||
end | ||
it "should get the projections of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.projections, "none") | ||
end | ||
it "should get the ETA's of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.etas, "none") | ||
end | ||
it "should get the resolutions of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.resolutions, "open") | ||
end | ||
it "should get the access levels of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.access_levels, "viewer") | ||
end | ||
it "should get the project statuses of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.project_statuses, "development") | ||
end | ||
it "should get the project view states of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.project_view_states, "public") | ||
end | ||
it "should get the issue view states of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.view_states, "public") | ||
end | ||
it "should get the custom_field_types of Mantis we're connecting to" do | ||
wont_be_nil_for(@session.config.custom_field_types, "Numeric") | ||
end | ||
it "project_status_for should convert :symbol to \"string\"" do | ||
@session.config.object_ref_for_value(:project_status, :development).wont_be_empty | ||
end | ||
it "view_state_for should convert :symbol to \"string\"" do | ||
@session.config.object_ref_for_value(:view_state, :public).wont_be_empty | ||
end | ||
it "access_min should convert :symbol to \"string\"" do | ||
@session.config.object_ref_for_value(:access_min, :viewer).wont_be_empty | ||
end | ||
|
||
describe "statuses" do | ||
it "should map acknowledged status" do | ||
s = @session.config.object_ref_for_value(:project_status, :release) | ||
assert s[:name] == "release" | ||
it "should get the statuses of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.statuses, "acknowledged") | ||
end | ||
it "should get the priorities of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.priorities, "none") | ||
end | ||
it "should get the severities of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.severities, "feature") | ||
end | ||
it "should get the reproducibilities of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.reproducibilities, "always") | ||
end | ||
it "should get the version of Mantis we're connecting to" do | ||
session.config.version.wont_be_nil | ||
end | ||
it "should get the projections of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.projections, "none") | ||
end | ||
it "should get the ETA's of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.etas, "none") | ||
end | ||
it "should get the resolutions of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.resolutions, "open") | ||
end | ||
it "should get the access levels of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.access_levels, "viewer") | ||
end | ||
it "should get the project statuses of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.project_statuses, "development") | ||
end | ||
it "should get the project view states of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.project_view_states, "public") | ||
end | ||
it "should get the issue view states of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.view_states, "public") | ||
end | ||
it "should get the custom_field_types of Mantis we're connecting to" do | ||
wont_be_nil_for(session.config.custom_field_types, "Numeric") | ||
end | ||
it "project_status_for should convert :symbol to \"string\"" do | ||
session.config.object_ref_for_value(:project_status, :development).wont_be_empty | ||
end | ||
it "view_state_for should convert :symbol to \"string\"" do | ||
session.config.object_ref_for_value(:view_state, :public).wont_be_empty | ||
end | ||
it "access_min should convert :symbol to \"string\"" do | ||
session.config.object_ref_for_value(:access_min, :viewer).wont_be_empty | ||
end | ||
end # statuses | ||
|
||
describe "meta-method mapping" do | ||
meth_to_val = { status: :acknowledged, | ||
priority: :none, | ||
severity: :feature, | ||
reproducibility: :always, | ||
projection: :none, | ||
eta: :none, | ||
resolution: :open, | ||
access_level: :viewer, | ||
project_status: :development, | ||
project_view_state: :public, | ||
view_state: :public, | ||
custom_field_type: :Numeric | ||
} | ||
meth_to_val.each { |k,v| | ||
it "should find a list of ObjectRef Type for #{k}" do | ||
refute_nil @session.config.object_ref_for_value(k,v) | ||
describe "statuses" do | ||
it "should map acknowledged status" do | ||
s = session.config.object_ref_for_value(:project_status, :release) | ||
assert s[:name] == "release" | ||
end | ||
} | ||
end # statuses | ||
|
||
describe "meta-method mapping" do | ||
meth_to_val = { status: :acknowledged, | ||
priority: :none, | ||
severity: :feature, | ||
reproducibility: :always, | ||
projection: :none, | ||
eta: :none, | ||
resolution: :open, | ||
access_level: :viewer, | ||
project_status: :development, | ||
project_view_state: :public, | ||
view_state: :public, | ||
custom_field_type: :Numeric | ||
} | ||
meth_to_val.each { |k,v| | ||
it "should find a list of ObjectRef Type for #{k}" do | ||
refute_nil session.config.object_ref_for_value(k,v) | ||
end | ||
} | ||
|
||
end # meta-method mapping | ||
end # config | ||
end # Mantis::Config | ||
end # meta-method mapping | ||
end # config | ||
end # Mantis::Config | ||
end # ConfigTest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.