Skip to content

Commit

Permalink
Added simplecov for local coverage reporting and cleaned up Cucumber …
Browse files Browse the repository at this point in the history
…step files
  • Loading branch information
visoft committed Jun 23, 2013
1 parent 3badf7e commit cfe177f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 64 deletions.
10 changes: 10 additions & 0 deletions .simplecov
@@ -0,0 +1,10 @@
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.9') && ENV['COVERAGE']
require 'simplecov'
require 'coveralls'

SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
SimpleCov::Formatter::HTMLFormatter
]

SimpleCov.start
end
12 changes: 10 additions & 2 deletions Rakefile
Expand Up @@ -13,11 +13,19 @@ Cucumber::Rake::Task.new(:features) do |t|
t.cucumber_opts = "features --format progress"
end


Bundler::GemHelper.install_tasks
task :default => [:spec, :features]

task :test_with_coveralls => [:spec, :features, 'coveralls_push_workaround']
desc "Run with code coverage"
task :coverage do
ENV['COVERAGE'] = 'true' if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.9')

Rake::Task["spec"].execute
Rake::Task["features"].execute
end

desc "Run test with coveralls"
task :test_with_coveralls => [:coverage, 'coveralls_push_workaround']
task :coveralls_push_workaround do
if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.9')
require 'coveralls/rake/task'
Expand Down
60 changes: 2 additions & 58 deletions features/step_definitions/service_steps.rb
Expand Up @@ -20,14 +20,6 @@
end
end

Given /^a HTTP BasicAuth ODataService exists$/ do
@service = OData::Service.new(BASICAUTH_URL)
end

Given /^a HTTPS BasicAuth ODataService exists$/ do
@service = OData::Service.new(HTTPS_BASICAUTH_URL)
end

Given /^a HTTP BasicAuth ODataService exists using username "([^\"]*)" and password "([^\"]*)"$/ do |username, password|
@service = OData::Service.new(BASICAUTH_URL, { :username => username, :password => password })
end
Expand All @@ -36,14 +28,6 @@
lambda { @service = OData::Service.new(BASICAUTH_URL, { :username => username, :password => password }) }.should raise_error(msg)
end

Given /^a HTTP BasicAuth ODataService exists it should throw an exception with message containing "([^\"]*)"$/ do |msg|
lambda { @service = OData::Service.new(BASICAUTH_URL) }.should raise_error(/#{msg}.*/)
end

Given /^a HTTPS BasicAuth ODataService exists it should throw an exception with message containing "([^"]*)"$/ do |msg|
lambda { @service = OData::Service.new(HTTPS_BASICAUTH_URL) }.should raise_error(/#{msg}.*/)
end

Given /^a HTTP BasicAuth ODataService exists it should throw an exception with message "([^\"]*)"$/ do |msg|
lambda { @service = OData::Service.new(BASICAUTH_URL) }.should raise_error(msg)
end
Expand All @@ -56,10 +40,6 @@
@service_query = @service.send(method)
end

Then /^the result should be "([^\"]*)"$/ do |result|
@service_result.should eq result
end

Then /^the integer result should be ([^\"]*)$/ do |result|
@service_result.should eq result.to_i
end
Expand Down Expand Up @@ -216,27 +196,6 @@
table.diff!(result_table)
end

Then /^the save result should be:$/ do |table|
# table is a Cucumber::Ast::Table

fields = table.hashes[0].keys

# Build an array of hashes so that we can compare tables
results = []

@saved_result.each do |result|
obj_hash = Hash.new
fields.each do |field|
obj_hash[field] = result.send(field)
end
results << obj_hash
end

result_table = Cucumber::Ast::Table.new(results)

table.diff!(result_table)
end

Then /^a class named "([^\"]*)" should exist$/ do |klass_name|
(Object.const_defined? klass_name).should eq true
end
Expand All @@ -261,14 +220,6 @@
end

# Type tests
Then /^the "([^\"]*)" method should return a (.*)/ do |method_name, type|
methods = method_name.split '.'
if methods.length == 1
@service_result.send(method_name).class.to_s.should eq type
else
@service_result.send(methods[0]).send(methods[1]).class.to_s.should eq type
end
end
Then /^the "([^\"]*)" method on the object should return a (.*)/ do |method_name, type|
methods = method_name.split '.'
if methods.length == 1
Expand All @@ -284,16 +235,9 @@

Then /^the new query result's time "([^\"]*)" should equal the saved query result$/ do |method_name|
methods = method_name.split '.'
if methods.length == 1
@service_result.send(method_name).xmlschema(3).should eq @stored_query_result.send(method_name).xmlschema(3)
else
@service_result.send(methods[0]).send(methods[1]).xmlschema(3).should eq @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
end
@service_result.send(methods[0]).send(methods[1]).xmlschema(3).should eq @stored_query_result.send(methods[0]).send(methods[1]).xmlschema(3)
end

Then /^show me the results$/ do
puts @service_result
end

Then /^the result count should be (\d+)$/ do |expected_count|
@service_result.count.should eq expected_count.to_i
Expand All @@ -313,4 +257,4 @@

When /^(.*) within a cassette named "([^"]*)"$/ do |the_step, cassette_name|
VCR.use_cassette(cassette_name) { step the_step }
end
end
6 changes: 4 additions & 2 deletions features/support/env.rb
Expand Up @@ -3,5 +3,7 @@
require lib + '/ruby_odata'
require 'machinist'

require 'coveralls'
Coveralls.wear_merged!
require 'simplecov'
# require 'coveralls'

# Coveralls.wear_merged!
1 change: 1 addition & 0 deletions ruby_odata.gemspec
Expand Up @@ -31,6 +31,7 @@ Gem::Specification.new do |s|
s.add_development_dependency("guard-rspec", "~> 1.2.1")
s.add_development_dependency("guard-cucumber", "~> 1.2.0")
s.add_development_dependency("vcr", "~> 2.2.4")
s.add_development_dependency("simplecov", "~> 0.7.1")
s.add_development_dependency("coveralls", "~> 0.6.7")

s.files = `git ls-files`.split("\n")
Expand Down
5 changes: 3 additions & 2 deletions spec/spec_helper.rb
@@ -1,6 +1,7 @@
require 'ruby_odata'
require 'webmock/rspec'
require 'coveralls'
Coveralls.wear_merged!
require 'simplecov'
# require 'coveralls'
# Coveralls.wear_merged!

Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }

0 comments on commit cfe177f

Please sign in to comment.